Browse Source

improve video auto play

master
filesite 4 months ago
parent
commit
b4db410534
  1. 21
      www/js/beauty.js

21
www/js/beauty.js

@ -640,6 +640,7 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
//加载更多视频 //加载更多视频
var currentPage = $('.othervideos').attr('data-page'), var currentPage = $('.othervideos').attr('data-page'),
currentVideoId = $('.othervideos').attr('data-id'); currentVideoId = $('.othervideos').attr('data-id');
var callback_loadNextPage = null;
var getOtherVideos = function(currentPage) { var getOtherVideos = function(currentPage) {
if (_noMoreVideos) {return false;} if (_noMoreVideos) {return false;}
var videoId = $('.othervideos').attr('data-id'), var videoId = $('.othervideos').attr('data-id'),
@ -669,6 +670,10 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
getVideoMetaAndShowIt(videoId, videoUrl); getVideoMetaAndShowIt(videoId, videoUrl);
}); });
}, 50); }, 50);
if (callback_loadNextPage) {
callback_loadNextPage(data.videos);
}
}else { }else {
_noMoreVideos = true; _noMoreVideos = true;
console.warn('获取更多视频数据出错啦', data.msg); console.warn('获取更多视频数据出错啦', data.msg);
@ -681,11 +686,7 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
getOtherVideos(currentPage); getOtherVideos(currentPage);
//自动播放 //自动播放
myPlayer.on('ended', function() { var playNextVideo = function() {
var cachedAutoPlayStatus = Cookies.get('autoplay');
if (cachedAutoPlayStatus == 'off') {return false;}
if (moreVideos && moreVideos.length > 0) {
var nextVideo = moreVideos.shift(); var nextVideo = moreVideos.shift();
if (nextVideo.id == currentVideoId && moreVideos.length > 0) { if (nextVideo.id == currentVideoId && moreVideos.length > 0) {
nextVideo = moreVideos.shift(); nextVideo = moreVideos.shift();
@ -695,7 +696,17 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
myPlayer.src(nextVideo.path); myPlayer.src(nextVideo.path);
$('.navbar-header .videotitle').text(nextVideo.filename); $('.navbar-header .videotitle').text(nextVideo.filename);
} }
};
myPlayer.on('ended', function() {
var cachedAutoPlayStatus = Cookies.get('autoplay');
if (cachedAutoPlayStatus == 'off') {return false;}
if (moreVideos && moreVideos.length > 0) {
playNextVideo();
}else { }else {
callback_loadNextPage = function(videos) {
playNextVideo();
};
currentPage = parseInt(currentPage) + 1; currentPage = parseInt(currentPage) + 1;
getOtherVideos(currentPage); getOtherVideos(currentPage);
} }

Loading…
Cancel
Save