如果您不知道媒體ID(直播走工作流程轉點播),可以通過媒體的輸入地址進行媒體資訊的查詢,介面為 QueryMediaListByURL。
<?php
namespace AlibabaCloud\SDK\Sample;
use AlibabaCloud\SDK\Mts\V20140618\Mts;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Mts\V20140618\Models\QueryMediaListByURLRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
class Sample {
/**
* 使用AK&SK初始化帳號Client
* @return Mts Client
*/
public static function createClient(){
$config = new Config([
// 必填,請確保代碼運行環境設定了環境變數 ALIBABA_CLOUD_ACCESS_KEY_ID。
"accessKeyId" => getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"),
// 必填,請確保代碼運行環境設定了環境變數 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
"accessKeySecret" => getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
]);
$config->endpoint = "mts.cn-hangzhou.aliyuncs.com";
return new Mts($config);
}
/**
* @param string[] $args
* @return void
*/
public static function main($args){
$client = self::createClient();
$queryMediaListByURLRequest = new QueryMediaListByURLRequest([
//需要查詢的媒體檔案地址
"fileURLs" => "http://example-bucket-****.oss-cn-shanghai.aliyuncs.com/example.mp4",
//返回結果中是否包含播放資訊
"includePlayList" => true,
//返回結果中是否包含截圖資訊
"includeSnapshotList" => true,
//返回結果中是否包含媒體資訊
"includeMediaInfo" => true,
//返回結果中是否包含摘要列表
"includeSummaryList" => true
]);
$runtime = new RuntimeOptions([]);
try {
// 複製代碼運行請自行列印 API 的傳回值
$client->queryMediaListByURLWithOptions($queryMediaListByURLRequest, $runtime);
}
catch (Exception $error) {
if (!($error instanceof TeaError)) {
$error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
}
// 此處僅做列印展示,請謹慎對待異常處理,在工程專案中切勿直接忽略異常。
// 錯誤 message
var_dump($error->message);
// 診斷地址
var_dump($error->data["Recommend"]);
Utils::assertAsString($error->message);
}
}
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
require_once $path;
}
Sample::main(array_slice($argv, 1));