<?php
/**
 * 结算页
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaoq <570035208@qq.com>
 */
namespace Home\Controller;
use Think\Controller;
class LiveAnchorController extends BaseController {

    public function player(){
        $postdata=I('get.');
        if($postdata['type']=='look_back'){
            $id=$postdata['id'];
            if(empty($id)) $this->error('参数错误');
            $map=array();
            $map['a.id']=$id;
            //1203
            $data = M('LiveHistory')->alias('a')->where($map)->JOIN('LEFT JOIN __LIVE_HISTORY_LINK__ hl ON a.roomnumber=hl.stream')->field('a.*,hl.*,hl.id as link_id,a.id as id')->find();
            if($data) {                
                $player_url = $data['recordurl'] = 'http://pili-vod.thinkp2p.cn/' .$data['m3u8_uri'];
                $data['start_time'] = time_format($val['start_time']);
                $data['stop_time'] = time_format($val['stop_time']);
                $data['begin_time'] = time_format($val['begin_time']);
                $data['end_time'] = time_format($val['end_time']);
                $data['liveimg'] = thumb($val['liveimg'],355,355);
                $data['goods_info'] = unserialize($val['goods_info']);
                $goods_info=array_filter(unserialize($val['goods_info']));
                $data['goods_count'] =count($goods_info)?count($goods_info):0;

                $return['status'] = 1;
                $return['data'] = $data;
                $return['recordcount'] =count($data);
            }else{
                $return['msg'] = '未找到相关录播信息';
            }
        }else{
            $room_id = $postdata['room_id'];
            $live= new \Common\Vendor\QiniuLive;
            $streamKey=$room_id;
            $player_url = $live->HLSPlayURL($streamKey);
            if(!$player_url) $this->error('拉流地址获取错误');
        }
        $this->assign('url',$player_url);
        $this->display();
    }
    public function notify(){
        $notify=file_get_contents("php://input");
        //file_put_contents('uploads/PAY-liveput'.NOW_TIME.'.txt',var_export($notify,1));
    }
	
	

 

   

   

 
  
  
    
}
?>