All Products
Search
Document Center

Media asset management

Last Updated: Jul 11, 2019

Initialize a client

Initialize a client before using the SDK. For more information, see InitVodClient.

Search for media asset information

For more information about the request and response parameters, see SearchMedia.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.SearchMedia
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                SearchMediaRequest request = new SearchMediaRequest();
                request.SearchType = "video";
                request.Fields = "Title,CoverURL,Status";
                request.Match = "Status in ('Normal','Checking') and CreationTime = ('2018-07-01T08:00:00Z','2018-08-01T08:00:00Z')";
                request.PageNo = 1;
                request.PageSize = 10;
                request.SearchType = "video";
                request.SortBy = "CreationTime:Desc";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                SearchMediaResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.MediaList ! = null && response.MediaList.Count > 0) 
                {
                    Console.WriteLine("Total = " + response.Total + "\n");
                    Console.WriteLine("ScrollToken = " + response.ScrollToken + "\n");
                    foreach (var media in response.MediaList)
                    {
                        Console.WriteLine("MediaId = " + media.MediaId + "\n");
                        Console.WriteLine("MediaType = " + media.MediaType + "\n");
                        Console.WriteLine("CreationTime = " + media.CreationTime + "\n");
                        Console.WriteLine("Title = " + media.Video.Title + "\n");
                        Console.WriteLine("CoverURL = " + media.Video.CoverURL + "\n");
                        Console.WriteLine("Status = " + media.Video.Status + "\n");
                    }
                }
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Obtain video information

For more information about the request and response parameters, see GetVideoInfo.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetVideoInfo
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                GetVideoInfoRequest request = new GetVideoInfoRequest();
                request.VideoId = "<Your video ID>";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetVideoInfoResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                Console.WriteLine("Title = " + response.Video.Title);
                Console.WriteLine("CoverURL = " + response.Video.CoverURL);
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Obtain the information about multiple videos

For more information about the request and response parameters, see GetVideoInfos.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetVideoInfos
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                GetVideoInfosRequest request = new GetVideoInfosRequest();
                request.VideoIds = "VideoId1,VideoId2";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetVideoInfosResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.NonExistVideoIds ! = null && response.NonExistVideoIds.Count > 0) 
                {
                    foreach (var videoId in response.NonExistVideoIds) {
                        Console.WriteLine("NonExist videoId = " + videoId);
                    }
                }
                if (response.VideoList ! = null && response.VideoList.Count > 0)
                {
                    foreach (var video in response.VideoList)
                    {
                        Console.WriteLine("MediaId = " + video.VideoId);
                        Console.WriteLine("Title = " + video.Title);
                        Console.WriteLine("CreationTime = " + video.CreationTime);
                        Console.WriteLine("CoverURL = " + video.CoverURL);
                        Console.WriteLine("Status = " + video.Status);
                    }
                }
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Modify video information

For more information about the request and response parameters, see UpdateVideoInfo.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.UpdateVideoInfo
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                UpdateVideoInfoRequest request = new UpdateVideoInfoRequest();
                request.VideoId = "<Your video ID>";
                request.Title = "new Title";
                request.Description = "new Description";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                UpdateVideoInfoResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Modify the information about multiple videos

For more information about the request and response parameters, see UpdateVideoInfos.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.UpdateVideoInfos
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                UpdateVideoInfosRequest request = new UpdateVideoInfosRequest();
                request.UpdateContent = "[{\"VideoId\":\"VideoId1\",\"Title\":\"new Title\"},{\"VideoId\":\"VideoId2\",\"Description\":\"new Description\"}]";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                UpdateVideoInfosResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.NonExistVideoIds ! = null && response.NonExistVideoIds.Count > 0)
                {
                    foreach (var videoId in response.NonExistVideoIds)
                    {
                        Console.WriteLine("NonExist videoId = " + videoId);
                    }
                }
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Delete videos

For more information about the request and response parameters, see DeleteVideo.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.DeleteVideo
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                DeleteVideoRequest request = new DeleteVideoRequest();
                request.VideoIds = "VideoId1,VideoId2";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                DeleteVideoResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Obtain mezzanine file information (including the mezzanine file download URL)

