Live.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Video\Lib;
  3. use Dever;
  4. class Live
  5. {
  6. # 根据id 获取信息
  7. public function get($data, $uid = false)
  8. {
  9. if (!is_array($data)) {
  10. $data = Dever::db('video/live')->getOne($data);
  11. }
  12. if (!$data) {
  13. Dever::alert('错误的信息');
  14. }
  15. $data['content'] = Dever::filter($data['content']);
  16. //embed
  17. $time = time();
  18. $data['status'] = 1;
  19. $data['stream'] = '';
  20. if ($data['sdate'] <= $time && $time <= $data['edate']) {
  21. $stream = Dever::db('live/stream')->one($data['stream_id']);
  22. $data['stream'] = $stream['live'];
  23. $data['stream_rtmp'] = $stream['url_rtmp'];
  24. $data['stream_hls'] = $stream['url_hls'];
  25. $data['stream_hdl'] = $stream['url_hdl'];
  26. $data['stream_pic'] = $stream['url_pic'];
  27. $data['status'] = 2;
  28. } elseif ($data['sdate'] > $time) {
  29. $data['status'] = 1;
  30. } elseif ($data['edate'] <= $time) {
  31. $data['status'] = 3;
  32. if (!$data['url']) {
  33. # 回放生成中
  34. $data['status'] = 3;
  35. }
  36. }
  37. $data['sdate_time'] = date('Y-m-d H:i:s', $data['sdate']);
  38. $data['edate_time'] = date('Y-m-d H:i:s', $data['edate']);
  39. return $data;
  40. }
  41. # 获取相关推荐
  42. public function getRelation($info)
  43. {
  44. $where['noid'] = $info['id'];
  45. $where['cate_id'] = $info['cate_id'];
  46. return Dever::db('video/live')->getRelation($where);
  47. }
  48. # 增加浏览量
  49. public function addView($id)
  50. {
  51. Dever::db('video/live')->addView($id);
  52. }
  53. }