]>
Commit | Line | Data |
---|---|---|
964dd0bc JW |
1 | <?php |
2 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | |
3 | /** | |
4 | * Music Player Daemon API | |
5 | * | |
6 | * PHP Version 5 | |
7 | * | |
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. | |
13 | * | |
14 | * @category Networking | |
15 | * @package Net_MPD | |
16 | * @author Graham Christensen <graham.christensen@itrebal.com> | |
17 | * @copyright 2006 Graham Christensen | |
18 | * @license http://www.php.net/license/3_01.txt | |
19 | * @version CVS: $ID:$ | |
20 | */ | |
21 | /** | |
22 | * API for the playback portion of Music Player Daemon commands | |
23 | * | |
24 | * For controlling playback aspects of MPD | |
25 | * | |
26 | * @category Networking | |
27 | * @package Net_MPD | |
28 | * @author Graham Christensen <graham.christensen@itrebal.com> | |
29 | * @copyright 2006 Graham Christensen | |
30 | * @license http://www.php.net/license/3_01.txt | |
31 | * @version CVS: $ID:$ | |
32 | */ | |
33 | class Net_MPD_Playback extends Net_MPD_Common | |
34 | { | |
35 | /** | |
36 | * Gets the current song and related information | |
37 | * | |
38 | * @return array of data | |
39 | */ | |
40 | public function getCurrentSong() | |
41 | { | |
42 | $out = $this->runCommand('currentsong'); | |
43 | if (!isset($out['file'][0])) { | |
44 | return false; | |
45 | } | |
46 | return $out['file'][0]; | |
47 | } | |
48 | ||
49 | ||
50 | ||
51 | /** | |
52 | * Set crossfade between songs | |
53 | * | |
54 | * @param $sec int, seconds to crossfade | |
55 | * @return bool | |
56 | */ | |
57 | public function setCrossfade($sec) | |
58 | { | |
59 | $this->runCommand('crossfade', $sec); | |
60 | return true; | |
61 | } | |
62 | ||
63 | ||
64 | ||
65 | /** | |
66 | * Continue to the next song | |
67 | * | |
68 | * @return bool | |
69 | */ | |
70 | public function nextSong() | |
71 | { | |
72 | $this->runCommand('next'); | |
73 | return true; | |
74 | } | |
75 | ||
76 | /** | |
77 | * Go back to the previous song | |
78 | * | |
79 | * @return bool | |
80 | */ | |
81 | public function previousSong() | |
82 | { | |
83 | $this->runCommand('previous'); | |
84 | return true; | |
85 | } | |
86 | ||
87 | ||
88 | ||
89 | /** | |
90 | * Pauses or plays the audio | |
91 | * | |
92 | * @return bool | |
93 | */ | |
94 | public function pause() | |
95 | { | |
96 | $this->runCommand('pause'); | |
97 | return true; | |
98 | } | |
99 | ||
100 | ||
101 | ||
102 | /** | |
103 | * Starts playback | |
104 | * | |
105 | * @param $song int, song position in playlist to start playing at | |
106 | * @return bool | |
107 | */ | |
108 | public function play($song = 0) | |
109 | { | |
110 | $this->runCommand('play', $song); | |
111 | return true; | |
112 | } | |
113 | ||
114 | /** | |
115 | * Starts playback by Id | |
116 | * | |
117 | * @param $song int, song Id | |
118 | * @return bool | |
119 | */ | |
120 | public function playId($song = 0) | |
121 | { | |
122 | $this->runCommand('playid', $song); | |
123 | return true; | |
124 | } | |
125 | ||
126 | ||
127 | ||
128 | /** | |
129 | * Sets 'random' mode on/off | |
130 | * | |
131 | * @param $on bool true or false, for random or not (respectively), | |
132 | optional | |
133 | * @return bool | |
134 | */ | |
135 | public function random($on = false) | |
136 | { | |
137 | $this->runCommand('random', (int)$on); | |
138 | return true; | |
139 | } | |
140 | ||
141 | ||
142 | ||
143 | /** | |
144 | * Sets 'random' mode on/off | |
145 | * @access public | |
146 | * @param $on bool true or false, for repeat or not (respectively), | |
147 | optional | |
148 | * @return true | |
149 | */ | |
150 | public function repeat($on = false) | |
151 | { | |
152 | $this->runCommand('repeat', (int)$on); | |
153 | return true; | |
154 | } | |
155 | ||
156 | ||
157 | ||
158 | /** | |
159 | * Seek a position in a song | |
160 | * | |
161 | * @param $song int song position in playlist | |
162 | * @param $time int time in seconds to seek to | |
163 | * @return bool | |
164 | */ | |
165 | public function seek($song, $time) | |
166 | { | |
167 | $this->runCommand('seek', array($song, $time)); | |
168 | return true; | |
169 | } | |
170 | ||
171 | ||
172 | ||
173 | /** | |
174 | * Seek a position in a song | |
175 | * | |
176 | * @param $song int song Id | |
177 | * @param $time int time in seconds to seek to | |
178 | * @return bool | |
179 | */ | |
180 | public function seekId($song, $time) | |
181 | { | |
182 | $this->runCommand('seekid', array($song, $time)); | |
183 | return true; | |
184 | } | |
185 | ||
186 | ||
187 | ||
188 | /** | |
189 | * Set volume | |
190 | * | |
191 | * @param $vol int volume | |
192 | * @return true | |
193 | */ | |
194 | public function setVolume($vol) | |
195 | { | |
196 | $this->runCommand('setvol', $vol); | |
197 | return true; | |
198 | } | |
199 | ||
200 | ||
201 | ||
202 | /** | |
203 | * Stop playback | |
204 | * | |
205 | * @return bool | |
206 | */ | |
207 | public function stop() | |
208 | { | |
209 | $this->runCommand('stop'); | |
210 | return true; | |
211 | } | |
212 | } | |
213 | ?> |