dever 6 years ago
parent
commit
199f886860
6 changed files with 100 additions and 23 deletions
  1. 19 0
      common.php
  2. 6 2
      doc/apidoc.php
  3. 42 1
      journal/database/content.php
  4. 18 1
      journal/database/info.php
  5. 14 2
      main/src/Journal.php
  6. 1 17
      video/lib/Vod.php

+ 19 - 0
common.php

@@ -14,4 +14,23 @@ function checkVersion()
     }
 
     return (object) array('video' => $video, 'journal_buy' => $journal_buy);
+}
+
+/**
+ * 音视频转换
+ */
+function convert($url, $ext = 'mp4', $table = false, $id = false, $col = '')
+{
+    if ($url && !strstr($url, '_c.' . $ext)) {
+        $file = $url . '_c.' . $ext;
+        if (Dever::is_file($file)) {
+            $url = $file;
+
+            if ($table) {
+                Dever::db($table)->update(array('where_id' => $id, $col => $file));
+            }
+        }
+    }
+
+    return $url;
 }

+ 6 - 2
doc/apidoc.php

@@ -675,7 +675,8 @@
  * @apiSuccess {String}   journal.num_ding 订阅数
  * @apiSuccess {String}   journal.num_view 浏览量
  * @apiSuccess {String}   journal.num_comment 评论量
- * @apiSuccess {String}   journal.buy 小刊是否收费 1收费 2不收费
+ * @apiSuccess {String}   journal.buy 小刊是否收费 1收费 2免费 3会员
+ * @apiSuccess {String}   journal.bgmusic 小刊背景音乐
  *
  * @apiSuccess {Object[]} subscribe 订阅列表
  * @apiSuccess {String}   subscribe.id 
@@ -723,7 +724,10 @@
  *
  * @apiSuccess {Object[]} content 内容数据列表,每页显示10条,请在翻到第7或者第8条时,请求第2
  * @apiSuccess {String}   content.id 内容id
- * @apiSuccess {String}   content.type 内容类型1全屏图、2长图、3图文内容、11关联图文、12关联视频、13关联直播
+ * @apiSuccess {String}   content.type 内容类型1全屏图、2长图、3图文内容、11关联图文、12关联视频、13关联直播、4全屏视频、5留言视频、6留言音频
+ * @apiSuccess {String}   content.name 标题。type=5,6时有效
+ * @apiSuccess {String}   content.video 视频地址。type=4,5时有效
+ * @apiSuccess {String}   content.music 音频地址。type=6时有效
  * @apiSuccess {String}   content.pic 全屏图或者长图,type=1,2时有效
  * @apiSuccess {String}   content.is_button 全屏图上的保存按钮,1显示2不显示,type=1时有效
  * @apiSuccess {String}   content.button_name 全屏图上的保存按钮的文字,type=1时有效

+ 42 - 1
journal/database/content.php

@@ -2,9 +2,16 @@
 
 $type = array
 (
+    # 默认类型
     3 => '图文内容',
     1 => '全屏图',
     2 => '长图',
+    # 2018-12-11 增加3个类型
+    4 => '全屏视频',
+    5 => '留言视频',
+    6 => '留言音频',
+
+    # 关联类型 > 10
     11 => '关联图文',
     12 => '关联视频',
     13 => '关联直播',
@@ -109,7 +116,41 @@ return array
             'list'      => true,
             //增加预览
             'preview'   => true,
-            'show'      => 'type=3',      
+            'show'      => 'type=3,5,6',      
+        ),
+
+        'video'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '上传视频-视频格式mp4,mov,上传大小不能超过4G',
+            'default'   => '',
+            'desc'      => '上传点播视频',
+            'match'     => 'is_string',
+            'update'    => 'upload',
+            'key'       => '3',
+            'place'     => '150',
+            'upload'    => 'qiniu',
+            'large'     => true,
+            //不覆盖原文件,生成新文件
+            'cover'     => 2,
+            'show'      => 'type=4,5',      
+        ),
+
+        'music'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '上传音频-视频格式mp3,上传大小不能超过100M',
+            'default'   => '',
+            'desc'      => '上传音频',
+            'match'     => 'is_string',
+            'update'    => 'upload',
+            'key'       => '2',
+            'place'     => '150',
+            'upload'    => 'qiniu',
+            'large'     => true,
+            //不覆盖原文件,生成新文件
+            'cover'     => 2,
+            'show'      => 'type=6',      
         ),
 
         'focus'     => array

