LiveController.class.php
3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* 【后台】直播页面接口
* Created by PhpStorm.
* User: yingcai
* Date: 2018/1/12
* Time: 下午2:49
*/
namespace Apicp\Controller\LiveRoom;
use Common\Common\Constant;
use Common\Common\User;
use Common\Service\MainService;
use Common\Service\RoleService;
class LiveController extends AbstractController
{
/**
* Live
* @author houyingcai
* @desc 直播页面接口
* @param Int lm_id:true:1 直播活动ID
* @return array|bool 直播列表
array(
'live_status' => 1, // 直播状态
'name' => '产品培训讲解', // 直播名称
'start_time' => 1515407868910, // 直播开始时间
'estimated_duration' => 45, // 预计时长(单位:分钟)
'pic' => 'b3ddbc502e307665f346cbd6e52cc10d', // 封面图ID
'pic_url' => 'http://qy.vchangyi.org', // 封面图片URL
'lecturer' => '王宇', // 讲师姓名
'avatar' => 'http://qy.vchangyi.org', // 讲师头像URL
'lecturer_title' => '金牌讲师', // 讲师头衔
'stream_name' => '2334_f40d273cafbd57d0be02091d7c128ecb', // 流名称
'stream_url' => 'rtmp://2334.livepush.myqcloud.com/live/', // 推流地址
'stream_status' => '1', // 直播室状态 0: 禁用 1: 允许推流 2: 断流
'qr_code' => 'http://qy.vchangyi.org', // 直播间二维码地址
)
*/
public function Index()
{
$lmId = $this->liveMainDetail['lm_id'];
// 获取直播信息
$mainService = new MainService();
$mainDetail = $this->liveMainDetail;
// 格式化直播状态
$live_status = $mainService->live_status($mainDetail['live_status'], $mainDetail['start_time']);
// 获取讲师信息
$roleService = new RoleService();
$roleInfo = $roleService->get_by_conds([
'lm_id' => $lmId,
'type' => Constant::LIVE_ROLE_TYPE_LECTURER,
], [], true);
// 获取讲师个人信息
$userService = &User::instance();
$lecturerInfo = $userService->getByUid($roleInfo['obj_id']);
// 返回数据
$this->_result = [
'live_status' => intval($live_status),
'name' => $mainDetail['name'],
'start_time' => $mainDetail['start_time'],
'estimated_duration' => $mainDetail['estimated_duration'],
'pic' => $mainDetail['pic'],
'pic_url' => $mainService->formatCover($mainDetail['pic']),
'lecturer' => $lecturerInfo['memUsername'],
'avatar' => $userService->avatar($roleInfo['obj_id'], $lecturerInfo),
'lecturer_title' => $roleInfo['title'],
'stream_name' => $this->studioDetail['stream_name'],
'stream_url' => $this->studioDetail['stream_url'],
'stream_status' => $this->studioDetail['stream_status'],
'qr_code' => oaUrl('Frontend/Index/RoomQrcode/index', ['lm_id' => $lmId], $mainDetail['domain']), // 二维码URL
];
return true;
}
}