You can use a server-side SDK to call the SearchMedia operation and search for media assets in Intelligent Media Services. This topic provides sample code in Java.
Usage notes
You can filter media assets by title, media asset ID, classification, and status. You can also specify the sort field and sort order for the results.
Sample code
For online debugging, visit the Alibaba Cloud OpenAPI Developer Portal.
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import Credential, { Config } from '@alicloud/credentials';
const Client = require('@alicloud/ice20201109').default;
// An AccessKey of an Alibaba Cloud account has access permissions to all API operations. For better security, use a Resource Access Management (RAM) user to make API calls or perform daily O&M.
// This example shows how to store an AccessKey ID and an AccessKey secret in environment variables. For information about how to configure them, see https://help.aliyun.com/document_detail/378664.html
const cred = new Credential();
const iceClient = new Client(new $OpenApi.Config({
credential: cred,
endpoint: 'ice.cn-shanghai.aliyuncs.com'
}));
// To hard-code the AccessKey ID and AccessKey secret, use the following code. However, do not hard-code the AccessKey ID and AccessKey secret in your project code. Hard coding may cause an AccessKey leak and threaten the security of all resources in your account.
// const iceClient = new Client(new $OpenApi.Config({
// accessKeyId: '<yourAccessKeyId>',
// accessKeySecret: '<yourAccessKeySecret>',
// endpoint: 'ice.cn-shanghai.aliyuncs.com'
// }));
iceClient.searchMedia({
match : "title = 'player' and mediaType = ('0','3')"
}).then(function (data) {
console.log(data.body);
}, function (err) {
console.log('Error:' + err);
});
Related API operation
该文章对您有帮助吗?