mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-29 22:01:38 +08:00
优化点播直播部分代码
This commit is contained in:
parent
f4dda5a58c
commit
3ce6897de1
@ -38,13 +38,13 @@ class Learning extends Service
|
||||
$data['position'] = $validator->checkPosition($post['position']);
|
||||
}
|
||||
|
||||
$interval = $validator->checkInterval($post['interval']);
|
||||
$intervalTime = $validator->checkIntervalTime($post['interval_time']);
|
||||
|
||||
$learning = new LearningModel($data);
|
||||
|
||||
$sync = new LearningSyncService();
|
||||
|
||||
$sync->addItem($learning, $interval);
|
||||
$sync->addItem($learning, $intervalTime);
|
||||
}
|
||||
|
||||
}
|
@ -49,7 +49,7 @@ class CourseList extends Service
|
||||
|
||||
$courses = $builder->getCourses($relations);
|
||||
|
||||
$pager->items = $courses;
|
||||
$pager->items = array_values($courses);
|
||||
|
||||
return $pager;
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ class Learning extends Service
|
||||
|
||||
/**
|
||||
* @param LearningModel $learning
|
||||
* @param int $interval
|
||||
* @param int $intervalTime
|
||||
*/
|
||||
public function addItem(LearningModel $learning, $interval = 10)
|
||||
public function addItem(LearningModel $learning, $intervalTime = 10)
|
||||
{
|
||||
$cache = $this->getCache();
|
||||
|
||||
@ -37,14 +37,14 @@ class Learning extends Service
|
||||
|
||||
$learning->client_type = $this->getClientType();
|
||||
$learning->client_ip = $this->getClientIp();
|
||||
$learning->duration = $interval;
|
||||
$learning->duration = $intervalTime;
|
||||
$learning->active_time = time();
|
||||
|
||||
$cache->save($itemKey, $learning, $this->lifetime);
|
||||
|
||||
} else {
|
||||
|
||||
$cacheLearning->duration += $interval;
|
||||
$cacheLearning->duration += $intervalTime;
|
||||
$cacheLearning->position = $learning->position;
|
||||
$cacheLearning->active_time = time();
|
||||
|
||||
|
@ -26,9 +26,9 @@ class Learning extends Validator
|
||||
return $requestId;
|
||||
}
|
||||
|
||||
public function checkInterval($interval)
|
||||
public function checkIntervalTime($intervalTime)
|
||||
{
|
||||
$value = $this->filter->sanitize($interval, ['trim', 'int']);
|
||||
$value = $this->filter->sanitize($intervalTime, ['trim', 'int']);
|
||||
|
||||
/**
|
||||
* 兼容秒和毫秒
|
||||
@ -38,7 +38,7 @@ class Learning extends Validator
|
||||
}
|
||||
|
||||
if ($value < 5) {
|
||||
throw new BadRequestException('learning.invalid_interval');
|
||||
throw new BadRequestException('learning.invalid_interval_time');
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
@ -108,7 +108,12 @@ class Refund extends Validator
|
||||
|
||||
public function checkIfAllowCancel(RefundModel $refund)
|
||||
{
|
||||
if ($refund->status != RefundModel::STATUS_PENDING) {
|
||||
$scopes = [
|
||||
RefundModel::STATUS_PENDING,
|
||||
RefundModel::STATUS_APPROVED,
|
||||
];
|
||||
|
||||
if (!in_array($refund->status, $scopes)) {
|
||||
throw new BadRequestException('refund.cancel_not_allowed');
|
||||
}
|
||||
}
|
||||
|
@ -321,8 +321,8 @@ $error['course_query.invalid_sort'] = '无效的排序类别';
|
||||
*/
|
||||
$error['learning.invalid_plan_id'] = '无效的计划编号';
|
||||
$error['learning.invalid_request_id'] = '无效的请求编号';
|
||||
$error['learning.invalid_interval_time'] = '无效的间隔时间';
|
||||
$error['learning.invalid_position'] = '无效的播放位置';
|
||||
$error['learning.invalid_interval'] = '无效的间隔时间';
|
||||
|
||||
/**
|
||||
* 即时通讯
|
||||
|
@ -6,7 +6,6 @@ layui.use(['jquery', 'helper'], function () {
|
||||
var interval = null;
|
||||
var intervalTime = 15000;
|
||||
var userId = window.user.id;
|
||||
var chapterId = $('input[name="chapter.id"]').val();
|
||||
var planId = $('input[name="chapter.plan_id"]').val();
|
||||
var learningUrl = $('input[name="chapter.learning_url"]').val();
|
||||
var playUrls = JSON.parse($('input[name="chapter.play_urls"]').val());
|
||||
@ -17,7 +16,7 @@ layui.use(['jquery', 'helper'], function () {
|
||||
autoplay: true,
|
||||
h5_flv: true,
|
||||
width: 760,
|
||||
height: 428
|
||||
height: 428,
|
||||
};
|
||||
|
||||
var formats = ['rtmp', 'flv', 'm3u8'];
|
||||
@ -32,14 +31,12 @@ layui.use(['jquery', 'helper'], function () {
|
||||
});
|
||||
});
|
||||
|
||||
console.log(options);
|
||||
|
||||
options.listener = function (msg) {
|
||||
if (msg.type === 'play') {
|
||||
start();
|
||||
} else if (msg.type === 'pause') {
|
||||
stop();
|
||||
} else if (msg.type === 'end') {
|
||||
} else if (msg.type === 'ended') {
|
||||
stop();
|
||||
}
|
||||
};
|
||||
@ -68,10 +65,8 @@ layui.use(['jquery', 'helper'], function () {
|
||||
url: learningUrl,
|
||||
data: {
|
||||
plan_id: planId,
|
||||
chapter_id: chapterId,
|
||||
request_id: requestId,
|
||||
interval: intervalTime,
|
||||
position: player.currentTime(),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ 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();
|
||||
@ -16,7 +15,7 @@ layui.use(['jquery', 'helper'], function () {
|
||||
var options = {
|
||||
autoplay: false,
|
||||
width: 760,
|
||||
height: 428
|
||||
height: 428,
|
||||
};
|
||||
|
||||
if (playUrls.hasOwnProperty('od')) {
|
||||
@ -84,10 +83,9 @@ layui.use(['jquery', 'helper'], function () {
|
||||
url: learningUrl,
|
||||
data: {
|
||||
plan_id: planId,
|
||||
chapter_id: chapterId,
|
||||
request_id: requestId,
|
||||
interval: intervalTime,
|
||||
position: player.currentTime()
|
||||
position: player.currentTime(),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user