Live.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. if ($data['stream_id'] && $data['stream_id'] > 0) {
  22. $stream = Dever::db('live/stream')->one($data['stream_id']);
  23. $data['stream'] = $stream['live'];
  24. $data['stream_rtmp'] = $stream['url_rtmp'];
  25. $data['stream_hls'] = $stream['url_hls'];
  26. $data['stream_hdl'] = $stream['url_hdl'];
  27. $data['stream_pic'] = $stream['url_pic'];
  28. $data['url'] = $data['stream_hls'];
  29. $source_type = Dever::input('source_type');
  30. if ($source_type != 'ios' && $source_type != 'android') {
  31. //$data['stream_rtmp'] = $data['stream_hdl'];
  32. }
  33. } elseif (isset($data['stream_link']) && $data['stream_link']) {
  34. $data['stream'] = $data['stream_link'];
  35. $data['stream_rtmp'] = $data['stream_link'];
  36. $data['stream_hls'] = $data['stream_link'];
  37. $data['stream_hdl'] = $data['stream_link'];
  38. $data['stream_pic'] = $data['stream_link'];
  39. $data['url'] = $data['stream_hls'];
  40. }
  41. $data['status'] = 2;
  42. } elseif ($data['sdate'] > $time) {
  43. $data['status'] = 1;
  44. } elseif ($data['edate'] <= $time) {
  45. $data['status'] = 3;
  46. if (!$data['url']) {
  47. # 回放生成中
  48. $data['status'] = 3;
  49. }
  50. }
  51. if ($data['url'] && !isset($data['stream_rtmp'])) {
  52. $data = Dever::load('video/lib/vod')->avinfo($data, 'url', 'video/live');
  53. }
  54. if (Dever::input('test') == 1) {
  55. print_r($data);die;
  56. }
  57. $data['sdate_time'] = date('Y-m-d H:i:s', $data['sdate']);
  58. $data['edate_time'] = date('Y-m-d H:i:s', $data['edate']);
  59. return $data;
  60. }
  61. # 获取相关推荐
  62. public function getRelation($info)
  63. {
  64. $where['noid'] = $info['id'];
  65. $where['cate_id'] = $info['cate_id'];
  66. return Dever::db('video/live')->getRelation($where);
  67. }
  68. # 增加浏览量
  69. public function addView($id)
  70. {
  71. Dever::db('video/live')->addView($id);
  72. }
  73. }