PHP code example of jameswang / vod

1. Go to this page and download the library: Download jameswang/vod library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jameswang / vod example snippets

shell

wang\Vod\Vod;

$config = [
    'accessKeyId'=>"",
    'accessKeySecret'=>"",
];
$path = '/Users/james/Downloads/aa.mp4';

// $arg['title']        // 视频标题(必填参数)
// $arg['file_name']    // 视频源文件名称,必须包含扩展名(必填参数)
// $arg['description']  // 视频源文件描述(可选);
// $arg['cover_url']    // 自定义视频封面(可选)
// $arg['tag']          // 视频标签,多个用逗号分隔(可选)
$arg['title'] = '测试';
$arg['file_name'] = "aa.mp4";


$vod = new Vod($config);
//带文件上传
$result = $vod->oss_upload_video($arg,$path);

//只获取上传凭证
$result = $vod->reserve_upload_video($arg);

//获取播放凭证
//$result = $vod->get_play_video('xxxxx81f25e6490d9d76ec7101axxxxx');
shell
 

namespace App\Repositories;

use Jameswang\Vod\Vod;

class Reserve
{

     private $vod;
    
     public function __construct(Vod $vod)
     {
        $this->vod = $vod;
     }
    
     public function reserveVideo($arg)
     {
         // $arg['title']        // 视频标题(必填参数)
         // $arg['file_name']    // 视频源文件名称,必须包含扩展名(必填参数)
         // $arg['description']  // 视频源文件描述(可选);
         // $arg['cover_url']    // 自定义视频封面(可选)
         // $arg['tag']          // 视频标签,多个用逗号分隔(可选)
         //$arg['title'] = 'demo';
         //$arg['file_name'] = 'demo.mp4';
         
         $res = $this->vod->reserve_upload_video($arg);

         return $res;

     }
     
     //获取播放凭证
     public function getPlayVideo($video_id)
     {
          
          $res = $this->vod->get_play_video($video_id);
          return $res;
     }
     


}