3 switch ( $c->daemon_type
) {
4 case 'mpd': include("mpdPlayer.php"); break;
5 case 'vlc': include("vlcPlayer.php"); break;
6 case 'xmms2': include("xmms2Player.php"); break;
7 default: include("adornoPlayer.php");
11 * High level function to play a track
13 function PlayTrack( $path, $hash ) {
14 if ( isset($_GET['act']) && $_GET['act'] == 'no' && ( !isset($_POST['act']) ||
$_POST['act'] == 'no') ) {
15 error_log( sprintf("DBG: PlayTrack: *NOT* Queueing '%s' for playing", $path) );
19 error_log( sprintf("DBG: PlayTrack: Queueing '%s' for playing", $path) );
21 if ( daemon_play_track($path) ) {
22 $qry = new PgQuery( "SELECT track_played(?) ", $hash );
23 $qry->Exec("PlayTrack");
29 * High level function to get the current track as a database object
31 function current_track() {
33 $current_track = daemon_current_track();
35 $query = "SELECT *, extract( EPOCH FROM duration)::int AS secs ";
36 if ( ereg( '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}', $current_track->started
) ) {
37 $query .= ", extract( EPOCH FROM ('".$current_track->started
."'::timestamp + duration))::int AS finishing ";
39 $query .= "FROM tracks WHERE path_name = ? ; ";
41 $qry = new PgQuery( $query, $current_track->track
);
42 if ( $qry->Exec('current_track') && $qry->rows
> 0 ) {
43 $track = $qry->Fetch();
51 * High level function to crudely display the current track
53 function show_queue() {
55 $queue = daemon_get_queue();
57 echo "<h3>Coming up...</h3>\n<p class=\"track_queue\">";
58 foreach( $queue AS $k => $v ) {
59 echo nice_track_name($v) . "<br>\n";
66 * High level function to return an array of $track objects
68 function current_queue() {
70 $queue = daemon_get_queue();
75 foreach( $queue AS $k => $track ) {
76 $in_list .= ($position == 0 ?
"" : ", ") . qpg($track);
77 $queue_pos[$track] = $position++
;
81 if ( $in_list == "" ) return $queue;
84 * Select the track information from the database
86 $sql = sprintf("SELECT *, EXTRACT( 'epoch' FROM duration ) AS dur_secs FROM tracks WHERE path_name IN ( %s );", $in_list );
87 $qry = new PgQuery( $sql );
88 if ( $qry->Exec("current_queue",__LINE__
,__FILE__
) && $qry->rows
) {
89 while( $track = $qry->Fetch() ) {
90 $position = $queue_pos[$track->path_name
];
91 $queue[$position] = $track;