-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate.php
41 lines (39 loc) · 1.05 KB
/
update.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
<?php require_once("config.php") ?>
<?php require_once("assets/includes/sonicflow.php"); ?>
<?php
/*
* This will check whether there is a new song yet.
* Returns true if there is a new song; otherwise, false.
* If this is being called from the now playing page, then it
* will return the new song id if there is a new song; otherwise, 0.
*/
$id_front = $_POST['id_front'];
$id_back = $_POST['id_back'];
$from = $_POST['from'];
if ($from == "queue") {
$song_front = getNext();
$song_back = getLast();
$song_front = $song_front[1];
$song_back = $song_back[1];
echo ($id_front != $song_front->id || $id_back != $song_back->id);
} else {
$song_front = getNext();
$song_front = $song_front[1];
if ($id_front != $song_front->id) {
$json = getSongJson($song_front);
echo $json;
} else {
echo 0;
}
}
function getSongJson($song) {
$arr = array(
'id' => $song->id,
'title' => $song->title,
'artist' => $song->artist,
'album' => $song->album,
'arturl' => $song->arturl
);
return json_encode($arr);
}
?>