Fixed start and end not being sent on add

This commit is contained in:
Kasper Rynning-Tønnesen
2017-11-10 11:49:18 +01:00
parent 47e4cecdef
commit 28e822fbb1
2 changed files with 20 additions and 2 deletions

View File

@@ -91,7 +91,7 @@ function add_function(arr, coll, guid, offline, socket) {
Frontpage.update_frontpage(coll, id, title);
if(!full_list) Search.get_correct_info(new_song, coll, false);
} else {
var new_song = {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration};
var new_song = {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration, "start": start, "end": end};
io.to(coll).emit("channel", {type: "added", value: new_song});
if(!full_list) Search.get_correct_info(new_song, coll, true);
}

View File

@@ -339,6 +339,7 @@ var Player = {
playNext: function(){
var next_song = full_playlist[0];
video_id = next_song.id;
time = (new Date()).getTime();
song_title = next_song.title;
@@ -349,6 +350,14 @@ var Player = {
else start = 0;
if(next_song.hasOwnProperty("end")) end = next_song.end;
else end = duration;
Player.np = {
id: video_id,
start: start,
end: end,
duration: duration,
};
Player.getTitle(song_title, viewers);
Player.setBGimage(video_id);
if(chromecastAvailable){
@@ -377,6 +386,14 @@ var Player = {
else start = 0;
if(next_song.hasOwnProperty("end")) end = next_song.end;
else end = duration;
Player.np = {
id: video_id,
start: start,
end: end,
duration: duration,
};
Player.getTitle(song_title, viewers);
Player.setBGimage(video_id);
@@ -591,10 +608,11 @@ var Player = {
if(!Player.stopInterval) {
durationBegun = true;
}
dMinutes = Math.floor(duration / 60);
dSeconds = duration - dMinutes * 60;
currDurr = Player.player.getCurrentTime() !== undefined ? Math.floor(Player.player.getCurrentTime()) : seekTo;
if(currDurr - Player.np.start > duration) {
if(currDurr - Player.np.start > duration && !offline) {
currDurr = duration - Player.np.start;
}
currDurr = currDurr - Player.np.start;