Fixed local-mode issues

This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-02 13:04:56 +01:00
parent 5e9e682932
commit b9bc22d1d2
4 changed files with 27 additions and 17 deletions

View File

@@ -504,9 +504,9 @@ function sendColor(coll, socket, id) {
var c = ColorThief.getColor(image); var c = ColorThief.getColor(image);
if(socket) { if(socket) {
socket.emit("color", {color: c}); socket.emit("color", {color: c, only: true});
} else { } else {
io.to(coll).emit("color", {color: c}); io.to(coll).emit("color", {color: c, only: false});
} }
}); });
} }

View File

@@ -54,23 +54,28 @@ var List = {
found_array_index = 0; found_array_index = 0;
break; break;
case "song_change": case "song_change":
if((offline && msg.offline_change) || !offline) {
if(window.location.pathname != "/") List.song_change(msg.time, msg.remove); if(window.location.pathname != "/") List.song_change(msg.time, msg.remove);
if(full_playlist.length > 0) { if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
found_array = []; found_array = [];
found_array_index = 0; found_array_index = 0;
}
break; break;
case "changed_values": case "changed_values":
List.changedValues(msg.value); List.changedValues(msg.value);
break; break;
case "song_change_prev": case "song_change_prev":
if((offline && msg.offline_change) || !offline) {
if(window.location.pathname != "/") List.song_change_prev(msg.time); if(window.location.pathname != "/") List.song_change_prev(msg.time);
if(full_playlist.length > 0) { if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
found_array = []; found_array = [];
found_array_index = 0; found_array_index = 0;
}
break; break;
} }
}, },

View File

@@ -227,6 +227,11 @@ $().ready(function(){
}); });
initializeCastApi = function() { initializeCastApi = function() {
try {
if(cast == undefined) return;
} catch(e) {
return;
}
cast.framework.CastContext.getInstance().setOptions({ cast.framework.CastContext.getInstance().setOptions({
receiverApplicationId: "E6856E24", receiverApplicationId: "E6856E24",
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
@@ -1159,7 +1164,7 @@ $(document).on( "click", "#add-many", function(e){
} else { } else {
try { try {
var length = parseInt(end) - parseInt(start); var length = parseInt(end) - parseInt(start);
$(this).parent().parent().remove(); $(this).parent().parent().parent().remove();
Search.submit(id, title, length, false, 0, 1, start, end); Search.submit(id, title, length, false, 0, 1, start, end);
} catch(e) { } catch(e) {
Materialize.toast("Only numbers are accepted as song start and end parameters..", 3000, "red lighten"); Materialize.toast("Only numbers are accepted as song start and end parameters..", 3000, "red lighten");

View File

@@ -406,7 +406,7 @@ var Player = {
} else { } else {
Player.loadVideoById(video_id, duration, start, end); Player.loadVideoById(video_id, duration, start, end);
} }
List.channel_function({type:"song_change", time: time}); List.channel_function({type:"song_change", time: time, offline_change: true});
}, },
playPrev: function() { playPrev: function() {
@@ -444,7 +444,7 @@ var Player = {
Player.loadVideoById(video_id, duration, start, end); Player.loadVideoById(video_id, duration, start, end);
} }
List.channel_function({type:"song_change_prev", time: time}); List.channel_function({type:"song_change_prev", time: time, offline_change: true});
}, },
sendNext: function(obj){ sendNext: function(obj){
@@ -554,7 +554,7 @@ var Player = {
setBGimage: function(c){ setBGimage: function(c){
var color = c.color; var color = c.color;
if(window.location.pathname != "/") { if(window.location.pathname != "/" && ((offline && c.only) || (!offline && !c.only))) {
document.getElementById("main-container").style.backgroundColor = Helper.rgbToHsl(color,true); document.getElementById("main-container").style.backgroundColor = Helper.rgbToHsl(color,true);
$("meta[name=theme-color]").attr("content", Helper.rgbToHex(color[0], color[1], color[2])); $("meta[name=theme-color]").attr("content", Helper.rgbToHex(color[0], color[1], color[2]));
var new_color = Helper.rgbToHex(color[0], color[1], color[2]); var new_color = Helper.rgbToHex(color[0], color[1], color[2]);
@@ -677,9 +677,9 @@ var Player = {
if(Player.player.getCurrentTime() > Player.np.end && Player.player.getPlayerState() == YT.PlayerState.PLAYING) { if(Player.player.getCurrentTime() > Player.np.end && Player.player.getPlayerState() == YT.PlayerState.PLAYING) {
end_programmatically = true; end_programmatically = true;
Player.player.pauseVideo();
if(!offline) { if(!offline) {
Player.player.pauseVideo();
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)}); socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
} else { } else {
Player.playNext(); Player.playNext();