Browse Source

视频缩略图

lizhen_gitee 1 year ago
parent
commit
497176735a
2 changed files with 22 additions and 0 deletions
  1. 14 0
      application/api/controller/Video.php
  2. 8 0
      application/api/controller/coach/Video.php

+ 14 - 0
application/api/controller/Video.php

@@ -26,6 +26,14 @@ class Video extends Api
         $list = Db::name('video')->where('createtime','>',$starttime)->where('is_show',1)->order('weigh desc')->autopage()->select();
         $list = list_domain_image($list,['video_file']);
 
+        if(!empty($list)){
+            foreach($list as $key => $val){
+                if(!empty($val['video_file'])){
+                    $list[$key]['thumb_image'] = $val['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast';
+                }
+            }
+        }
+
         $this->success(1,$list);
     }
 
@@ -35,6 +43,12 @@ class Video extends Api
         $info = Db::name('video')->where('id',$id)->find();
         $info = info_domain_image($info,['video_file']);
 
+        if(!empty($info)){
+            if(!empty($info['video_file'])){
+                $info['thumb_image'] = $info['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast';
+            }
+        }
+
         $this->success(1,$info);
     }
 }

+ 8 - 0
application/api/controller/coach/Video.php

@@ -19,6 +19,14 @@ class Video extends Apic
         $list = Db::name('video')->where('coach_id',$this->auth->id)->autopage()->order('id desc')->select();
         $list = list_domain_image($list,['video_file']);
 
+        if(!empty($list)){
+            foreach($list as $key => $val){
+                if(!empty($val['video_file'])){
+                    $list[$key]['thumb_image'] = $val['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast';
+                }
+            }
+        }
+
         $this->success(1,$list);
     }