author | Dan |
Tue, 23 Sep 2008 23:31:51 -0400 | |
changeset 51 | 7009a9cbd46f |
parent 44 | 92dd253f501c |
child 55 | b8a3c9c54fbe |
permissions | -rw-r--r-- |
0
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
1 |
<?php |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
2 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
3 |
/** |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
4 |
* Action servlet (play, pause, etc.) |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
5 |
* |
6
5f35ebc4f9bb
First release version. Renamed to Greyhound and readme/license files added.
Dan
parents:
5
diff
changeset
|
6 |
* Greyhound - real web management for Amarok |
5
9b96265b5918
Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents:
3
diff
changeset
|
7 |
* Copyright (C) 2008 Dan Fuhry |
0
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
8 |
* |
5
9b96265b5918
Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents:
3
diff
changeset
|
9 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
9b96265b5918
Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents:
3
diff
changeset
|
10 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
9b96265b5918
Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents:
3
diff
changeset
|
11 |
* |
9b96265b5918
Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents:
3
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
9b96265b5918
Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents:
3
diff
changeset
|
13 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
0
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
14 |
*/ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
15 |
|
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
16 |
status('initializing Services_JSON'); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
17 |
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); |
0
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
18 |
|
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
19 |
// keep track of playlist refresh |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
20 |
$playlist_last_refresh = time(); |
0
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
21 |
|
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
22 |
/** |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
23 |
* Terminate a request with an error string formatted as JSON. |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
24 |
* @param string Error message |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
25 |
*/ |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
26 |
|
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
27 |
function json_die($msg) |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
28 |
{ |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
29 |
global $json; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
30 |
echo $json->encode(array( |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
31 |
'mode' => 'error', |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
32 |
'error' => $msg |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
33 |
)); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
34 |
return true; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
35 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
36 |
|
21
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
37 |
function ajax_request_handler($httpd, $socket) |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
38 |
{ |
3
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
39 |
global $playlist, $mime_types, $json, $allowcontrol; |
21
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
40 |
global $use_auth, $auth_data; |
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
41 |
|
44
92dd253f501c
First shot at getting a session management system in place. Login and logout pages are there, and auth seems to be working and sufficiently secure for the moment. Sessions last indefinitely and are cookie-based.
Dan
parents:
21
diff
changeset
|
42 |
if ( !session_check() ) |
92dd253f501c
First shot at getting a session management system in place. Login and logout pages are there, and auth seems to be working and sufficiently secure for the moment. Sessions last indefinitely and are cookie-based.
Dan
parents:
21
diff
changeset
|
43 |
return true; |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
44 |
|
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
45 |
// Set content type |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
46 |
$httpd->header("Content-type: {$mime_types['js']}"); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
47 |
|
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
48 |
// get PATH_INFO |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
49 |
$pathinfo = @substr(@substr($_SERVER['REQUEST_URI'], 1), @strpos(@substr($_SERVER['REQUEST_URI'], 1), '/')+1); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
50 |
if ( empty($pathinfo) ) |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
51 |
{ |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
52 |
return json_die('No action specified on URI'); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
53 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
54 |
|
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
55 |
$params = explode('/', $pathinfo); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
56 |
$action =& $params[0]; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
57 |
switch ( $action ) |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
58 |
{ |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
59 |
case 'stop': |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
60 |
case 'next': |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
61 |
case 'prev': |
3
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
62 |
if ( !$allowcontrol ) |
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
63 |
return false; |
5
9b96265b5918
Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents:
3
diff
changeset
|
64 |
echo dcop_action('player', $action); |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
65 |
break; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
66 |
case 'play': |
3
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
67 |
if ( !$allowcontrol ) |
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
68 |
return false; |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
69 |
echo dcop_action('player', 'playPause'); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
70 |
break; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
71 |
case 'jump': |
3
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
72 |
if ( !$allowcontrol ) |
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
73 |
return false; |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
74 |
$tid =& $params[1]; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
75 |
if ( !preg_match('/^[0-9]+$/', $tid) ) |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
76 |
{ |
10
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
77 |
return json_die('Invalid track ID'); |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
78 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
79 |
$tid = intval($tid); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
80 |
dcop_action('playlist', "playByIndex $tid"); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
81 |
$return = array( |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
82 |
'current_track_length' => $playlist[$tid]['length_int'], |
18
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
83 |
'current_track_pos' => 0, |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
84 |
'current_track_title' => $playlist[$tid]['title'], |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
85 |
'current_track_album' => $playlist[$tid]['album'], |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
86 |
'current_track_artist' => $playlist[$tid]['artist'] |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
87 |
); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
88 |
echo $json->encode($return); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
89 |
break; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
90 |
case 'volume': |
3
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
91 |
if ( !$allowcontrol ) |
e7447a6044ec
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
Dan
parents:
2
diff
changeset
|
92 |
return false; |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
93 |
$volume =& $params[1]; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
94 |
if ( !preg_match('/^[0-9]+$/', $volume) ) |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
95 |
{ |
10
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
96 |
return json_die('Invalid track ID'); |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
97 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
98 |
$volume = intval($volume); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
99 |
dcop_action('player', "setVolume $volume"); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
100 |
$return = array( |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
101 |
'volume' => $volume |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
102 |
); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
103 |
echo $json->encode($return); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
104 |
break; |
10
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
105 |
case 'seek': |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
106 |
if ( !$allowcontrol ) |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
107 |
return false; |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
108 |
$pos =& $params[1]; |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
109 |
if ( !preg_match('/^[0-9]+$/', $pos) ) |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
110 |
{ |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
111 |
return json_die('Invalid track ID'); |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
112 |
} |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
113 |
$pos = intval($pos); |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
114 |
dcop_action('player', "seek $pos"); |
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
115 |
|
d3059e20b0fa
SECURITY: Fix ability to crash server in ajax.php; added playback position slider and ability to seek through current song
Dan
parents:
6
diff
changeset
|
116 |
break; |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
117 |
case 'refresh': |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
118 |
global $playlist_last_refresh, $playlist, $playlist_last_md5; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
119 |
if ( $playlist_last_refresh + 60 < time() ) |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
120 |
{ |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
121 |
rebuild_playlist(); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
122 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
123 |
$current_track = dcop_action('playlist', 'getActiveIndex'); |
21
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
124 |
$current_time = dcop_action('player', 'trackCurrentTime'); |
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
125 |
$is_playing = dcop_action('player', 'isPlaying'); |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
126 |
$return = array( |
21
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
127 |
'is_playing' => $is_playing, |
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
128 |
'is_paused' => $current_time > 0 && !$is_playing, |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
129 |
'current_track' => $current_track, |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
130 |
'volume' => dcop_action('player', 'getVolume'), |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
131 |
// include the MD5 of the playlist so that if it changes, the |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
132 |
// client can refresh (otherwise things get madly corrupted) |
18
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
133 |
'playlist_hash' => $playlist_last_md5, |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
134 |
'current_track_title' => false, |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
135 |
'current_track_album' => false, |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
136 |
'current_track_artist' => false |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
137 |
); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
138 |
if ( isset($playlist[$current_track]) ) |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
139 |
{ |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
140 |
$return['current_track_length'] = $playlist[$current_track]['length_int']; |
21
74edc873234f
Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
Dan
parents:
18
diff
changeset
|
141 |
$return['current_track_pos'] = $current_time; |
18
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
142 |
$return['current_track_title'] = $playlist[$current_track]['title']; |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
143 |
$return['current_track_artist'] = $playlist[$current_track]['artist']; |
69af47034212
Added page-titling functionality that changes document.title to match the current track; made position slider reset to zero on stop or playlist end
Dan
parents:
10
diff
changeset
|
144 |
$return['current_track_album'] = $playlist[$current_track]['album']; |
2
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
145 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
146 |
echo $json->encode($return); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
147 |
break; |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
148 |
default: |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
149 |
return json_die("Undefined action: $action"); |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
150 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
151 |
} |
860ba7141641
Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
0
diff
changeset
|
152 |