Fixed issue with next song not being sent to embedder

This commit is contained in:
Kasper Rynning-Tønnesen
2017-06-09 01:20:52 +02:00
parent 0458d93d96
commit e106d3defd
4 changed files with 11 additions and 22 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-14
View File
@@ -21,21 +21,15 @@ var List = {
if((!offline || (offline && !msg.shuffled)) && !(offline && prev_chan_list == chan)){ if((!offline || (offline && !msg.shuffled)) && !(offline && prev_chan_list == chan)){
prev_chan_list = chan; prev_chan_list = chan;
List.populate_list(msg.playlist); List.populate_list(msg.playlist);
if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
} else if(offline && prev_chan_list == chan && full_playlist != undefined && !msg.shuffled){ } else if(offline && prev_chan_list == chan && full_playlist != undefined && !msg.shuffled){
List.populate_list(full_playlist, true); List.populate_list(full_playlist, true);
if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
}
break; break;
case "added": case "added":
List.added_song(msg.value); List.added_song(msg.value);
if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
break; break;
case "deleted": case "deleted":
List.deleted_song(msg.value, msg.removed); List.deleted_song(msg.value, msg.removed);
@@ -43,16 +37,12 @@ var List = {
case "vote": case "vote":
if(!offline){ if(!offline){
List.voted_song(msg.value, msg.time); List.voted_song(msg.value, msg.time);
if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
}
break; break;
case "song_change": case "song_change":
if(window.location.pathname != "/") List.song_change(msg.time, msg.remove); if(window.location.pathname != "/") List.song_change(msg.time, msg.remove);
if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
break; break;
} }
}, },
@@ -365,9 +355,7 @@ var List = {
//if(removed) { //if(removed) {
$("#"+deleted).remove(); $("#"+deleted).remove();
full_playlist.splice(List.getIndexOfSong(deleted), 1); full_playlist.splice(List.getIndexOfSong(deleted), 1);
if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
//} //}
} catch(err) { } catch(err) {
@@ -379,11 +367,9 @@ var List = {
} else if($("#wrapper").children().length > List.page + List.can_fit){ } else if($("#wrapper").children().length > List.page + List.can_fit){
$($("#wrapper").children()[List.page + (List.can_fit - 1)]).css("display", "inline-block"); $($("#wrapper").children()[List.page + (List.can_fit - 1)]).css("display", "inline-block");
} }
if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
} }
}
if(full_playlist.length <= 2){ if(full_playlist.length <= 2){
List.empty = true; List.empty = true;
+3
View File
@@ -80,6 +80,9 @@ var Player = {
if(embed) { if(embed) {
if(window.parentWindow && window.parentOrigin) { if(window.parentWindow && window.parentOrigin) {
window.parentWindow.postMessage({type: "np", title: obj.np[0].title}, window.parentOrigin); window.parentWindow.postMessage({type: "np", title: obj.np[0].title}, window.parentOrigin);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
} }
} }