Added dragging to the duration while in private-mode

This commit is contained in:
Kasper Rynning-Tønnesen
2017-04-28 16:36:50 +02:00
parent 7e2d16ed20
commit f1f0659899
4 changed files with 23 additions and 7 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

@@ -14,6 +14,7 @@ var adminpass = "";
var filesadded = "";
var player_ready = false;
var viewers = 1;
var dragging = false;
var paused = false;
var playing = false;
var SAMPLE_RATE = 6000; // 6 seconds
@@ -609,11 +610,18 @@ function change_offline(enabled, already_offline){
});
$("#controls").on("mouseleave", function(e){
dragging = false;
if(!$("#seekToDuration").hasClass("hide")){
$("#seekToDuration").addClass("hide");
}
});
$("#controls").on("mousedown", function(e) {
dragging = true;
});
$("#controls").on("mouseup", function(e) {
dragging = false;
});
$("#controls").on("mousemove", seekToMove);
$("#controls").on("click", seekToClick);
$("body").append("<div id='seekToDuration' class='hide'>00:00/01:00</div>");
@@ -661,6 +669,8 @@ function change_offline(enabled, already_offline){
});
$("#controls").off("mouseleave");
$("#controls").off("mouseenter");
$("#controls").off("mousedown");
$("#controls").off("mouseup");
$("#controls").off("mousemove", seekToMove);
$("#controls").off("click", seekToClick);
$("#seekToDuration").remove();
@@ -695,6 +705,7 @@ window.enable_debug = enable_debug;
window.disable_debug = disable_debug;
function seekToMove(e){
var pos_x = e.clientX - Math.ceil($("#seekToDuration").width() / 2) - 8;
if(pos_x < 0) pos_x = 0;
else if(pos_x + $("#seekToDuration").width() > $("#controls").width()) {
@@ -709,6 +720,10 @@ function seekToMove(e){
var _minutes = Helper.pad(_time[0]);
var _seconds = Helper.pad(Math.ceil(_time[1]));
$("#seekToDuration").text(_minutes + ":" + _seconds);
if(dragging) {
$("#bar").width(((100 / Player.player.getDuration()) * total) + "%");
}
} catch(e){}
}

View File

@@ -493,7 +493,8 @@ var Player = {
per = 100;
else if(duration === 0)
per = 0;
$("#bar").width(per+"%");
if(!dragging) $("#bar").width(per+"%");
}catch(e){
}