| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Http\Validator\LiveValidator;
- use App\Services\LiveService;
- /**
- * 在线直播
- * @package App\Http\Controllers\Api\v1
- */
- class LiveController extends webApp
- {
- /**
- * 获取流地址
- * @return array
- */
- public function getUrl()
- {
- $urls = LiveService::make()->getLiveUrl($this->userId);
- return message(1010, true, $urls);
- }
- /**
- * 直播详情
- * @param LiveValidator $validator
- * @return array
- */
- public function getInfo(LiveValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'info');
- if (!is_array($params)) {
- return message($params, false);
- }
- if(!$info = LiveService::make()->getInfo($params['id'], $this->userId)){
- return message(LiveService::make()->getError(),false);
- }else{
- return message(1010,true, $info);
- }
- }
- /**
- * 创建直播间(开启直播)
- * @return array
- */
- public function create(LiveValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'create');
- if (!is_array($params)) {
- return message($params, false);
- }
- if(!$result = LiveService::make()->create($this->userId, $params)){
- return message(LiveService::make()->getError(),false);
- }else{
- return message(LiveService::make()->getError(),true, $result);
- }
- }
- }
|