|
|
@ -546,6 +546,7 @@ var saveVideoMeta = function(videoId, metaData, manual) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
//视频播放器
|
|
|
|
//视频播放器
|
|
|
|
|
|
|
|
var moreVideos = [], _noMoreVideos = false; |
|
|
|
if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { |
|
|
|
if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { |
|
|
|
var myPlayer = videojs('my-player', { |
|
|
|
var myPlayer = videojs('my-player', { |
|
|
|
controls: true, |
|
|
|
controls: true, |
|
|
@ -590,6 +591,7 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { |
|
|
|
setTimeout(takeScreenshot, screenshot_start); |
|
|
|
setTimeout(takeScreenshot, screenshot_start); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//生成封面图
|
|
|
|
$('.btn-snapshot').click(function(e) { |
|
|
|
$('.btn-snapshot').click(function(e) { |
|
|
|
var clickedBtn = $(e.target); |
|
|
|
var clickedBtn = $(e.target); |
|
|
|
clickedBtn.prop('disabled', true); |
|
|
|
clickedBtn.prop('disabled', true); |
|
|
@ -601,22 +603,6 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { |
|
|
|
clickedBtn.prop('disabled', false); |
|
|
|
clickedBtn.prop('disabled', false); |
|
|
|
}, 3000); |
|
|
|
}, 3000); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加载更多视频
|
|
|
|
|
|
|
|
if ($('.othervideos').length > 0) { |
|
|
|
|
|
|
|
var videoId = $('.othervideos').attr('data-id'), |
|
|
|
|
|
|
|
cateId = $('.othervideos').attr('data-pid'), |
|
|
|
|
|
|
|
cacheId = $('.othervideos').attr('data-cid'), |
|
|
|
|
|
|
|
currentPage = $('.othervideos').attr('data-page'); |
|
|
|
|
|
|
|
var api = '/list/', |
|
|
|
|
|
|
|
params = { |
|
|
|
|
|
|
|
id: cateId, |
|
|
|
|
|
|
|
cid: cacheId, |
|
|
|
|
|
|
|
show: 'video', |
|
|
|
|
|
|
|
dataType: 'video', |
|
|
|
|
|
|
|
page: currentPage |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getVideoUrl = function(videoId, videoPath) { |
|
|
|
var getVideoUrl = function(videoId, videoPath) { |
|
|
|
var url = new URL(location.href); |
|
|
|
var url = new URL(location.href); |
|
|
@ -651,28 +637,87 @@ if ($('.othervideos').length > 0) { |
|
|
|
return html; |
|
|
|
return html; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
//加载更多视频
|
|
|
|
url: api, |
|
|
|
var currentPage = $('.othervideos').attr('data-page'); |
|
|
|
method: 'GET', |
|
|
|
var getOtherVideos = function(currentPage) { |
|
|
|
dataType: 'json', |
|
|
|
if (_noMoreVideos) {return false;} |
|
|
|
data: params |
|
|
|
var videoId = $('.othervideos').attr('data-id'), |
|
|
|
}).done(function(data) { |
|
|
|
cateId = $('.othervideos').attr('data-pid'), |
|
|
|
//console.log('more videos', data);
|
|
|
|
cacheId = $('.othervideos').attr('data-cid'); |
|
|
|
if (typeof(data.videos) != 'undefined' && data.videos.length > 0) { |
|
|
|
var api = '/list/', |
|
|
|
$('.othervideos').html(renderVideos(videoId, data.videos)); |
|
|
|
params = { |
|
|
|
setTimeout(function() { |
|
|
|
id: cateId, |
|
|
|
$('.othervideos .video-poster').each(function(index, el) { |
|
|
|
cid: cacheId, |
|
|
|
var videoId = $(el).attr('data-video-id'), |
|
|
|
show: 'video', |
|
|
|
videoUrl = $(el).attr('data-video-url'); |
|
|
|
dataType: 'video', |
|
|
|
getVideoMetaAndShowIt(videoId, videoUrl); |
|
|
|
page: currentPage |
|
|
|
}); |
|
|
|
}; |
|
|
|
}, 50); |
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
url: api, |
|
|
|
|
|
|
|
method: 'GET', |
|
|
|
|
|
|
|
dataType: 'json', |
|
|
|
|
|
|
|
data: params |
|
|
|
|
|
|
|
}).done(function(data) { |
|
|
|
|
|
|
|
if (typeof(data.videos) != 'undefined' && data.videos.length > 0) { |
|
|
|
|
|
|
|
moreVideos = data.videos; |
|
|
|
|
|
|
|
$('.othervideos').html(renderVideos(videoId, data.videos)); |
|
|
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
|
|
$('.othervideos .video-poster').each(function(index, el) { |
|
|
|
|
|
|
|
var videoId = $(el).attr('data-video-id'), |
|
|
|
|
|
|
|
videoUrl = $(el).attr('data-video-url'); |
|
|
|
|
|
|
|
getVideoMetaAndShowIt(videoId, videoUrl); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, 50); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
_noMoreVideos = true; |
|
|
|
|
|
|
|
console.warn('获取更多视频数据出错啦', data.msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).fail(function(jqXHR, textStatus, errorThrown) { |
|
|
|
|
|
|
|
console.error('获取更多视频数据失败,错误信息:' + errorThrown); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getOtherVideos(currentPage); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//自动播放
|
|
|
|
|
|
|
|
myPlayer.on('ended', function() { |
|
|
|
|
|
|
|
var cachedAutoPlayStatus = Cookies.get('autoplay'); |
|
|
|
|
|
|
|
if (cachedAutoPlayStatus == 'off') {return false;} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (moreVideos && moreVideos.length > 0) { |
|
|
|
|
|
|
|
var nextVideo = moreVideos.shift(); |
|
|
|
|
|
|
|
myPlayer.src(nextVideo.path); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
//_noMoreData = true;
|
|
|
|
currentPage = parseInt(currentPage) + 1; |
|
|
|
console.warn('获取更多视频数据出错啦', data.msg); |
|
|
|
getOtherVideos(currentPage); |
|
|
|
} |
|
|
|
} |
|
|
|
}).fail(function(jqXHR, textStatus, errorThrown) { |
|
|
|
}); |
|
|
|
console.error('获取更多视频数据失败,错误信息:' + errorThrown); |
|
|
|
|
|
|
|
|
|
|
|
var switchAutoPlayBtns = function(status) { |
|
|
|
|
|
|
|
var cookieKey = 'autoplay'; |
|
|
|
|
|
|
|
if (status == 'on') { |
|
|
|
|
|
|
|
$('.autoplay_disabled').removeClass('btn-primary'); |
|
|
|
|
|
|
|
$('.autoplay_enabled').addClass('btn-primary'); |
|
|
|
|
|
|
|
Cookies.set(cookieKey, 'on', { expires: 7 }); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
$('.autoplay_enabled').removeClass('btn-primary'); |
|
|
|
|
|
|
|
$('.autoplay_disabled').addClass('btn-primary'); |
|
|
|
|
|
|
|
Cookies.set(cookieKey, 'off', { expires: 7 }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$('#my-player').focus(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cachedAutoPlayStatus = Cookies.get('autoplay'); |
|
|
|
|
|
|
|
if (cachedAutoPlayStatus == 'off') { |
|
|
|
|
|
|
|
$('.autoplay_enabled').removeClass('btn-primary'); |
|
|
|
|
|
|
|
$('.autoplay_disabled').addClass('btn-primary'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.autoplay_disabled').click(function() { |
|
|
|
|
|
|
|
switchAutoPlayBtns('off'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$('.autoplay_enabled').click(function() { |
|
|
|
|
|
|
|
switchAutoPlayBtns('on'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|