AddTranscodeUrlController.class.php 1.64 KB
<?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;
    }
}