ApsaraVideo VOD supports retrieving playback URLs through two methods: event notifications and API/SDK calls.
Get URLs via event notifications
You can receive event notifications when a video stream is transcoded to a specific definition (StreamTranscodeComplete) or when all transcoded streams are generated (TranscodeComplete). The event notifications contain playback URLs. Save these URLs on your own server and retrieve them when a client requests playback.
This method is ideal for high-concurrency playback. By caching URLs on your server and pre-warming content with the purge and prefetch feature, you can scale to support millions of concurrent viewers. For more information, see Purge and prefetch.
Usage notes
The playback URLs obtained from event notifications are static URLs. If URL signing is enabled, you must generate a signed URL yourself.
If you disable or delete an old domain, you must replace it with the new domain when retrieving saved playback URLs.
If you have configured video encryption, the returned playback URL points to an encrypted stream that must be decrypted by the player for playback.
Get URLs through API/SDK calls
A VideoId is provided when you upload a media file to ApsaraVideo VOD. Call the GetPlayInfo operation to retrieve the playback URL by specifying the VideoId.
Usage notes
By default, this operation returns only the latest transcoded stream in each definition and format to ensure that the latest transcoded stream is played. When calling the GetPlayInfo API, you can set
ResultTypetoMultipleto retrieve all completed streams for the video.If you have enabled Alibaba Cloud proprietary cryptography, the video can only be played using the ApsaraVideo Player. By default, the GetPlayInfo API does not return privately encrypted streams. You can set
ResultTypetoMultipleto retrieve all completed streams, including encrypted ones.If you have enabled HLS encryption, the API returns the standard encrypted stream with priority for playback by default.
If you have configured tiered storage for your media files, calling this API will have the following behavior:
By default, if the storage class is Standard, the API returns the playback stream normally. If the storage class is a non-standard tier (such as Archive), the API will not return a playback stream. If the storage class for the source file is a non-standard tier, the API will return transcoded streams but not the source video stream.
You can set the
StorageClassfield within thePlayConfigparameter to request streams from a specified non-standard storage tier.
Workflow
The following diagram illustrates the workflow for retrieving a playback URL and playing the video, using a CDN-accelerated domain as an example.
The client sends a request to your application server to get a playback URL.
The server calls GetPlayInfo using the Server SDK to obtain the playback authorization.
ApsaraVideo VOD returns the playback URL to the server.
The server returns the playback URL to the client.
The client player requests media resource based on the returned playback URL.
If the resource is not cached on the CDN POP or the cache has expired, the CDN performs an origin-pull from the OSS bucket.
The OSS bucket returns the resource to the CDN POP, which then caches the resource.
The CDN POP serves the media resource to the client.
What to do next
You can integrate the ApsaraVideo Player SDK on the client side to play videos using the URL. For more information, see ApsaraVideo Player SDK overview.