mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-22 19:44:02 +08:00
修正记忆播放问题
This commit is contained in:
parent
a3d62c71bf
commit
74c08316f1
@ -48,10 +48,12 @@ class SyncLearningTask extends Task
|
||||
*/
|
||||
protected function handleLearning($itemKey)
|
||||
{
|
||||
$cache = $this->getCache();
|
||||
|
||||
/**
|
||||
* @var LearningModel $cacheLearning
|
||||
*/
|
||||
$cacheLearning = $this->cache->get($itemKey);
|
||||
$cacheLearning = $cache->get($itemKey);
|
||||
|
||||
if (!$cacheLearning) return;
|
||||
|
||||
@ -76,7 +78,7 @@ class SyncLearningTask extends Task
|
||||
$this->updateChapterUser($dbLearning);
|
||||
}
|
||||
|
||||
$this->cache->delete($itemKey);
|
||||
$cache->delete($itemKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +113,12 @@ class SyncLearningTask extends Task
|
||||
|
||||
$progress = floor(100 * $chapterUser->duration / $duration);
|
||||
|
||||
$chapterUser->position = floor($learning->position);
|
||||
/**
|
||||
* 过于接近结束位置当作已结束处理,播放位置为起点0
|
||||
*/
|
||||
$playPosition = $duration - $learning->position > 10 ? floor($learning->position) : 0;
|
||||
|
||||
$chapterUser->position = $playPosition;
|
||||
$chapterUser->progress = $progress < 100 ? $progress : 100;
|
||||
$chapterUser->consumed = $chapterUser->duration > 0.3 * $duration ? 1 : 0;
|
||||
|
||||
|
@ -99,6 +99,9 @@ class Chapter extends Repository
|
||||
*/
|
||||
public function findByFileId($fileId)
|
||||
{
|
||||
/**
|
||||
* @var ChapterVodModel $vod
|
||||
*/
|
||||
$vod = ChapterVodModel::findFirst([
|
||||
'conditions' => 'file_id = :file_id:',
|
||||
'bind' => ['file_id' => $fileId],
|
||||
|
@ -7,6 +7,7 @@ layui.use(['jquery', 'helper'], function () {
|
||||
var intervalTime = 15000;
|
||||
var userId = window.user.id;
|
||||
var requestId = helper.getRequestId();
|
||||
var chapterId = $('input[name="chapter.id"]').val();
|
||||
var planId = $('input[name="chapter.plan_id"]').val();
|
||||
var lastPosition = $('input[name="chapter.position"]').val();
|
||||
var learningUrl = $('input[name="chapter.learning_url"]').val();
|
||||
@ -57,15 +58,30 @@ layui.use(['jquery', 'helper'], function () {
|
||||
player.toggle();
|
||||
});
|
||||
|
||||
var position = parseInt(lastPosition);
|
||||
var position = getLastPosition();
|
||||
|
||||
/**
|
||||
* 过于接近结束位置当作已结束处理
|
||||
* 上次播放位置
|
||||
*/
|
||||
if (position > 0 && player.video.duration - position > 10) {
|
||||
if (position > 0) {
|
||||
player.seek(position);
|
||||
}
|
||||
|
||||
function getPositionKey() {
|
||||
return 'chapter:' + chapterId + ':position';
|
||||
}
|
||||
|
||||
function getLastPosition() {
|
||||
var key = getPositionKey();
|
||||
var value = localStorage.getItem(key);
|
||||
return value != null ? parseInt(value) : lastPosition;
|
||||
}
|
||||
|
||||
function setLastPosition(value) {
|
||||
var key = getPositionKey();
|
||||
localStorage.setItem(key, value);
|
||||
}
|
||||
|
||||
function clearLearningInterval() {
|
||||
if (interval != null) {
|
||||
clearInterval(interval);
|
||||
@ -87,11 +103,13 @@ layui.use(['jquery', 'helper'], function () {
|
||||
}
|
||||
|
||||
function ended() {
|
||||
clearLearningInterval();
|
||||
learning();
|
||||
setLastPosition(0);
|
||||
clearLearningInterval();
|
||||
}
|
||||
|
||||
function learning() {
|
||||
setLastPosition(player.video.currentTime);
|
||||
if (userId !== '0' && planId !== '0') {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
Loading…
x
Reference in New Issue
Block a user