cleargo 2017-02-06 13:15:52 1993次浏览 0条回复 0 0 0
if(isset($this->param['vid'])&&$this->param['vid']!=''){
            $vid = $this->param['vid'];
        }else{
            return JsonWidget::widget(array(
                'success'=>false,
                'message'=>'请传入直播视频id',
                'data'=>array()
            ));
        }
//        $vid = 48;

        //创建hub
        $mac = new Qiniu\Pili\Mac($this->ak, $this->sk);
        $client = new Qiniu\Pili\Client($mac);
        $hub = $client->hub($this->hubName);
        $re = new VideoLive();
        $reinfo = VideoLive::find()->where('del=:del AND vid=:vid',[':del'=>1,':vid'=>$vid])->one();
        $rtmpurl = $reinfo->rtmpurl;
        $rtmparr = explode('/',$rtmpurl);
        $rtmparrs = explode('?',$rtmparr[4]);
        $streamname = $rtmparrs[0];
        //加入流名
        $stream = $hub->stream("{$streamname}");

        try {
            //判断直播的状态
            $status = $stream->liveStatus();
            if($status){
                return JsonWidget::widget(array(
                    'success'=>true,
                    'message'=>'正在直播',
                    'data'=>array()
                ));
            }
        } catch (\Exception $e) {
            echo "Error:", $e, "\n";
        }
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册