1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace Video\Lib;
- use Dever;
- class Live
- {
- # 根据id 获取信息
- public function get($data, $uid = false)
- {
- if (!is_array($data)) {
- $data = Dever::db('video/live')->getOne($data);
- }
-
- if (!$data) {
- Dever::alert('错误的信息');
- }
- $data['content'] = Dever::filter($data['content']);
-
- //embed
- $time = time();
- $data['status'] = 1;
- $data['stream'] = '';
- if ($data['sdate'] <= $time && $time <= $data['edate']) {
- $stream = Dever::db('live/stream')->one($data['stream_id']);
- $data['stream'] = $stream['live'];
- $data['stream_rtmp'] = $stream['url_rtmp'];
- $data['stream_hls'] = $stream['url_hls'];
- $data['stream_hdl'] = $stream['url_hdl'];
- $data['stream_pic'] = $stream['url_pic'];
- $data['status'] = 2;
- } elseif ($data['sdate'] > $time) {
- $data['status'] = 1;
- } elseif ($data['edate'] <= $time) {
- $data['status'] = 3;
- if (!$data['url']) {
- # 回放生成中
- $data['status'] = 3;
- }
- }
- $data['sdate_time'] = date('Y-m-d H:i:s', $data['sdate']);
- $data['edate_time'] = date('Y-m-d H:i:s', $data['edate']);
-
- return $data;
- }
- # 获取相关推荐
- public function getRelation($info)
- {
- $where['noid'] = $info['id'];
- $where['cate_id'] = $info['cate_id'];
- return Dever::db('video/live')->getRelation($where);
- }
- # 增加浏览量
- public function addView($id)
- {
- Dever::db('video/live')->addView($id);
- }
- }
|