[go: nahoru, domu]

Skip to content

Commit

Permalink
Don't interrupt playing
Browse files Browse the repository at this point in the history
  • Loading branch information
porjo committed Jun 6, 2023
1 parent 568d386 commit 625af04
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions html/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ var player = null;

var loc = window.location, ws_uri;
if (loc.protocol === "https:") {
ws_uri = "wss:";
ws_uri = "wss:";
} else {
ws_uri = "ws:";
ws_uri = "ws:";
}
ws_uri += "//" + loc.host;
var path = loc.pathname.replace(/\/$/, '');
Expand Down Expand Up @@ -117,8 +117,10 @@ $(function(){
$("#filesize").text( (bytes / 1024 / 1024).toFixed(2) + " MB" );
break;
case 'link_stream':
$("#playa").show();
updatePlayer(encodeURI(msg.Value.DownloadURL), msg.Value.Title, msg.Value.Artist);
if(!isPlaying()) {
$("#playa").show();
updatePlayer(encodeURI(msg.Value.DownloadURL), msg.Value.Title, msg.Value.Artist);
}
break;
case 'recent':
if( msg.Value.length == 0 ) {
Expand Down Expand Up @@ -163,6 +165,13 @@ $(function(){
updatePlayer(url, title, artist, true);
}

function isPlaying() {
if(player && !player.audio.paused) {
return true;
}
return false
}

function updatePlayer(url, title, artist, autoplay=false) {
if( player === null ) {
player = new Shikwasa.Player({
Expand Down

0 comments on commit 625af04

Please sign in to comment.