wesmiler 2 năm trước cách đây
mục cha
commit
a504ea3f2e
1 tập tin đã thay đổi với 10 bổ sung9 xóa
  1. 10 9
      app/Services/LiveService.php

+ 10 - 9
app/Services/LiveService.php

@@ -49,27 +49,28 @@ class LiveService extends BaseService
      * @param int $expireTime
      * @return array
      */
-    public function getLiveUrl($streamName, $appName='xlapp', $playType='flv',$expireTime=1440)
+    public function getLiveUrl($streamName, $appName='xlapp', $playType='rtmp',$expireTime=1440)
     {
         $playUrls = [];
         //未开启鉴权Key的情况下
         $pushDomain = ConfigService::make()->getConfigByCode('live_push_url');
         $playDomain = ConfigService::make()->getConfigByCode('live_play_url');
-        $pushKey = 'push_key2222';
-        $playKey = 'push_key666';
-//        $accessKey = ConfigService::make()->getConfigByCode('live_url_access_key');
+        $pushKey = ConfigService::make()->getConfigByCode('push_url_key');
+        $playKey = ConfigService::make()->getConfigByCode('play_url_key');
+        $timeStamp = time() + $expireTime * 60;
         if($pushKey==''){
             $pushUrl = 'rtmp://'.$pushDomain.'/'.$appName.'/'.$streamName;
-
-            $playUrls['rtmp'] = 'rtmp://'.$playDomain.'/'.$appName.'/'.$streamName;
-            $playUrls['flv'] = 'http://'.$playDomain.'/'.$appName.'/'.$streamName.'.flv';
-            $playUrls['hls'] = 'http://'.$playDomain.'/'.$appName.'/'.$streamName.'.m3u8';
         }else{
-            $timeStamp = time() + $expireTime * 60;
             $sstring = '/'.$appName.'/'.$streamName.'-'.$timeStamp.'-0-0-'.$pushKey;
             $md5hash = md5($sstring);
             $pushUrl = 'rtmp://'.$pushDomain.'/'.$appName.'/'.$streamName.'?auth_key='.$timeStamp.'-0-0-'.$md5hash;
+        }
 
+        if($playKey==''){
+            $playUrls['rtmp'] = 'rtmp://'.$playDomain.'/'.$appName.'/'.$streamName;
+            $playUrls['flv'] = 'http://'.$playDomain.'/'.$appName.'/'.$streamName.'.flv';
+            $playUrls['hls'] = 'http://'.$playDomain.'/'.$appName.'/'.$streamName.'.m3u8';
+        }else{
             $rtmpSstring = '/'.$appName.'/'.$streamName.'-'.$timeStamp.'-0-0-'.$playKey;
             $rtmpMd5hash = md5($rtmpSstring);
             $playUrls['rtmp'] = 'rtmp://'.$playDomain.'/'.$appName.'/'.$streamName.'?auth_key='.$timeStamp.'-0-0-'.$rtmpMd5hash;