summaryrefslogtreecommitdiffstats
path: root/templates/show_now_playing.inc
blob: 22422388facdef2318643cc083bdd75da267a58c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*

 Copyright (c) 2001 - 2005 Ampache.org
 All rights reserved.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/
/*!
 @header Show Now Playing

*/

?>
<?php if (count($results)) { ?>
<table class="border" cellspacing="1" cellpadding="3" border="0" width="100%">
  <tr class="table-header">
    <td colspan="4"><?php echo _("Now Playing"); ?></td>
  </tr>
<?php
	$user = $GLOBALS['user'];
        echo '<script language="JavaScript" type="text/javascript"> var mpd_state = "'. "stop" .'" </script>';
	foreach($results as $item) { 
		$song = $item['song'];
		$np_user = $item['user'];
		if (is_object($song)) {
                   $artist = $song->f_artist;
                   $album  = $song->get_album_name();
                   $text = "$song->f_title";
		   if (!$np_user->fullname) { $np_user->fullname = "Unknown User"; }
		   if ($user->username == $np_user->username)
		       {
                       $sql = "SELECT start_time FROM now_playing WHERE user ='".$user->username."'";
                       $db_results = mysql_query($sql, dbh());
                       while ($r = mysql_fetch_assoc($db_results)) {
                          echo '<script language="JavaScript" type="text/javascript"> var mpd_elapsed = '.(time() - $r['start_time']).' </script>';
                          echo '<script language="JavaScript" type="text/javascript"> var mpd_song_length = '. $song->time .' </script>';
                          echo '<script language="JavaScript" type="text/javascript"> var mpd_state = "'. "play" .'" </script>';
                          } // end while
                       echo "<tr class=\"even\">\n"; }
		   else
                       { echo "<tr class=\"even\">\n"; }
                   if (conf('use_auth')) { 
		       echo "\t<td valign=\"middle\">$np_user->fullname</td>\n"; 
		       }
                   echo "\t<td><a title=\"" . htmlspecialchars($song->title) . "\" href=\"$web_path/song.php?action=m3u&amp;song=$song->id\">$text</a></td>\n";
		   echo "\t<td><a title=\"" . htmlspecialchars($song->f_artist) . "\" href=\"$web_path/artists.php?action=show&amp;artist=$song->artist\">$song->f_artist</a> / ";
                   echo "\t<a title=\"" . htmlspecialchars($album) . "\" href=\"$web_path/albums.php?action=show&amp;album=$song->album\">$song->f_album</a></td>";
                   if (conf('play_album_art')) {
                       echo "\t<td align=\"center\">";
                       echo "<a target=\"_blank\" href=\"" . conf('web_path') . "/albumart.php?id=" . $song->album . "&amp;type=popup\">";
                       echo "<img align=\"middle\" border=\"0\" src=\"" . conf('web_path') . "/albumart.php?id=" . $song->album . "&amp;fast=1&amp;thumb=1\" alt=\"Album Art\" height=\"75\" />";
                       echo "</a>\n";
                       echo "\t</td>\n";
                       echo "</tr>\n";
                       } // if album art on now playing
		   else {
		       echo "\n</tr>";
			}
                } // if it's a song
        } // while we're getting songs
?>
</table>
<?php } ?>