初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model\live;
|
||||
|
||||
use think\Model;
|
||||
use app\api\model\course\Course as CourseModel;
|
||||
class Playback extends Model
|
||||
{
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'live_playback';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取回放视频列表
|
||||
* @return void
|
||||
*/
|
||||
public function getVideoList($courseId){
|
||||
$data = self::where([
|
||||
'course_id'=>$courseId,
|
||||
'status'=>1
|
||||
])
|
||||
->order('start_time','asc')
|
||||
->select();
|
||||
|
||||
//判断是否为伪直播并启用了自动回放
|
||||
$liveData = CourseModel::where([
|
||||
'id'=>$courseId,
|
||||
'live_type'=>2,
|
||||
'live_video_convert_replay'=>1
|
||||
])->find();
|
||||
|
||||
|
||||
if($liveData && $liveData['live_video']){
|
||||
$liveVideo = json_decode($liveData['live_video'],true);
|
||||
if($liveVideo){
|
||||
$data[] = [
|
||||
'file_path'=>$liveVideo['url'],
|
||||
'source'=>$liveVideo['storage'],
|
||||
'start_time'=>$liveData['live_start_time'],
|
||||
'end_time'=>$liveData['live_end_time'],
|
||||
'file_name'=>$liveData['name']
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$data){
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($data as &$item){
|
||||
$item['file_path'] = parse_file_url($item['file_path'],$item['source']);
|
||||
|
||||
$item['time'] = date('m-d h:i',$item['start_time']) . " ~~ " . date('m-d h:i',$item['end_time']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user