Working seekto on chromecast also

This commit is contained in:
Kasper Rynning-Tønnesen
2017-03-03 08:26:14 +01:00
parent 95c7ca62ff
commit 1fbbc31ff0
3 changed files with 31 additions and 23 deletions
+2 -2
View File
File diff suppressed because one or more lines are too long
+4 -4
View File
File diff suppressed because one or more lines are too long
+25 -17
View File
@@ -854,14 +854,15 @@ window.enable_debug = enable_debug;
window.disable_debug = disable_debug; window.disable_debug = disable_debug;
function seekToMove(e){ function seekToMove(e){
var pos_x = e.clientX - $("#seekToDuration").width() / 2; var pos_x = e.clientX - Math.ceil($("#seekToDuration").width() / 2) - 8;
if(pos_x < 0) pos_x = 0; if(pos_x < 0) pos_x = 0;
else if(pos_x + $("#seekToDuration").width() > $("#controls").width()) { else if(pos_x + $("#seekToDuration").width() > $("#controls").width()) {
pos_x = $("#controls").width() - $("#seekToDuration").width(); pos_x = $("#controls").width() - $("#seekToDuration").width();
} }
$("#seekToDuration").css("left", pos_x); $("#seekToDuration").css("left", pos_x);
try{ try{
var total = Player.player.getDuration() / $("#controls").width(); //var total = Player.player.getDuration() / $("#controls").width();
var total = full_playlist[full_playlist.length - 1].duration / $("#controls").width();
total = total * e.clientX; total = total * e.clientX;
var _time = Helper.secondsToOther(total); var _time = Helper.secondsToOther(total);
var _minutes = Helper.pad(_time[0]); var _minutes = Helper.pad(_time[0]);
@@ -875,22 +876,28 @@ function seekToClick(e){
if(acceptable.indexOf($(e.target).attr("id")) >= 0) { if(acceptable.indexOf($(e.target).attr("id")) >= 0) {
var total = Player.player.getDuration() / $("#controls").width(); var total = Player.player.getDuration() / $("#controls").width();
total = total * e.clientX; total = total * e.clientX;
Player.player.seekTo(total);
dMinutes = Math.floor(duration / 60);
dSeconds = duration - dMinutes * 60; if(!chromecastAvailable){
currDurr = total; Player.player.seekTo(total);
if(currDurr > duration)
currDurr = duration; dMinutes = Math.floor(duration / 60);
minutes = Math.floor(currDurr / 60); dSeconds = duration - dMinutes * 60;
seconds = currDurr - (minutes * 60); currDurr = total;
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds); if(currDurr > duration)
per = (100 / duration) * currDurr; currDurr = duration;
if(per >= 100) minutes = Math.floor(currDurr / 60);
per = 100; seconds = currDurr - (minutes * 60);
else if(duration === 0) document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
per = 0; per = (100 / duration) * currDurr;
$("#bar").width(per+"%"); if(per >= 100)
per = 100;
else if(duration === 0)
per = 0;
$("#bar").width(per+"%");
} else {
castSession.sendMessage("urn:x-cast:zoff.me", {type: "seekTo", seekTo: total});
}
} }
} }
@@ -1477,6 +1484,7 @@ $(window).resize(function(){
$(".list-song").css("height", List.element_height + "px"); $(".list-song").css("height", List.element_height + "px");
$("#player_overlay").width($("#player").width()+1); $("#player_overlay").width($("#player").width()+1);
set_title_width(); set_title_width();
$("#seekToDuration").css("top", $("#controls").position().top + 10);
} }
}) })