We are unlikely to be sending XHTML, or want to be.
[adorno.git] / inc / PlayTracks.php
blob1e3c568fd660640f7331977f0dd3d94d77169c46
1 <?php
3 function PlayTrack( $path, $hash ) {
4 $fifo = fopen( "/var/run/adorno/fifo", "w" );
5 fputs( $fifo, "queue $path\n" );
6 fclose($fifo);
7 error_log( sprintf("DBG: PlayTrack: Queueing '%s' for playing", $path) );
9 $qry = new PgQuery( "SELECT track_played(?) ", $hash );
10 $qry->Exec("PlayTrack");
13 if ( isset($l) && isset($a) && isset($t) ) {
14 $qry = new PgQuery( "SELECT path_name, hash_key FROM tracks WHERE album = ? AND artist = ? AND title = ? ", $l, $a, $t );
15 if ( $qry->Exec("PlayTracks") && $qry->rows == 1 ) {
16 $track = $qry->Fetch();
17 PlayTrack( $track->path_name, $track->hash_key );
20 else if ( ( isset($a) || (isset($play) && $play > 0) ) && isset($l) ) {
21 // Play all of the tracks for this alum
22 if ( isset($a) )
23 $qry = new PgQuery( "SELECT path_name, hash_key FROM tracks WHERE album = ? AND artist = ? ORDER BY setpart, tracknum;", $l, $a );
24 else
25 $qry = new PgQuery( "SELECT path_name, hash_key FROM tracks WHERE album = ? ORDER BY setpart, tracknum;", $l );
26 if ( $qry->Exec("PlayTracks") && $qry->rows > 0 ) {
27 while( $track = $qry->Fetch() ) {
28 PlayTrack( $track->path_name, $track->hash_key );