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

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

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

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

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

19
www/js/beauty.js

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

Loading…
Cancel
Save