Tüm Ürünler
Search
Belge Merkezi

ApsaraVideo VOD:Medya varlık yönetimi

Son Güncelleme:Oct 05, 2026

Bu konuda, medya yönetimi modülünün API işlemlerinin nasıl kullanılacağına ilişkin örnekler sunulur. Bu API işlemleri ApsaraVideo VOD SDK for Java içinde kapsüllenmiştir. Medya varlığı bilgilerini aramak, video bilgilerini değiştirmek ve kaynak dosya bilgilerini sorgulamak için bu API işlemlerini çağırabilirsiniz. Ayrıca videoları ve görselleri sorgulayıp silebilirsiniz.

Kullanım notları

  • Bu konudaki tüm örneklerde bir istemci örneğini başlatmak için AccessKey çifti kullanılır.

  • İstek ve yanıt parametrelerinin ayrıntıları için Alibaba Cloud OpenAPI Explorer adresini ziyaret edin ve API Documentations sekmesini açın.

  • Diğer API işlemlerine yönelik SDK örnekleri için Alibaba Cloud OpenAPI Explorer adresini ziyaret edin. Parameters sekmesinde parametreleri belirtin ve çağrıyı başlatın. Ardından kodu görüntülemek ve indirmek için SDK Sample Code sekmesinden SDK sürümünü ve dili seçin.

  • Bu konudaki örnekler SDK V1.0 sürümünü kullanır. V2.0 örnekleri için OpenAPI Explorer'da doğru SDK sürümünü seçin.

İstemciyi başlatma

SDK'yı kullanmadan önce bir istemci başlatın. Daha fazla bilgi için bkz. Başlatma.

Medya varlığı bilgilerini sorgulama

Medya varlığı bilgilerini sorgulamak için SearchMedia işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için SearchMedia bağlantısını tıklayın.

Örnek kod:

