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

Commit 56fda368 authored by Jonas Haraldsson's avatar Jonas Haraldsson

Merge branch 'player-2.0'

parents af4990a1 8eaf8a0a
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
var audio; var audio;
var scrobbled, now_playing, tracktoptags; var scrobbled, now_playing, tracktoptags;
var artist, album, track, trackpage, session_key, radio_key, ws_key, station; var artist, album, track, trackpage, radio_key, ws_key, station;
var playlist = [], current_song = 0; var playlist = [], current_song = 0;
var player_ready = false; var player_ready = false;
var playable_songs = false; var playable_songs = false;
...@@ -40,14 +40,14 @@ var base_url = base_url || ""; ...@@ -40,14 +40,14 @@ var base_url = base_url || "";
* @param string sk Scrobble session key or false if the user isn't logged in * @param string sk Scrobble session key or false if the user isn't logged in
* @param string rk Radio session key or false if streaming isn't required * @param string rk Radio session key or false if streaming isn't required
*/ */
function playerInit(list, sk, ws, rk, stationurl) { function playerInit(list, ws, rk, stationurl) {
audio = document.getElementById("audio"); audio = document.getElementById("audio");
if (!list) { if (!list) {
// We're playing a stream instead of a playlist // We're playing a stream instead of a playlist
streaming = true; streaming = true;
} }
session_key = sk; api_key = 'hellothisisthegnufmwebsiteplayer';
ws_key = ws; ws_key = ws;
radio_key = ws_key || rk; radio_key = ws_key || rk;
station = stationurl || false; station = stationurl || false;
...@@ -335,21 +335,21 @@ function togglePlaylist() { ...@@ -335,21 +335,21 @@ function togglePlaylist() {
function scrobble() { function scrobble() {
var timestamp; var timestamp;
scrobbled = true; scrobbled = true;
if(!session_key) { if(!ws_key) {
//Not authenticated //Not authenticated
return; return;
} }
timestamp = Math.round(new Date().getTime() / 1000); timestamp = Math.round(new Date().getTime() / 1000);
$.post(base_url + "/scrobble-proxy.php?method=scrobble", { "a[0]" : artist, "b[0]" : album, "t[0]" : track, "i[0]" : timestamp, "s" : session_key }, $.post(base_url + '/2.0/', { 'method':'track.scrobble', 'artist':artist, 'album':album, 'track':track, 'duration':audio.duration, 'timestamp':timestamp, 'sk':ws_key, 'api_key':api_key, 'format':'json'},
function(data){ function(data){
if(data.substring(0, 2) == "OK") { if('scrobbles' in data) {
$("#scrobbled").text("Scrobbled"); $("#scrobbled").text("Scrobbled");
$("#scrobbled").fadeIn(5000, function() { $("#scrobbled").fadeOut(5000) } ); $("#scrobbled").fadeIn(5000, function() { $("#scrobbled").fadeOut(5000) } );
} else { } else {
$("#scrobbled").text(data); $("#scrobbled").text(data);
$("#scrobbled").fadeIn(1000); $("#scrobbled").fadeIn(1000);
} }
}, "text"); }, 'json');
} }
/** /**
...@@ -359,12 +359,12 @@ function scrobble() { ...@@ -359,12 +359,12 @@ function scrobble() {
function nowPlaying() { function nowPlaying() {
var timestamp; var timestamp;
now_playing = true; now_playing = true;
if(!session_key) { if(!ws_key) {
//Not authenticated //Not authenticated
return; return;
} }
timestamp = Math.round(new Date().getTime() / 1000); timestamp = Math.round(new Date().getTime() / 1000);
$.post(base_url + "/scrobble-proxy.php?method=nowplaying", { "a" : artist, "b" : album, "t" : track, "l" : audio.duration, "s" : session_key}, function(data) {}, "text"); $.post(base_url + '/2.0/', { 'method':'track.updatenowplaying', 'artist':artist, 'album':album, 'track':track, 'duration':audio.duration, 'sk':ws_key, 'api_key':api_key}, function(data) {}, "text");
} }
/** /**
......
...@@ -74,9 +74,9 @@ ...@@ -74,9 +74,9 @@
var station = "{$station}"; var station = "{$station}";
{/if} {/if}
{if isset($this_user)} {if isset($this_user)}
playerInit(playlist, "{$this_user->getScrobbleSession()}", "{$this_user->getWebServiceSession()}", false, station); playerInit(playlist, "{$this_user->getWebServiceSession()}", false, station);
{else} {else}
playerInit(playlist, false, false, radio_session, false); playerInit(playlist, false, radio_session, false);
{/if} {/if}
{rdelim}); {rdelim});
</script> </script>
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