+ 18 - 1
journal/database/info.php

@@ -37,12 +37,13 @@ $buy = array
 (
 	1 => '收费',
 	2 => '免费',
+	3 => '会员',
 );
 
 $page = 15;
 
 # 常用的col
-$col = 'id,name,subname,pic_cover,pic_view_cover,pic_view_bg,pdate,num_add_view+num_view as num_view,num_ding+num_add_ding as num_ding,num_comment,buy,share_yes,share_title,share_pic,share_content,pic_gd,cate_id,cash';
+$col = 'id,name,subname,pic_cover,pic_view_cover,pic_view_bg,pdate,num_add_view+num_view as num_view,num_ding+num_add_ding as num_ding,num_comment,buy,share_yes,share_title,share_pic,share_content,pic_gd,cate_id,cash,bgmusic';
 
 return array
 (
@@ -161,6 +162,22 @@ return array
 			'place'		=> '150',
 		),
 
+		'bgmusic'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '背景音乐-音频格式mp3,上传大小不能超过100M',
+			'default' 	=> '',
+			'desc' 		=> '背景音乐',
+			'match' 	=> 'option',
+			'update'	=> 'upload',
+			'key' 		=> '2',
+			'place'		=> '150',
+			'upload'	=> 'qiniu',
+			'large' 	=> true,
+			//不覆盖原文件,生成新文件
+			'cover'		=> 2,
+		),
+
 		'num_add_ding'		=> array
 		(
 			'type' 		=> 'int-11',

+ 14 - 2
main/src/Journal.php

@@ -343,16 +343,19 @@ class Journal extends Core
     public function read()
     {
         if (!$this->data['uid']) {
-            //Dever::alert('错误的用户信息');
+            Dever::alert('错误的用户信息');
         }
         # 验证是否可以阅读
         $id = $this->check();
         $this->data['info'] = $this->info($this->data['info'], false);
 
+        # 是否转码
+        //$this->data['info']['bgmusic'] = convert($this->data['info']['bgmusic'], 'mp3', 'journal/info', $this->data['info']['id'], 'bgmusic');
+
         $subscribe = Dever::load('act/lib/subscribe')->get($id, $this->data['uid'], 4);
 
         if ($this->data['info']['buy'] == 1 && $subscribe == 2) {
-            //Dever::alert('未订阅');
+            Dever::alert('未订阅');
         }
 
         if ($this->data['info']['buy'] == 2) {
@@ -414,6 +417,15 @@ class Journal extends Core
             $info['info']['author_id'] = $author_id;
             $info['info']['content'] = $content;
             $info['info'] = Dever::load('content/lib/article')->getContent($info['info']);
+        } elseif ($info['type'] == 4 || $info['type'] == 5) {
+            $info['video'] = convert($info['video'], 'mp4', 'journal/content', $info['id'], 'video');
+            if ($info['type'] == 5) {
+                $info['name'] = $name;
+            }
+        } elseif ($info['type'] == 6) {
+            $info['name'] = $name;
+            //音频先不转码
+            //$info['music'] = convert($info['music'], 'mp3', 'journal/content', $info['id'], 'music');
         } elseif ($info['type'] == 11) {
             $info['info'] = Dever::load('content/lib/article')->get($info['article_id']);
         } elseif ($info['type'] == 12) {

+ 1 - 17
video/lib/Vod.php

@@ -18,27 +18,11 @@ class Vod
     
         $data['content'] = Dever::filter($data['content']);
 
-        $data['video'] = $this->convert($data['video'], 'mp4', 'video/vod', $data['id'], 'video');
+        $data['video'] = convert($data['video'], 'mp4', 'video/vod', $data['id'], 'video');
 
         return $data;
     }
 
-    public function convert($url, $ext = 'mp4', $table = false, $id = false, $col = '')
-    {
-        if ($url && !strstr($url, '_c.' . $ext)) {
-            $file = $url . '_c.' . $ext;
-            if (Dever::is_file($file)) {
-                $url = $file;
-
-                if ($table) {
-                    Dever::db($table)->update(array('where_id' => $id, $col => $file));
-                }
-            }
-        }
-
-        return $url;
-    }
-
 
     # 获取相关推荐
     public function getRelation($info)