forked from ampache/ampache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnow_playing.php
81 lines (76 loc) · 2.94 KB
/
now_playing.php
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
78
79
80
81
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2020 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
define('NO_SESSION', '1');
require_once 'lib/init.php';
/* Check Perms */
if (!AmpConfig::get('use_now_playing_embedded') || AmpConfig::get('demo_mode')) {
UI::access_denied();
exit;
} ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $htmllang; ?>" lang="<?php echo $htmllang; ?>" dir="<?php echo is_rtl(AmpConfig::get('lang')) ? 'rtl' : 'ltr';?>">
<head>
<!-- Propelled by Ampache | ampache.org -->
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=<?php echo AmpConfig::get('site_charset'); ?>" />
<title><?php echo AmpConfig::get('site_title') . ' - ' . T_("Now Playing"); ?></title>
<?php
if (AmpConfig::get('now_playing_css_file')) { ?>
<link rel="stylesheet" href="<?php echo $web_path;
echo AmpConfig::get('now_playing_css_file'); ?>" type="text/css" media="screen" />
<?php
}
if (AmpConfig::get('now_playing_refresh_limit') > 1) {
$refresh_limit = AmpConfig::get('now_playing_refresh_limit'); ?>
<script>
reload = window.setInterval(function(){ window.location.reload(); }, <?php echo $refresh_limit ?> * 1000);
</script>
<?php
} ?>
</head>
<body>
<?php
Stream::garbage_collection();
$results = Stream::get_now_playing();
if (Core::get_request('user_id') !== '') {
if (empty($results)) {
debug_event('now_playing', 'no result; getting last song played instead', 5);
$last_song = Stats::get_last_song(Core::get_request('user_id'));
$type = $last_song['object_type'];
$media = new $type($last_song['object_id']);
$media->format();
$client = new User($last_song['user']);
$client->format();
$results[] = array(
'media' => $media,
'client' => $client,
'agent' => $last_song['agent'],
'expire' => ''
);
}
// If the URL specifies a specific user, filter the results on that user
$results = array_filter($results, function ($item) {
return ($item['client']->id === Core::get_request('user_id'));
});
}
require AmpConfig::get('prefix') . UI::find_template('show_now_playing.inc.php'); ?>
</body>
</html>