сохранение времени последнего просмотра
This commit is contained in:
@@ -1,10 +1,33 @@
|
||||
<#include "/header.inc.html">
|
||||
<script type="text/javascript" src="${basedir}/js/js.cookie-2.1.0.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var video_data = ${json};
|
||||
var player;
|
||||
var videotime = 0;
|
||||
|
||||
function msToTime(ms) {
|
||||
function addZ(n) { return (n<10? '0':'') + n; }
|
||||
|
||||
var _ms = ms % 1000;
|
||||
ms = (ms - _ms) / 1000;
|
||||
var _sec = ms % 60;
|
||||
ms = (ms - _sec) / 60;
|
||||
var _min = ms % 60;
|
||||
var _hr = (ms - _min) / 60;
|
||||
|
||||
return {
|
||||
's': addZ(_sec),
|
||||
'm': addZ(_min),
|
||||
'h': addZ(_hr)
|
||||
};
|
||||
}
|
||||
|
||||
$(function(){
|
||||
player = $('#player');
|
||||
|
||||
// set video
|
||||
if (typeof(video_data.file) !== 'undefined') {
|
||||
$('#player').attr('src', '${basedir}'+video_data.file);
|
||||
player.attr('src', '${basedir}'+video_data.file);
|
||||
} else if (typeof(video_data.playlist) !== 'undefined') {
|
||||
$('#pl-season').removeClass('hide');
|
||||
menu = $('#pl-season-menu');
|
||||
@@ -28,15 +51,59 @@
|
||||
|
||||
smenu.find('a').bind('click', function(){
|
||||
$('#dropdownSerial').html(this.text + ' <span class="caret"></span>');
|
||||
$('#player').attr('src', '${basedir}'+this.attributes['data-file'].value);
|
||||
player.attr('src', '${basedir}'+this.attributes['data-file'].value);
|
||||
});
|
||||
|
||||
$('#pl-serial').removeClass('hide');
|
||||
});
|
||||
}
|
||||
|
||||
// save video time
|
||||
var path = window.location.pathname.substr("${basedir}".length);
|
||||
var data = Cookies.getJSON(path);
|
||||
if (data != null) {
|
||||
videotime = data.time;
|
||||
var fulltime = msToTime(videotime * 1000);
|
||||
$('#mdl-vtime').text(fulltime.h + ':' + fulltime.m + ':' + fulltime.s);
|
||||
$('#modal').modal('show');
|
||||
} else {
|
||||
player.load();
|
||||
}
|
||||
|
||||
var tl;
|
||||
player.bind('play', function(){
|
||||
tl = $.now();
|
||||
});
|
||||
player.bind('timeupdate', function(){
|
||||
var tc = $.now();
|
||||
var sec = Math.floor((tc-tl)/1000);
|
||||
if (sec >= 5) {
|
||||
Cookies.set(path, {time:player[0].currentTime});
|
||||
tl = tc;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function continueVideo() {
|
||||
player[0].currentTime = videotime;
|
||||
player[0].load();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="modal fade" tabindex="-1" role="dialog" id="modal">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<p class="text-center">Продолжить просмотр с <span id="mdl-vtime"></span>?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="continueVideo()">Да</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="player[0].load()">Нет</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="pl-season" class="dropdown hide" style="display: inline-block;">
|
||||
@@ -61,6 +128,6 @@
|
||||
|
||||
<br><br>
|
||||
|
||||
<video id="player" class="center-block" controls="controls"></video>
|
||||
<video id="player" class="center-block" controls="controls" preload="none"></video>
|
||||
<br>
|
||||
<#include "/fother.inc.html">
|
||||
Reference in New Issue
Block a user