2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 * Music Player Daemon API
8 * LICENSE: This source file is subject to version 3.01 of the PHP license
9 * that is available thorugh the world-wide-web at the following URI:
10 * http://www.php.net/license/3_01.txt. If you did not receive a copy of
11 * the PHP License and are unable to obtain it through the web, please
12 * send a note to license@php.net so we can mail you a copy immediately.
14 * @category Networking
16 * @author Graham Christensen <graham.christensen@itrebal.com>
17 * @copyright 2006 Graham Christensen
18 * @license http://www.php.net/license/3_01.txt
22 * API for the playback portion of Music Player Daemon commands
24 * For controlling playback aspects of MPD
26 * @category Networking
28 * @author Graham Christensen <graham.christensen@itrebal.com>
29 * @copyright 2006 Graham Christensen
30 * @license http://www.php.net/license/3_01.txt
33 class Net_MPD_Playback extends Net_MPD_Common
36 * Gets the current song and related information
38 * @return array of data
40 public function getCurrentSong()
42 $out = $this->runCommand('currentsong');
43 if (!isset($out['file'][0])) {
46 return $out['file'][0];
52 * Set crossfade between songs
54 * @param $sec int, seconds to crossfade
57 public function setCrossfade($sec)
59 $this->runCommand('crossfade', $sec);
66 * Continue to the next song
70 public function nextSong()
72 $this->runCommand('next');
77 * Go back to the previous song
81 public function previousSong()
83 $this->runCommand('previous');
90 * Pauses or plays the audio
94 public function pause()
96 $this->runCommand('pause');
105 * @param $song int, song position in playlist to start playing at
108 public function play($song = 0)
110 $this->runCommand('play', $song);
115 * Starts playback by Id
117 * @param $song int, song Id
120 public function playId($song = 0)
122 $this->runCommand('playid', $song);
129 * Sets 'random' mode on/off
131 * @param $on bool true or false, for random or not (respectively),
135 public function random($on = false)
137 $this->runCommand('random', (int)$on);
144 * Sets 'random' mode on/off
146 * @param $on bool true or false, for repeat or not (respectively),
150 public function repeat($on = false)
152 $this->runCommand('repeat', (int)$on);
159 * Seek a position in a song
161 * @param $song int song position in playlist
162 * @param $time int time in seconds to seek to
165 public function seek($song, $time)
167 $this->runCommand('seek', array($song, $time));
174 * Seek a position in a song
176 * @param $song int song Id
177 * @param $time int time in seconds to seek to
180 public function seekId($song, $time)
182 $this->runCommand('seekid', array($song, $time));
191 * @param $vol int volume
194 public function setVolume($vol)
196 $this->runCommand('setvol', $vol);
207 public function stop()
209 $this->runCommand('stop');