import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.EnvironmentVariableCredentialsProvider;
import com.aliyuncs.vod.model.v20170321.SearchMediaRequest;
import com.aliyuncs.vod.model.v20170321.SearchMediaResponse;

 /**
   * Obtain the AccessKey information.
   */
    public static DefaultAcsClient initVodClient() throws ClientException {
    String regionId = "cn-shanghai";  // Specify the region in which ApsaraVideo VOD is activated.
    // The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. 
    // We recommend that you do not save your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked. As a result, the security of all resources in your account is compromised. 
    // In this example, the system reads the AccessKey pair from environment variables to implement authentication for API access. Before you run the sample code, configure the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET. 
    DefaultProfile profile = DefaultProfile.getProfile(regionId, System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
    DefaultAcsClient client = new DefaultAcsClient(profile);
    return client;
}
/**
 * Search for media asset information.
 * @param client The client that sends a request.
 * @return SearchMediaResponse The information contained in the response.
 * @throws Exception
 */
public static SearchMediaResponse searchMedia(DefaultAcsClient client) throws Exception {
    SearchMediaRequest request = new SearchMediaRequest();
    request.setFields("Title,CoverURL,Status");
    request.setMatch("Status in ('Normal','Checking') and CreationTime = ('2018-07-01T08:00:00Z','2018-08-01T08:00:00Z')");
    request.setPageNo(1);
    request.setPageSize(10);
    request.setSearchType("video");
    request.setSortBy("CreationTime:Desc");
    return client.getAcsResponse(request);
}

// Sample request
public static void main(String[] argv) {
    DefaultAcsClient client = initVodClient();
    SearchMediaResponse response = new SearchMediaResponse();
    try {
        response = searchMedia(client);
        if (response.getMediaList() != null && response.getMediaList().size() > 0) {
            System.out.print("Total = " + response.getTotal() + "\n");
            System.out.print("ScrollToken = " + response.getScrollToken() + "\n");
            for (SearchMediaResponse.Media media : response.getMediaList()) {
                System.out.print("MediaId = " + media.getMediaId() + "\n");
                System.out.print("MediaType = " + media.getMediaType() + "\n");
                System.out.print("CreationTime = " + media.getCreationTime() + "\n");
                System.out.print("Title = " + media.getVideo().getTitle() + "\n");
                System.out.print("CoverURL = " + media.getVideo().getCoverURL() + "\n");
                System.out.print("Status = " + media.getVideo().getStatus() + "\n");
            }
        }
    } catch (Exception e) {
        System.out.print("ErrorMessage = " + e.getLocalizedMessage());
    }
    System.out.print("RequestId = " + response.getRequestId() + "\n");
}

Ses veya video dosyaları hakkında bilgi sorgulama

  • Bir ses veya video dosyası hakkında bilgi sorgulamak için GetVideoInfo işlemine çağrı yapabilirsiniz.

    Bu API işlemi hakkında daha fazla bilgi edinmek için GetVideoInfo bağlantısını tıklayın.

  • Birden çok ses veya video dosyası hakkında aynı anda bilgi sorgulamak için GetVideoInfos işlemine çağrı yapabilirsiniz.

    Bu API işlemi hakkında daha fazla bilgi edinmek için GetVideoInfos bağlantısını tıklayın.

Ses veya video dosyası hakkında bilgi değiştirme

Bir ses veya video dosyası hakkında bilgi değiştirmek için UpdateVideoInfo işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için UpdateVideoInfo bağlantısını tıklayın.

Birden çok ses veya video dosyası hakkında bilgi değiştirme

Birden çok ses veya video dosyası hakkında aynı anda bilgi değiştirmek için UpdateVideoInfos işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için UpdateVideoInfos bağlantısını tıklayın.

Örnek kod:

import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.EnvironmentVariableCredentialsProvider;
import com.aliyuncs.vod.model.v20170321.UpdateVideoInfosRequest;
import com.aliyuncs.vod.model.v20170321.UpdateVideoInfosResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

 /**
   * Obtain the AccessKey information.
   */
    public static DefaultAcsClient initVodClient() throws ClientException {
    String regionId = "cn-shanghai";  // Specify the region in which ApsaraVideo VOD is activated.
    // The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. 
    // We recommend that you do not save your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked. As a result, the security of all resources in your account is compromised. 
    // In this example, the system reads the AccessKey pair from environment variables to implement authentication for API access. Before you run the sample code, configure the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET. 
    DefaultProfile profile = DefaultProfile.getProfile(regionId, System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
    DefaultAcsClient client = new DefaultAcsClient(profile);
    return client;
}
/**
 * Modify information about multiple video files at a time.
 * @param client The client that sends a request.
 * @return UpdateVideoInfosResponse The information contained in the response.
 * @throws Exception
*/
public static UpdateVideoInfosResponse updateVideoInfos(DefaultAcsClient client) throws Exception {
    UpdateVideoInfosRequest request = new UpdateVideoInfosRequest();
    JSONArray updateContentArray = new JSONArray();
    JSONObject updateContent1 = new JSONObject();
    updateContent1.put("VideoId", "VideoId1");
    // updateContent1.put("Title", "new Title");
    // updateContent1.put("Tags", "new Tag1,new Tag2");
    updateContentArray.add((updateContent1));
    JSONObject updateContent2 = new JSONObject();
    updateContent2.put("VideoId", "VideoId2");
    // updateContent2.put("Title", "new Title");
    // updateContent2.put("Tags", "new Tag1,new Tag2");
    updateContentArray.add((updateContent2));
    request.setUpdateContent(updateContentArray.toJSONString());
    return client.getAcsResponse(request);
}

// Sample request
public static void main(String[] argv) {
    DefaultAcsClient client = initVodClient();
    UpdateVideoInfosResponse response = new UpdateVideoInfosResponse();
    try {
        response = updateVideoInfos(client);
        if (response.getNonExistVideoIds() != null && response.getNonExistVideoIds().size() > 0) {
            System.out.print("======nonexistent VideoIds : ======\n");
            for (String videoId : response.getNonExistVideoIds()) {
                System.out.print(videoId + "\n");
            }
        }
    } catch (Exception e) {
        System.out.print("ErrorMessage = " + e.getLocalizedMessage());
    }
    System.out.print("RequestId = " + response.getRequestId() + "\n");
}

Kaynak dosya bilgilerini sorgulama (indirme URL'si dahil)

Kaynak dosya bilgilerini sorgulamak için GetMezzanineInfo işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için GetMezzanineInfo bağlantısını tıklayın.

Ses ve video dosyalarını sorgulama

Ses ve video dosyalarını sorgulamak için GetVideoList işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için GetVideoList bağlantısını tıklayın.

Ses ve video dosyalarını silme

Ses ve video dosyalarını silmek için DeleteVideo işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için DeleteVideo bağlantısını tıklayın.

Medya akışlarını silme

Medya akışlarını silmek için DeleteStream işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için DeleteStream bağlantısını tıklayın.

Birden çok kaynak dosyayı silme

Birden çok kaynak dosyayı aynı anda silmek için DeleteMezzanines işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için DeleteMezzanines bağlantısını tıklayın.

Birden çok görsel hakkında bilgi değiştirme

Birden çok görsel hakkında aynı anda bilgi değiştirmek için UpdateImageInfos işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için UpdateImageInfos bağlantısını tıklayın.

Örnek kod:

import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.EnvironmentVariableCredentialsProvider;
import com.aliyuncs.vod.model.v20170321.UpdateImageInfosRequest;
import com.aliyuncs.vod.model.v20170321.UpdateImageInfosResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

 /**
   * Obtain the AccessKey information.
   */
    public static DefaultAcsClient initVodClient() throws ClientException {
    String regionId = "cn-shanghai";  // Specify the region in which ApsaraVideo VOD is activated.
    // The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. 
    // We recommend that you do not save your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked. As a result, the security of all resources in your account is compromised. 
    // In this example, the system reads the AccessKey pair from environment variables to implement authentication for API access. Before you run the sample code, configure the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET. 
    DefaultProfile profile = DefaultProfile.getProfile(regionId, System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
    DefaultAcsClient client = new DefaultAcsClient(profile);
    return client;
}
/**
 * Modify information about multiple images at a time.
 * @param client The client that sends a request.
 * @return UpdateImageInfosResponse The information contained in the response.
 * @throws Exception
*/
public static UpdateImageInfosResponse updateImageInfos(DefaultAcsClient client) throws Exception{
        UpdateImageInfosRequest request = new UpdateImageInfosRequest();
        JSONArray updateContentArray = new JSONArray();
        JSONObject updateContent1 = new JSONObject();
        updateContent1.put("ImageId", "ImageId1");
//        updateContent1.put("Title", "new Title");
//        updateContent1.put("Tags", "new Tag1,new Tag2");
        updateContentArray.add((updateContent1));
        JSONObject updateContent2 = new JSONObject();
        updateContent2.put("ImageId", "ImageId2");
//        updateContent2.put("Title", "new Title");
//        updateContent2.put("Tags", "new Tag1,new Tag2");
        updateContentArray.add((updateContent2));
        request.setUpdateContent(updateContentArray.toJSONString());
        return client.getAcsResponse(request);
    }

// Sample request
public static void main(String[] argv) throws Exception {
    DefaultAcsClient client = initVodClient();
    UpdateImageInfosResponse response = new UpdateImageInfosResponse();
    try {
        response = updateImageInfos(client);
        if (response.getNonExistImageIds() != null && response.getNonExistImageIds().size() > 0) {
            System.out.print("======nonexistent ImageIds : ======\n");
            for (String imageId : response.getNonExistImageIds()) {
                System.out.print(imageId + "\n");
            }
        }
    } catch (Exception e) {
        System.out.print("ErrorMessage = " + e.getLocalizedMessage());
    }
    System.out.print("RequestId = " + response.getRequestId() + "\n");
}

Görsel hakkında bilgi sorgulama

Bir görsel hakkında bilgi sorgulamak için GetImageInfo işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için GetImageInfo bağlantısını tıklayın.

Görselleri silme

Görselleri silmek için DeleteImage işlemine çağrı yapabilirsiniz.

Bu API işlemi hakkında daha fazla bilgi edinmek için DeleteImage bağlantısını tıklayın.

Örnek kod:

import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.EnvironmentVariableCredentialsProvider;
import com.aliyuncs.vod.model.v20170321.DeleteImageRequest;
import com.aliyuncs.vod.model.v20170321.DeleteImageResponse;

 /**
   * Obtain the AccessKey information.
   */
    public static DefaultAcsClient initVodClient() throws ClientException {
    String regionId = "cn-shanghai";  // Specify the region in which ApsaraVideo VOD is activated.
    // The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. 
    // We recommend that you do not save your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked. As a result, the security of all resources in your account is compromised. 
    // In this example, the system reads the AccessKey pair from environment variables to implement authentication for API access. Before you run the sample code, configure the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET. 
    DefaultProfile profile = DefaultProfile.getProfile(regionId, System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
    DefaultAcsClient client = new DefaultAcsClient(profile);
    return client;
}
/**
 * Delete images.
 *
 * @param client The client that sends a request.
 * @return DeleteImageResponse The information contained in the response.
 * @throws Exception
*/
public static DeleteImageResponse deleteImage(DefaultAcsClient client) throws Exception {
    DeleteImageRequest request = new DeleteImageRequest();
    // Delete image files based on ImageURL.
    request.setDeleteImageType("ImageURL");
    // Example of ImageURL: http://example.aliyundoc.com/cover-****.jpg.
    String url = "<your image URL>";
    String encodeUrl = URLEncoder.encode(url, "UTF-8");
    request.setImageURLs(encodeUrl);
    // Delete image files based on ImageId.
    //request.setDeleteImageType("ImageId");
    //request.setImageIds("ImageId1,ImageId2");
    // Delete image files of a specified type based on VideoId.
    //request.setDeleteImageType("VideoId");
    //request.setVideoId("VideoId");
    //request.setImageType("SpriteSnapshot");
    return client.getAcsResponse(request);
}

// Sample request
public static void main(String[] argv) throws ClientException {
    DefaultAcsClient client = initVodClient();
    DeleteImageResponse response = new DeleteImageResponse();
    try {
        response = deleteImage(client);
    } catch (Exception e) {
        System.out.print("ErrorMessage = " + e.getLocalizedMessage());
    }
    System.out.print("RequestId = " + response.getRequestId() + "\n");
}