Offline previous song

This commit is contained in:
Kasper Rynning-Tønnesen
2017-10-08 22:31:59 +02:00
parent 9fd9cd301b
commit 2339327a6e
7 changed files with 79 additions and 16 deletions

View File

@@ -128,14 +128,23 @@ var List = {
//if(!w_p) List.dragging(true);
break;
case "song_change":
if(window.location.pathname != "/") List.song_change(msg.time, msg.remove);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
found_array = [];
found_array_index = 0;
//if(!w_p) List.dragging(true);
break;
if(window.location.pathname != "/") List.song_change(msg.time, msg.remove);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
found_array = [];
found_array_index = 0;
//if(!w_p) List.dragging(true);
break;
case "song_change_prev":
if(window.location.pathname != "/") List.song_change_prev(msg.time);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
found_array = [];
found_array_index = 0;
//if(!w_p) List.dragging(true);
break;
}
},
@@ -204,6 +213,7 @@ var List = {
}
}
List.sortList();
$("#wrapper").empty();
Helper.log("---------------------------");
@@ -496,6 +506,25 @@ var List = {
List.insertAtIndex(song_voted_on, false);
},
song_change_prev: function(time) {
full_playlist[full_playlist.length - 1].now_playing = false;
full_playlist[full_playlist.length - 1].votes = full_playlist[0].votes;
full_playlist[full_playlist.length - 1].guids = [];
full_playlist[full_playlist.length - 1].added = full_playlist[0].added - 1;
full_playlist.unshift(full_playlist.pop());
full_playlist[full_playlist.length - 1].now_playing = true;
$("#wrapper").children()[$("#wrapper").children().length - 1].remove();
var length = full_playlist.length - 2;
if(length < 0) {
length = 0;
}
List.insertAtIndex(full_playlist[0], false, true);
},
song_change: function(time, remove) {
try{
var length = full_playlist.length - 1;
@@ -539,11 +568,15 @@ var List = {
return true;
},
skip: function() {
skip: function(way) {
if(!offline){
socket.emit('skip', {pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), id:video_id, channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
} else {
Player.playNext();
if(way) {
Player.playNext();
} else {
Player.playPrev();
}
}
return true;
},

View File

@@ -787,6 +787,9 @@ function change_offline(enabled, already_offline){
}
//$(".list-remove").removeClass("hide");
$("#viewers").addClass("hide");
$(".margin-playbar").removeClass("margin-playbar");
$(".prev.playbar").addClass("margin-playbar");
$(".prev.playbar").removeClass("hide");
$("#offline-mode").removeClass("waves-cyan");
$("#offline-mode").addClass("cyan");
if(!Helper.mobilecheck()) {
@@ -844,7 +847,10 @@ function change_offline(enabled, already_offline){
list_html = $("<div>" + list_html + "</div>");
list_html = list_html.html();
}
$(".margin-playbar").removeClass("margin-playbar");
$("#playpause").addClass("margin-playbar");
$("#viewers").removeClass("hide");
$(".prev.playbar").addClass("hide");
$("#offline-mode").addClass("waves-cyan");
$("#offline-mode").removeClass("cyan");
if(!Helper.mobilecheck()) {

View File

@@ -303,6 +303,30 @@ var Player = {
List.channel_function({type:"song_change", time: time});
},
playPrev: function() {
var length = full_playlist.length - 2;
if(length < 0) {
length = 0;
}
var next_song = full_playlist[length];
video_id = next_song.id;
time = (new Date()).getTime();
song_title = next_song.title;
duration = next_song.duration;
Player.getTitle(song_title, viewers);
Player.setBGimage(video_id);
if(chromecastAvailable){
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, channel: chan.toLowerCase()});
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: '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);
}
List.channel_function({type:"song_change_prev", time: time});
},
sendNext: function(obj){
if(chromecastAvailable){
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", title: obj.title, videoId: obj.videoId});