本文为您介绍如何查询和更新媒体基本信息。
功能使用
媒体处理支持通过SDK或API查询和更新媒体基本信息。SDK安装,请参见Java SDK、Python SDK、PHP SDK,示例代码参见下文。如需通过API使用功能,具体接口信息请参见直接调用API处理媒体基本信息。
说明
本文以PHP语言为例。
SDK调用API处理媒体基本信息
查询媒体基本信息
媒体处理提供2种查询方式查询媒体基本信息:通过媒体ID查询、通过OSS文件地址查询。
使用媒体ID查询媒体基本信息
说明如需了解参数详细信息,请参考查询媒体-使用媒体ID。
<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\QueryMediaListRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * 正式环境下 建议 protocol = "HTTPS"; */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new QueryMediaListRequest([ "mediaIds" => "90accf1a2ccb5c5fbc99****" ]); $response = $client->queryMediaList($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
使用OSS文件地址查询媒体基本信息
说明OSS文件地址指媒体文件路径。例如:
http://example-bucket-****.oss-cn-hangzhou.aliyuncs.com/test/1****.mp4
。如需了解参数详细信息,请参考查询媒体-使用OSS文件地址。<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\QueryMediaListByURLRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * 正式环境下 建议 protocol = "HTTPS"; */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new QueryMediaListByURLRequest([ "fileURLs" => "http://<bucket name>.oss-cn-shanghai.aliyuncs.com/mps_input/video.mp4" ]); $response = $client->queryMediaListByURL($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
更新媒体属性
<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\UpdateMediaRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * 正式环境下 建议 protocol = "HTTPS"; */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new UpdateMediaRequest([ "mediaId" => "7ce3a1c225ef0670bc2****", "title" => "测试 updateMedia" ]); $response = $client->updateMedia($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
直接调用API处理媒体基本信息
说明
直接调用API是指直接在OpenAPI门户调用该接口请求查询或修改媒体基本信息。
下表为查询和更新媒体信息的对应接口。
功能 | 接口 |
查询媒体基本信息-使用媒体ID | |
查询媒体基本信息-使用OSS文件地址 | 说明 OSS文件地址指媒体文件路径。例如: |
(全量)更新媒体属性 | |
(单个)更新媒体属性 |
文档内容是否对您有帮助?