1
0
mirror of https://github.com/shimunn/aria2xspf.git synced 2023-11-17 09:27:54 +01:00
aria2xspf/js/resume.js
2019-04-26 16:26:46 +02:00

36 lines
1.2 KiB
JavaScript

(function($, window) {
window.jumpVid = function (id, time) {
$("video").each(function(e) {
if(btoa(this.currentSrc) == id) {
this.currentTime = time;
this.play();
}
});
};
$(window).on('load', function() {
$("video").each(function(e) {
var src = this.currentSrc;
var id = btoa(src);
console.log(src);
var start = window.localStorage[id];
if (start) {
if(!$(this).prev().find(".resume").length){
$(this).prev().append(' <div class="resume"></div>');
}
$(this).prev().find(".resume").html('Resume <a href="javascript:jumpVid(\''+id+'\',' + start + ');">@'+Math.round(start / 60) +'min');
this.currentTime = parseFloat(start);
}
});
});
setInterval(function() {
$("video").each(function(e) {
var src = this.currentSrc;
var time = this.currentTime;
if (time) {
window.localStorage[btoa(src)] = time;
console.log("Persisted video progress at: " + time);
}
});
}, 5000);
}($, window));