AddTranscodeUrlController.class.php
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* 新增视频转码文件回调数据
*/
namespace Apicp\Controller\Attachment;
use Common\Common\Constant;
use VcySDK\FileConvert;
use VcySDK\Service;
class AddTranscodeUrlController extends AbstractController
{
/**
* AddTranscodeUrl
*
* @author heyuelong
* @desc 视频转换接口
*
* @param String fileId 视频ID
* @param String title 视频名字
* @param String qtnFilesize 文件大小
*
* @return array
*/
public function Index()
{
$fileId = I('post.fileId');
$title = I('post.title');
$qtnFilesize = I('post.qtnFilesize');
$qcloudServ = new FileConvert(Service::instance());
$result = $qcloudServ->add([
'qtnFileId' => $fileId,
'qtnNotifyUrl' => ''
]);
if ($result['code'] == 'SUCCESS') {
$data = [
'title' => $this->dealPrefix($title),
'source_type' => Constant::SOURCE_TYPE_VEDIO,
'source_status' => Constant::SOURCE_STATUS_CONVERT,
'at_id' => $fileId,
'at_type' => Constant::ATTACH_TYPE_VIDEO,
'at_url' => '',
'at_name' => $title,
'at_size' => $qtnFilesize
];
$source_id = $this->saveAtt($data);
}
$this->_result = [
'source_id' => $source_id
];
return true;
}
//去除标题末尾后缀
public function dealPrefix($title)
{
$deal_title = explode('.', $title);
array_pop($deal_title);
$title=implode('.',$deal_title);
return $title;
}
}