We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 02d8bd4a authored by elleo's avatar elleo

Add now playing support to the javascript player

parent 8351150a
......@@ -42,4 +42,4 @@ if (!PEAR::isError ($aNowPlaying)) {
$smarty->assign('welcome', true);
$smarty->display('welcome.tpl');
?>
\ No newline at end of file
?>
var scrobbled;
var scrobbled, now_playing;
var artist, album, track, session_key;
var playlist, current_song = 0;
var playable_songs = false;
......@@ -25,12 +25,16 @@ function playerInit(list, sk) {
$("#play").fadeTo("normal", 1);
$("#progressbar").progressbar({ value: 0 });
scrobbled = false;
now_playing = false;
$("#player > #interface").show();
}
function play() {
var audio = document.getElementById("audio");
audio.play();
if(!now_playing) {
nowPlaying();
}
$("#play").fadeTo("normal", 0.5);
$("#pause").fadeTo("normal", 1);
$("#seekforward").fadeTo("normal", 1);
......@@ -107,7 +111,7 @@ function scrobble() {
//Not authenticated
return;
}
timestamp = Math.round(new Date().getTime() / 1000)
timestamp = Math.round(new Date().getTime() / 1000);
$.post("/scrobble-proxy.php?method=scrobble", { "a[0]" : artist, "b[0]" : album, "t[0]" : track, "i[0]" : timestamp, "s" : session_key },
function(data){
if(data.substring(0, 2) == "OK") {
......@@ -119,6 +123,18 @@ function scrobble() {
}, "text");
}
function nowPlaying() {
var timestamp;
var audio = document.getElementById("audio");
now_playing = true;
if(!session_key) {
//Not authenticated
return;
}
timestamp = Math.round(new Date().getTime() / 1000);
$.post("/scrobble-proxy.php?method=nowplaying", { "a" : artist, "b" : album, "t" : track, "l" : audio.duration, "s" : session_key}, function(data) {}, "text");
}
function playSong(song) {
var audio = document.getElementById("audio");
loadSong(song);
......@@ -133,6 +149,7 @@ function loadSong(song) {
track = playlist[song]["track"];
current_song = song;
scrobbled = false;
now_playing = false;
audio.src = url;
audio.load();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment