From b3da558336c12efc2c610b7e432df2cdd0703242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 24 Jul 2018 23:40:35 +0200 Subject: [PATCH] bugfixes - Fixed color-issue on local - Fixed issue with navigating back in playlist on local - Fixed issue with starting at the right time on local when start/end had been set - Fixed issue where changing channel when in local, song wouldn't change - Fixed issue on previous song not starting at the correct time in local mode --- server/public/assets/js/frontpage.js | 5 +++-- server/public/assets/js/functions.js | 2 +- server/public/assets/js/list.js | 2 ++ server/public/assets/js/listeners.js | 3 ++- server/public/assets/js/player.js | 17 +++++++++++------ 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/server/public/assets/js/frontpage.js b/server/public/assets/js/frontpage.js index 40f25796..2a5a736f 100755 --- a/server/public/assets/js/frontpage.js +++ b/server/public/assets/js/frontpage.js @@ -356,12 +356,12 @@ var Frontpage = { //socket.disconnect(); socket.removeAllListeners(); } - + var old_chan = chan; if(!popstate){ window.history.pushState("to the channel!", "Title", "/" + new_channel); if(prev_chan_list == "") prev_chan_list = new_channel; if(prev_chan_player == "") prev_chan_player = new_channel; - window.chan = new_channel; + chan = new_channel; } var response = document.createElement("div"); @@ -392,6 +392,7 @@ var Frontpage = { Helper.addClass(".page-footer", "padding-bottom-novideo"); from_frontpage = true; if(document.querySelectorAll("#alreadychannel").length == 1){ + if(old_chan != new_channel) local_new_channel = true; Channel.init(); }else{ fromFront = true; diff --git a/server/public/assets/js/functions.js b/server/public/assets/js/functions.js index a2c6bbe7..ca172c71 100644 --- a/server/public/assets/js/functions.js +++ b/server/public/assets/js/functions.js @@ -30,7 +30,7 @@ function getColor(id) { id: id }), success: function(c) { - //c = JSON.parse(c); + c = JSON.parse(c); if(typeof(c) == "object") { Player.setBGimage({color:c, only:true}); } diff --git a/server/public/assets/js/list.js b/server/public/assets/js/list.js index 78b4db09..1d96e7e0 100755 --- a/server/public/assets/js/list.js +++ b/server/public/assets/js/list.js @@ -513,6 +513,8 @@ var List = { full_playlist.unshift(full_playlist.pop()); full_playlist[full_playlist.length - 1].now_playing = true; + + if(full_playlist.length == 1) return; document.querySelector("#wrapper").children[document.querySelector("#wrapper").children.length - 1].remove(); var length = full_playlist.length - 2; diff --git a/server/public/assets/js/listeners.js b/server/public/assets/js/listeners.js index 70f3d15c..0a1dff98 100755 --- a/server/public/assets/js/listeners.js +++ b/server/public/assets/js/listeners.js @@ -5,6 +5,7 @@ var client = false; if(domain.length > 0 && domain[0] == "client") { client = true; } +var local_new_channel = false; var videoSource; var dynamicListeners = {}; var socket_connected = false; @@ -1310,7 +1311,7 @@ window.addEventListener("resize", function(){ var scPlaying = false; var ytPlaying = false; try { - ytPlaying = Player.player.getPlayerState() == YT.PlayerState.PLAYING || Player.player.getPlayerState() == YT.PlayerState.BUFFERING; + ytPlaying = Player.player.getPlayerState() == YT.PlayerState.PLAYING || Player.player.getPlayerState() == YT.PlayerState.BUFFERING; } catch(e) {} try { scPlaying = Player.soundcloud_player.isPlaying(); diff --git a/server/public/assets/js/player.js b/server/public/assets/js/player.js index e680cdb4..48e45e96 100755 --- a/server/public/assets/js/player.js +++ b/server/public/assets/js/player.js @@ -13,7 +13,7 @@ var Player = { }, now_playing_listener: function(obj) { - if(offline && video_id != undefined) { + if((offline && !local_new_channel) && video_id != undefined) { return; } if(obj.np != undefined) { @@ -26,7 +26,7 @@ var Player = { song_title = obj.np[0].title; duration = obj.np[0].duration; - if(offline && (video_id == "" || video_id == undefined) && !client){ + if(offline && (video_id == "" || video_id == undefined || local_new_channel) && !client){ if(obj.conf != undefined) { conf = obj.conf[0]; } @@ -85,6 +85,7 @@ var Player = { Player.cueVideoById(Player.np.id, duration, Player.np.start, Player.np.end); } } + local_new_channel = false; updateChromecastMetadata(); }, @@ -481,8 +482,8 @@ var Player = { }, playNext: function(){ - if(full_playlist.length == 0) return; - var next_song = full_playlist[0]; + if(full_playlist == undefined || full_playlist.length == 0) return; + var next_song = full_playlist[0]; video_id = next_song.id; time = (new Date()).getTime(); @@ -495,13 +496,15 @@ var Player = { else start = 0; if(next_song.hasOwnProperty("end")) end = next_song.end; else end = duration; - Player.np = next_song; Player.np.start = start; Player.np.end = end; + //seekTo = 0; Player.np.duration = duration; + Player.getTitle(song_title, viewers); + seekTo = start; //Player.setBGimage(video_id); if(chromecastAvailable){ loadChromecastVideo(); @@ -509,12 +512,14 @@ var Player = { chrome.cast.media.GenericMediaMetadata({metadataType: 0, title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg', images: ['https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg']}); chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'); } else { + Player.loadVideoById(video_id, duration, start, end); } List.channel_function({type:"song_change", time: time, offline_change: true}); }, playPrev: function() { + if(full_playlist == undefined) return; var length = full_playlist.length - 2; if(length < 0) { length = 0; @@ -536,7 +541,7 @@ var Player = { Player.np.start = start; Player.np.end = end; Player.np.duration = duration; - + seekTo = start; Player.getTitle(song_title, viewers); //Player.setBGimage(video_id);