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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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,6 +876,9 @@ 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;
if(!chromecastAvailable){
Player.player.seekTo(total); Player.player.seekTo(total);
dMinutes = Math.floor(duration / 60); dMinutes = Math.floor(duration / 60);
@@ -891,6 +895,9 @@ function seekToClick(e){
else if(duration === 0) else if(duration === 0)
per = 0; per = 0;
$("#bar").width(per+"%"); $("#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);
} }
}) })