Browse Source

video play loop for all pages

master
filesite 4 months ago
parent
commit
5b90885716
  1. 3
      themes/beauty/controller/SiteController.php
  2. 2
      themes/beauty/views/site/index.php
  3. 1
      themes/beauty/views/site/player.php
  4. 19
      www/js/beauty.js

3
themes/beauty/controller/SiteController.php

@ -431,6 +431,7 @@ Class SiteController extends Controller { @@ -431,6 +431,7 @@ Class SiteController extends Controller {
$cateId = $this->get('pid', '');
$cacheParentDataId = $this->get('cid', '');
$page = $this->get('page', 1);
$pageSize = $this->get('limit', 24);
if (empty($videoUrl) || empty($videoId) || empty($cateId) || empty($cacheParentDataId)) {
throw new Exception("缺少参数!", 403);
@ -456,7 +457,7 @@ Class SiteController extends Controller { @@ -456,7 +457,7 @@ Class SiteController extends Controller {
$viewName = 'player';
$params = compact(
'videoUrl', 'videoId', 'videoFilename',
'cateId', 'cacheParentDataId', 'page',
'cateId', 'cacheParentDataId', 'page', 'pageSize',
'copyright'
);
return $this->render($viewName, $params, $pageTitle);

2
themes/beauty/views/site/index.php

@ -320,7 +320,7 @@ eof; @@ -320,7 +320,7 @@ eof;
$videoUrl = urlencode($file['path']);
$linkUrl = "/site/player?id={$file['id']}&pid={$file['pid']}&cid={$viewData['cacheDataId']}&url={$videoUrl}";
if ($viewData['showType'] == 'video') {
$linkUrl .= "&page={$viewData['page']}";
$linkUrl .= "&page={$viewData['page']}&limit={$viewData['pageSize']}";
}
echo <<<eof

1
themes/beauty/views/site/player.php

@ -67,6 +67,7 @@ @@ -67,6 +67,7 @@
data-pid="<?php echo $viewData['cateId']; ?>"
data-cid="<?php echo $viewData['cacheParentDataId']; ?>"
data-page="<?php echo $viewData['page']; ?>"
data-page-size="<?php echo $viewData['pageSize']; ?>"
class="othervideos">其它视频</div>
</div>
</div>

19
www/js/beauty.js

@ -639,9 +639,10 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { @@ -639,9 +639,10 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
//加载更多视频
var currentPage = $('.othervideos').attr('data-page'),
currentPageSize = $('.othervideos').attr('data-page-size'),
currentVideoId = $('.othervideos').attr('data-id');
var callback_loadNextPage = null;
var getOtherVideos = function(currentPage) {
var getOtherVideos = function() {
if (_noMoreVideos) {return false;}
var videoId = $('.othervideos').attr('data-id'),
cateId = $('.othervideos').attr('data-pid'),
@ -652,7 +653,8 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { @@ -652,7 +653,8 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
cid: cacheId,
show: 'video',
dataType: 'video',
page: currentPage
page: currentPage,
limit: currentPageSize
};
$.ajax({
url: api,
@ -675,15 +677,20 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { @@ -675,15 +677,20 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
callback_loadNextPage(data.videos);
}
}else {
_noMoreVideos = true;
console.warn('获取更多视频数据出错啦', data.msg);
if (currentPage > 1) {
currentPage = 1; //重新从第一页循环播放
getOtherVideos();
}else {
_noMoreVideos = true;
console.warn('获取更多视频数据出错啦', data.msg);
}
}
}).fail(function(jqXHR, textStatus, errorThrown) {
console.error('获取更多视频数据失败,错误信息:' + errorThrown);
});
};
getOtherVideos(currentPage);
getOtherVideos();
//自动播放
var playNextVideo = function() {
@ -708,7 +715,7 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { @@ -708,7 +715,7 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
playNextVideo();
};
currentPage = parseInt(currentPage) + 1;
getOtherVideos(currentPage);
getOtherVideos();
}
});

Loading…
Cancel
Save