Fast-loading full-screen playback
Combine ApsaraVideo Player SDK preloading and video thumbnails to achieve millisecond-level startup, eliminating slow loading and stuttering in short video scenarios.
Solution overview
Video playback may show a black screen during initial loading. To eliminate this, enable preloading in ApsaraVideo Player to fetch video data in advance, and set the first frame as the thumbnail so it displays immediately while the video buffers. This delivers seamless playback with no visible delay.
You can use the solution to shorten the average startup time to about 300 milliseconds in a Wi-Fi environment.
Limits
-
Only ApsaraVideo Player SDK for Android and iOS supports fast-loading full-screen playback.
-
You can preload only one MP4, MP3, FLV, or HLS file at a time.
-
Play preloaded videos with UrlSource only. VidAuth and VidSts are not supported for preloaded playback.
Prerequisites
ApsaraVideo VOD is activated. For more information, see Activate ApsaraVideo VOD.
-
ApsaraVideo Player SDK is integrated. Quick integration of ApsaraVideo Player SDK for Android | Quick integration of ApsaraVideo Player SDK for iOS
-
A CDN domain name is configured for the prefetch feature in ApsaraVideo VOD. Add a domain name for CDN
Step 1: Enable the preload feature in ApsaraVideo Player SDK
Preloading fetches video data to the local device before playback starts, reducing startup time.
Limits
-
Currently supports loading single media files such as MP4, MP3, FLV, and HLS.
Android player configuration
-
Enable the local caching feature.
To enable the local caching feature, call
AliPlayerGlobalSettings.enableLocalCachein the/app/src/main/java/com/aliyun/alivcsolution/MutiApplication.javafile.public class MutiApplication extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } @Override public void onCreate() { super.onCreate(); // Enable the local caching feature. The path that the cache is stored must be an absolute path. Example: /tmp. The maxBufferMemoryKB parameter in the following sample code is deprecated in ApsaraVideo Player SDK V5.4.7.1 and later and does not take effect. AliPlayerGlobalSettings.enableLocalCache(true,10240,"/tmp"); } } -
Create a preload instance. Configure a callback for the preload status during instance initialization.
This is defined in
/AliyunListPlayer/src/main/java/com/aliyun/player/aliyunlistplayer/AliyunListPlayerActivity.java.public class AliyunListPlayerActivity extends AppCompatActivity { private AliyunListPlayerView mListPlayerView; private NetWatchdog mNetWatchDog; private String mUserToken; private boolean mIsLoadMore = false; private int mLastVideoId = -1; private ImageView mBackImageView; // Create a singleton for preloading. private MediaLoader medialoader=MediaLoader.getInstance(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_aliyun_list_player); mUserToken = getIntent().getStringExtra("list_player_user_token"); initView(); initSts(true); initListener(); // Set the callback for the loading status. medialoader.setOnLoadStatusListener(new MediaLoader.OnLoadStatusListener() { @Override public void onError(String url, int code, String msg) { // An error occurred during loading. } @Override public void onCompleted(String s) { // The loading is complete. } @Override public void onCanceled(String s) { // The loading is canceled. } }); } ... -
When you respond to a data request, call the
loadfunction to preload and store data to the specified disk path.private void getDatas(int id){ GetVideoInfomation getVideoInfomation = new GetVideoInfomation(); getVideoInfomation.getListPlayerVideoInfos(this, "1", mUserToken, id, new GetVideoInfomation.OnGetListPlayerVideoInfosListener() { private SparseArray<String> mSparseArray; @Override public void onGetSuccess(Request request, String result) { // The demo list player uses only video IDs to request video data. // However, you can preload videos only using URLs, not video IDs. // The following code provides an example of how to use medialoader to preload a video after you obtain its URL. String url="";// Assume that you have obtained the video URL. medialoader.load(url,10000);// Preload data and save it to a specified disk path. The loading duration is 10,000 milliseconds. Gson gson = new Gson(); AliyunVideoListBean aliyunVideoListBean = gson.fromJson(result, AliyunVideoListBean.class); ...
Configure ApsaraVideo Player SDK for iOS
-
Enable the local caching feature and configure a callback for the preload status during instance initialization.
- (AliPlayer *)aliPlayer{ if (!_aliPlayer && UIApplicationStateActive == [[UIApplication sharedApplication] applicationState]) { _aliPlayer = [[AliPlayer alloc] init]; _aliPlayer.scalingMode = AVP_SCALINGMODE_SCALEASPECTFIT; _aliPlayer.rate = 1; _aliPlayer.delegate = self; _aliPlayer.playerView = self.playerView; // Enable local caching. The local cache file path must be a sandbox path. The maxBufferMemoryKB parameter is deprecated in v5.4.7.1 and later and has no effect. NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; [AliPlayerGlobalSettings enableLocalCache:YES maxBufferMemoryKB:10*1024 localCacheDir:[docDir stringByAppendingPathComponent:@"alivcCache"]]; [AliPlayerGlobalSettings setCacheFileClearConfig:30*60*24 maxCapacityMB:20480 freeStorageMB:0]; // Set the URL callback method to prevent preload failures that occur when the preload URL and playback URL are inconsistent due to parameter changes. [AliPlayerGlobalSettings setCacheUrlHashCallback:hashCallback]; // Set the callback delegate. [[AliMediaLoader shareInstance] setAliMediaLoaderStatusDelegate:self]; } return _aliPlayer; } // The URL callback method. NSString* hashCallback(NSString* url){ NSString *md5Str = [NSString aliyun_MD5:url]; return md5Str; } // Callback methods for preloading. #pragma mark -- AliMediaLoaderStatusDelegate /** @brief The error callback. @param url The URL to load. @param code The error code. @param msg The error description. */ - (void)onError:(NSString *)url code:(int64_t)code msg:(NSString *)msg { } /** @brief The completion callback. @param url The loaded URL. */ - (void)onCompleted:(NSString *)url { } /** @brief The cancellation callback. @param url The URL whose loading was canceled. */ - (void)onCanceled:(NSString *)url { } -
Call the
loadfunction when you configure the data source to preload data to the specified disk path.NSString *urlString = @"<URL>"; AVPUrlSource *urlSource = [[AVPUrlSource alloc] urlWithString:urlString]; [_aliPlayer setUrlSource:urlSource]; [[AliMediaLoader shareInstance] load:urlString duration:10000];// Save the preloaded data to the specified disk path. The loading time is set to 10,000 milliseconds.
Step 2: Set the first frame of a video as the thumbnail
Set the first frame as the video thumbnail to eliminate black screens during startup.
When playing videos in a list, apply the following logic to speed up playback and reduce traffic:
-
Request only thumbnails when a user swipes between videos quickly.
-
Display the prefetched thumbnail when half of the next video view appears.
Console
-
Create a snapshot template to capture the first frame.
-
Log on to the ApsaraVideo for VOD console.
-
In the left-side navigation pane, choose Configuration Management > Media Processing > Snapshot Templates.
-
Click Create Snapshot Template. Configure the parameters to capture the first frame.
Set a custom Template Name. Select Normal Snapshot for Snapshot Type. Set Start Time to 00:00:00 and Snapshot Count: to 1. Configure other parameters as needed (Snapshot templates).
-
Click Save to create the snapshot template.
-
-
Submit a snapshot job to capture the first frame.
Note-
To submit a snapshot job from the console, create a workflow with a Snapshots node and select the first-frame snapshot template (Manage workflows).
-
Configure a SnapshotComplete event notification to receive the task status and captured image URL when the job completes (Callback settings).
-
Scenario 1: Take a snapshot during video upload
-
In the ApsaraVideo for VOD console, choose Media Files > Audio/Video.
-
Click Upload Audio/Video, and then click Add Audio/Video.
-
Set the upload method and storage location, add the video file, and then select Use Workflow. Choose the workflow you created for capturing the first frame.
-
Click Upload.
-
-
Scenario 2: Take a snapshot after video upload
-
In the ApsaraVideo for VOD console, choose Media Files > Audio/Video.
-
In the audio/video list, find the target video and click Media Processing in the Actions column.
-
Set Processing Type to Use Workflow, and set the Workflows parameter to the workflow you created for capturing the first frame.
-
Click OK.
-
-
Obtain the snapshot result
-
If you have configured a SnapshotComplete event notification, you can get the task status and the captured image URL from the callback.
-
If you have not configured event notifications, you can periodically call the ListSnapshots operation to poll for the task status and the captured image URL.
-
-
-
Set the video thumbnail to the first-frame snapshot.
NoteSave the snapshot from Step 2 to your local computer before uploading it as the thumbnail.
-
In the ApsaraVideo for VOD console, choose Media Files > Audio/Video.
-
In the audio/video list, find the target video and click Manage in the Actions column.
-
On the Basic information tab, click Editing Video Information .
-
Click Upload, select the first-frame snapshot that you saved locally, and click Open.
-
Click Save to set the video thumbnail.
Check the audio/video list to verify the thumbnail update.
-
OpenAPI
The following examples use the Alibaba Cloud SDK for Java to call ApsaraVideo for VOD API operations.
Procedure
-
Create a snapshot template to capture the first frame.
Call the AddVodTemplate operation to create a snapshot template for capturing the first frame. The following code provides an example:
import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.vod.model.v20170321.AddVodTemplateRequest; import com.aliyuncs.vod.model.v20170321.AddVodTemplateResponse; /** * Note: * 1. This demo shows how to create a template to capture the first frame as a single snapshot. * 2. We recommend using the ApsaraVideo for VOD console to create snapshot templates for a more convenient experience. */ public class AddSnapshotTemplate { // 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. // Do not hard-code the AccessKey ID and AccessKey Secret in your project. Otherwise, the AccessKey pair may be leaked and the security of all your resources may be compromised. // This example shows how to use environment variables to obtain the AccessKey pair for identity verification. Before you run the code, configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables. public static String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"); public static String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); public static void main(String[] args) { try{ DefaultAcsClient vodClient = initVodClient(accessKeyId, accessKeySecret); AddVodTemplateResponse response = addSnapshotTemplate(vodClient); System.out.println("RequestId is:" + response.getRequestId()); System.out.println("TemplateId is:" + response.getVodTemplateId()); }catch (Exception e){ } } public static AddVodTemplateResponse addSnapshotTemplate(DefaultAcsClient vodClient) throws ClientException { AddVodTemplateRequest request = new AddVodTemplateRequest(); request.setName("First-frame snapshot template"); request.setTemplateType("Snapshot"); request.setTemplateConfig("{\"SnapshotType\":\"NormalSnapshot\",\"SnapshotConfig\":{\"FrameType\":\"normal\",\"Count\":1,\"Interval\":1,\"SpecifiedOffsetTime\":0}}"); return vodClient.getAcsResponse(request); } public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { // The region where ApsaraVideo for VOD is activated. String regionId = "cn-shanghai"; DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); DefaultAcsClient client = new DefaultAcsClient(profile); return client; } } -
Submit a snapshot job to capture the first frame.
Call the SubmitSnapshotJob operation to submit a snapshot job. The following code provides an example:
import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.vod.model.v20170321.*; /** * Note: * 1. This demo shows how to submit a snapshot job after a first-frame snapshot template is created. * 2. For newly uploaded videos, we recommend performing this step after the `VideoAnalysisComplete` event succeeds. For existing videos with a Normal status, you can design your own process. * 3. Snapshots are an asynchronous task. We recommend waiting for the `SnapshotComplete` event to succeed before you retrieve the snapshot URL. * 4. You can infer the snapshot output URL from `SnapshotRegular` in the event callback. For more information about the URL generation rule, see the `SnapshotComplete` topic. * 5. If you do not have a callback service, you can also call the `ListSnapshots` operation to poll for results. This operation returns only the latest snapshot result by default. For more information, see the `ListSnapshots` API reference. */ public class SubmitSnapshotJob { // 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. // Do not hard-code the AccessKey ID and AccessKey Secret in your project. Otherwise, the AccessKey pair may be leaked and the security of all your resources may be compromised. // This example shows how to use environment variables to obtain the AccessKey pair for identity verification. Before you run the code, configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables. public static String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"); public static String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); public static void main(String[] args) { try{ DefaultAcsClient vodClient = initVodClient(accessKeyId, accessKeySecret); SubmitSnapshotJobResponse response = submitSnapshotJob(vodClient); System.out.println("RequestId is:" + response.getRequestId()); System.out.println("JobId is:" + response.getSnapshotJob().getJobId()); }catch (Exception e){ } } public static SubmitSnapshotJobResponse submitSnapshotJob(DefaultAcsClient vodClient) throws ClientException { SubmitSnapshotJobRequest request = new SubmitSnapshotJobRequest(); request.setVideoId("a42b**********633b79f0102"); request.setSnapshotTemplateId("1f27a7**********eba2756"); // Optional. Custom pass-through parameters that are available in callbacks. Use this to identify the first-frame snapshot. request.setUserData("{\"Extend\":{\"SnapshotType\":\"FirstFrame\",\"VideoId\":\"a42bf540********33b79f0102\"}}"); return vodClient.getAcsResponse(request); } public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { // The region where ApsaraVideo for VOD is activated. String regionId = "cn-shanghai"; DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); DefaultAcsClient client = new DefaultAcsClient(profile); return client; } // Call ListSnapshots to query snapshots. public static ListSnapshotsResponse listSnapshots(DefaultAcsClient vodClient) throws ClientException { ListSnapshotsRequest request = new ListSnapshotsRequest(); request.setVideoId("a42bf540b1b371ed804a6633b79****"); request.setSnapshotType("NormalSnapshot"); ListSnapshotsResponse response = vodClient.getAcsResponse(request); System.out.println("RequestId is:" + response.getRequestId()); System.out.println("SnapshotUrl is:" + response.getMediaSnapshot().getSnapshots().get(0).getUrl()); return vodClient.getAcsResponse(request); } } -
Set the video thumbnail to the first-frame snapshot.
This example modifies a single video's thumbnail after upload. Other methods: Set a thumbnail during video upload and Update a thumbnail after video upload.
Call the UpdateVideoInfo operation and pass the
CoverURLparameter to specify the video thumbnail. The following code provides an example:package com.alibaba.bltest.transcode; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.vod.model.v20170321.UpdateVideoInfoRequest; import com.aliyuncs.vod.model.v20170321.UpdateVideoInfoResponse; /** * Note: * 1. This demo shows how to update the thumbnail of a single video. To modify other video parameters, see the `UpdateVideoInfo` API reference. * 2. When updating a thumbnail, ensure that the image URL you provide is valid. */ public class UpdateVideoInfo { // 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. // Do not hard-code the AccessKey ID and AccessKey Secret in your project. Otherwise, the AccessKey pair may be leaked and the security of all your resources may be compromised. // This example shows how to use environment variables to obtain the AccessKey pair for identity verification. Before you run the code, configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables. public static String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"); public static String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); public static void main(String[] args) { try{ DefaultAcsClient vodClient = initVodClient(accessKeyId, accessKeySecret); UpdateVideoInfoResponse response = updateVideoInfo(vodClient); System.out.println("RequestId is:" + response.getRequestId()); }catch (Exception e){ } } public static UpdateVideoInfoResponse updateVideoInfo(DefaultAcsClient vodClient) throws ClientException { UpdateVideoInfoRequest request = new UpdateVideoInfoRequest(); request.setVideoId("a42b***********33b79f0102"); // When setting the first-frame thumbnail, set `CoverURL` to the image URL that is output after the first-frame snapshot job succeeds. request.setCoverURL("http://demo.aliyuncdn.com/a42bf5******40b1b37/snapshots/normal/41B7AF54-18672BB301D-1748-0984-309-112420****.jpg"); return vodClient.getAcsResponse(request); } public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { // The region where ApsaraVideo for VOD is activated. String regionId = "cn-shanghai"; DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); DefaultAcsClient client = new DefaultAcsClient(profile); return client; } }
Complete example
package com.alibaba.bltest.transcode;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.vod.model.v20170321.*;
import org.apache.commons.lang3.StringUtils;
/**
* Note:
* 1. This demo provides the complete logic for taking a snapshot and updating a thumbnail. You must adapt parts of the code to your business logic.
* 2. This demo cannot be run directly. You must add the required logic.
* 3. This demo is for reference only and does not represent the only implementation method.
*/
public class SnapshotAndUpdateCover {
// 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.
// Do not hard-code the AccessKey ID and AccessKey Secret in your project. Otherwise, the AccessKey pair may be leaked and the security of all your resources may be compromised.
// This example shows how to use environment variables to obtain the AccessKey pair for identity verification. Before you run the code, configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables.
public static String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
public static String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
public static void main(String[] args) {
try{
DefaultAcsClient vodClient = initVodClient(accessKeyId, accessKeySecret);
// Video ID
String videoId = "a42bf540b1b37*******b79f0102";
// Scenario 1: You have a callback service or use Message Service (MNS).
// If you set a thumbnail for a newly uploaded video, you must first receive the video analysis success event.
// If you set a thumbnail for an existing video, you can directly submit a snapshot job from this step.
submitSnapshotJob(vodClient,videoId);
// After you receive the `SnapshotComplete` event callback, determine the snapshot type and retrieve the required image URL.
JSONObject callBackMessage = new JSONObject(); // Replace this with the message received by the callback service.
String snapshotType = callBackMessage.getJSONObject("UserData").getJSONObject("Extend").getString("SnapshotType");
if("FirstFrame".equals(snapshotType)){
// Replace the snapshot path logic here with your custom logic.
String coverUrl = callBackMessage.getJSONArray("SnapshotInfos").getJSONObject(0).getString("SnapshotRegular").replace("{SnapshotCount}","00001");
// Update the video thumbnail.
updateVideoInfo(vodClient,videoId,coverUrl);
}
// Scenario 2: You do not have a callback service or use MNS.
// If you set a thumbnail for a newly uploaded video, poll the video status after the upload.
String videoStatus = "";
while(!"Normal".equals(videoStatus)){
videoStatus = getVideoInfo(vodClient,videoId);
Thread.sleep(1000);
}
// If you set a thumbnail for an existing video, you can directly submit a snapshot job from this step.
submitSnapshotJob(vodClient,videoId);
// Poll for the snapshot result.
String coverUrl = "";
while(StringUtils.isBlank(coverUrl)){
coverUrl = listSnapshots(vodClient,videoId);
Thread.sleep(1000);
}
// Update the video thumbnail.
updateVideoInfo(vodClient,videoId,coverUrl);
}catch (Exception e){
}
}
/**
* Submit a snapshot job.
*/
public static SubmitSnapshotJobResponse submitSnapshotJob(DefaultAcsClient vodClient, String vid) throws ClientException {
SubmitSnapshotJobRequest request = new SubmitSnapshotJobRequest();
request.setVideoId(vid);
request.setSnapshotTemplateId("1f27a7f*********70eba2756");
// Optional. Custom pass-through parameters that are available in callbacks. Use this to identify the first-frame snapshot.
request.setUserData("{\"Extend\":{\"SnapshotType\":\"FirstFrame\",\"VideoId\":\"a42bf540********33b79f0102\"}}");
return vodClient.getAcsResponse(request);
}
/**
* Update the video thumbnail.
*/
public static UpdateVideoInfoResponse updateVideoInfo(DefaultAcsClient vodClient, String vid, String coverUrl) throws ClientException {
UpdateVideoInfoRequest request = new UpdateVideoInfoRequest();
request.setVideoId(vid);
// When setting the first-frame thumbnail, set `CoverURL` to the image URL that is output after the first-frame snapshot job succeeds.
request.setCoverURL(coverUrl);
return vodClient.getAcsResponse(request);
}
/**
* Initialize the SDK instance.
*/
public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException {
// The region where ApsaraVideo for VOD is activated.
String regionId = "cn-shanghai";
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
return client;
}
/**
* Query snapshots.
*/
public static String listSnapshots(DefaultAcsClient vodClient, String vid) throws ClientException {
ListSnapshotsRequest request = new ListSnapshotsRequest();
request.setVideoId(vid);
request.setSnapshotType("NormalSnapshot");
ListSnapshotsResponse response = vodClient.getAcsResponse(request);
String coverUrl = "";
System.out.println("RequestId is:" + response.getRequestId());
try{
coverUrl = response.getMediaSnapshot().getSnapshots().get(0).getUrl();
System.out.println("SnapshotUrl is:" + response.getMediaSnapshot().getSnapshots().get(0).getUrl());
}catch (NullPointerException e){
}
return coverUrl;
}
/**
* Query a single video.
*/
public static String getVideoInfo(DefaultAcsClient vodClient, String vid) throws ClientException {
GetVideoInfoRequest request = new GetVideoInfoRequest();
request.setVideoId(vid);
GetVideoInfoResponse response = vodClient.getAcsResponse(request);
System.out.println("RequestId is:" + response.getRequestId());
String videoStatus = "";
try{
videoStatus = response.getVideo().getStatus();
System.out.println("Video Status is:" + response.getVideo().getStatus());
}catch (NullPointerException e){
}
return videoStatus;
}
}
Step 3: (Optional) Prefetch video resources
Prefetching caches video resources from the origin server to CDN points of presence (POPs) in advance. Users retrieve resources directly from POPs, accelerating playback and complementing client-side preloading.
The prefetch feature incurs origin traffic charges. Prefetch selectively based on video popularity.
Console configuration
-
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Configuration Management > CDN Configuration > Refresh and Prefetch.
-
On the Purge Cache tab, configure the prefetch information.
-
For Operation type, select Prefetch.
-
Purge Type: This parameter is fixed to URL.
-
URL: Enter the URL of the video resource that you want to prefetch. Each URL must start with
http://orhttps://. You can prefetch resources from up to 500 URLs per day. You can specify up to 100 URLs in a request.
-
-
Click Submit to complete the prefetch configuration.
Configuration with OpenAPI
-
Call the PreloadVodObjectCaches operation to prefetch video resources.
Step 4: Use ApsaraVideo Player to play videos
Play videos using ApsaraVideo Player with UrlSource.