summaryrefslogtreecommitdiffstats
path: root/lib/mpd.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-09 16:34:40 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-09 16:34:40 +0000
commitbcad40a05ab2dc2a341a3227e30b96668bce4500 (patch)
tree6fca27588d53a1b24705bd2834e9e643bb729bd1 /lib/mpd.php
downloadampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.tar.gz
ampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.tar.bz2
ampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.zip
New Import
Diffstat (limited to 'lib/mpd.php')
-rw-r--r--lib/mpd.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/lib/mpd.php b/lib/mpd.php
new file mode 100644
index 00000000..166bfe5b
--- /dev/null
+++ b/lib/mpd.php
@@ -0,0 +1,75 @@
+<?php
+/*
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+/*!
+ @function addToPlaylist()
+ @discussion adds a bunch of songs to the mpd playlist
+ this takes a mpd object, and an array of songs
+*/
+function addToPlaylist( $myMpd, $song_ids=array()) {
+
+ foreach( $song_ids as $song_id ) {
+
+ /* There are two ways to do this, filename or URL */
+ if (conf('mpd_method') == 'url') {
+ // We just need to generate a standard stream URL and pass that
+ $song = new Song($song_id);
+ $sess_id = session_id();
+ if ($song->type == ".flac") { $song->type = ".ogg"; }
+ if ($GLOBALS['user']->prefs['play_type'] == 'downsample') {
+ $ds = $GLOBALS['user']->prefs['sample_rate'];
+ }
+ $song_url = conf('web_path') . "/play/index.php?song=$song_id&uid=" . $GLOBALS['user']->id . "&sid=$sess_id&ds=$ds&name=." . $song->type;
+ if (is_null( $myMpd->PlAdd($song_url) ) ) {
+ $log_line = _("Error") . ": " . _("Could not add") . ": " . $song_url . " : " . $myMpd->errStr;
+ echo "<font class=\"error\">$log_line</font><br />\n";
+ log_event($GLOBALS['user']->username,'add',$log_line);
+ } // if it's null
+ } // if we want urls
+ else {
+ $song = new Song( $song_id );
+ $song_filename = $song->get_rel_path();
+ if( is_null( $myMpd->PLAdd( $song_filename ) ) ) {
+ $log_line = _("Error") . ": " . _("Could not add") . ": " . $song_filename . " : " . $myMpd->errStr;
+ echo "<font class=\"error\">$log_line</font><br />\n";
+ log_event($_SESSION['userdata']['username'],'add',$log_line);
+ } // end if it's null
+ // We still need to count if they use the file method
+ else {
+ $GLOBALS['user']->update_stats( $song_id );
+ } // end else
+
+ } // end else not url method
+ } // end foreach
+
+} // addToPlaylist
+
+/*!
+ @function show_mpd_control
+ @discussion shows the mpd controls
+*/
+function show_mpd_control() {
+
+ $_REQUEST['action'] = 'show_control';
+ require_once ('amp-mpd.php');
+
+
+} // show_mpd_control
+
+?>