For more information about the request and response parameters, see GetMezzanineInfo.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetMezzanineInfo
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                GetMezzanineInfoRequest request = new GetMezzanineInfoRequest();
                request.VideoId = "f45cf4eba5c84d25b290233389558c39";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetMezzanineInfoResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                Console.WriteLine("FileURL = " + response.Mezzanine.FileURL);
                Console.WriteLine("Duration = " + response.Mezzanine.Duration);
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Obtain a video list

For more information about the request and response parameters, see GetVideoList.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.Sample
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                GetVideoListRequest request = new GetVideoListRequest();
                // Sets the start time to one month ago (in UTC) and the end time to the current time (in UTC) for filtering videos.
                request.StartTime = DateTime.UtcNow.AddMonths(-2).ToString("yyyy-MM-ddTHH:mm:ssZ");
                request.EndTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
                request.Status = "Normal,Checking";
                request.PageNo = 1;
                request.PageSize = 20;
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetVideoListResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                foreach (var videoInfo in response.VideoList)
                {
                    Console.WriteLine("VideoList.VideoId = " + videoInfo.VideoId);
                    Console.WriteLine("VideoList.Title = " + videoInfo.Title);
                }
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Delete media streams

For more information about the request and response parameters, see DeleteStream.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.Sample
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                DeleteStreamRequest request = new DeleteStreamRequest();
                request.VideoId = "<Your video ID>";
                request.JobIds = "JobId1,JobId2";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                DeleteStreamResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Delete multiple mezzanine files

For more information about the request and response parameters, see DeleteMezzanines.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.DeleteMezzanines
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                DeleteMezzaninesRequest request = new DeleteMezzaninesRequest();
                // Specifies one or more IDs of the videos to be deleted.
                request.VideoIds = "VideoId1,VideoId2";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                DeleteMezzaninesResponse response = client.GetAcsResponse(request);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.NonExistVideoIds ! = null && response.NonExistVideoIds.Count > 0) 
                {
                    foreach (var videoId in response.NonExistVideoIds)
                    {
                        Console.WriteLine("NonExist videoId = " + videoId);
                    }
                }
                if (response.UnRemoveableVideoIds ! = null && response.UnRemoveableVideoIds.Count > 0) 
                {
                    foreach (var videoId in response.UnRemoveableVideoIds)
                    {
                        Console.WriteLine("UnRemoveable videoId = " + videoId);
                    }
                }
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Update the information about multiple images

For more information about the request and response parameters, see UpdateImageInfos.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.UpdateImageInfos
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                UpdateImageInfosRequest request = new UpdateImageInfosRequest();

                request.UpdateContent = "[{\"ImageId\":\"ImageId1\",\"Title\":\"new Title\"},{\"ImageId\":\"ImageId2\",\"Description\":\"new Description\"}]";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                UpdateImageInfosResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.NonExistImageIds ! = null && response.NonExistImageIds.Count > 0) 
                {
                    foreach (var imageId in response.NonExistImageIds)
                    {
                        Console.WriteLine("NonExist ImageId = " + imageId);
                    }
                }
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Obtain image information

For more information about the request and response parameters, see GetImageInfo.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetImageInfo
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                GetImageInfoRequest request = new GetImageInfoRequest();
                // Sets the image ID.
                request.ImageId = "ImageId";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetImageInfoResponse response = client.GetAcsResponse(request);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.ImageInfo ! = null)
                {
                    Console.WriteLine("ImageId = " + response.ImageInfo.ImageId);
                    Console.WriteLine("ImageType = " + response.ImageInfo.ImageType);
                    Console.WriteLine("Title = " + response.ImageInfo.Title);
                }
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Delete images

For more information about the request and response parameters, see DeleteImage.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.DeleteImage
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                DeleteImageRequest request = new DeleteImageRequest();
                // Deletes image files based on image URLs.
                request.DeleteImageType = "ImageURL";
                request.ImageURLs = "http://sample.aliyun.com/cover.jpg";
                // Deletes image files based on image IDs.
                //request.DeleteImageType = "ImageId";
                //request.ImageIds = "ImageId1,ImageId2";
                // Deletes image files of the specified image type based on a video ID.
                //request.DeleteImageType = "VideoId";
                //request.VideoId = "VideoId";
                //request.ImageType = "SpriteSnapshot";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                DeleteImageResponse response = client.GetAcsResponse(request);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}