Live.php 1.6 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. }
  29. if ($data['sdate'] > $time) {
  30. $data['status'] = 1;
  31. }
  32. if ($data['edate'] <= $time) {
  33. $data['status'] = 3;
  34. }
  35. $data['sdate_time'] = date('Y-m-d H:i:s', $data['sdate']);
  36. $data['edate_time'] = date('Y-m-d H:i:s', $data['edate']);
  37. return $data;
  38. }
  39. # 获取相关推荐
  40. public function getRelation($info)
  41. {
  42. $where['noid'] = $info['id'];
  43. $where['cate_id'] = $info['cate_id'];
  44. return Dever::db('video/live')->getRelation($where);
  45. }
  46. # 增加浏览量
  47. public function addView($id)
  48. {
  49. Dever::db('video/live')->addView($id);
  50. }
  51. }