This guide introduces how to integrate the short-form drama solution into an Android project.
Source code
This solution requires the Professional Edition of the ApsaraVideo Player SDK. Refer to Obtain a license to acquire your license, then submit a ticket or contact Alibaba Cloud sales to request the source code.
Environment requirements
Category | Requirement | ||||||
Development environment | Android Studio 4.0 or later is recommended. | ||||||
System version | Android 5.0 (API Level 21) or later. | ||||||
Other | A physical device that runs Android 5.0 or later. Debugging on emulators is not supported. | ||||||
Prerequisites
You have obtained a Player SDK license and License Key for the Professional Edition.To associate the license to your application, refer to Associate a license.

Run the demo
After downloading the demo source code, open the project in Android Studio.
Place the license certificate in the
src/main/assetsdirectory of your project.Add the <meta-data> node to the
AndroidManifest.xmlfile.ImportantThe <meta-data> node must be placed inside the <application> element. If license verification fails after configuration, check whether the <meta-data> node is correctly placed and whether the key/value pairs are correct.

<meta-data android:name="com.aliyun.alivc_license.licensekey" android:value="no80rm6m8ayTXNTk80637a6cdef2a4825****************" /> <!--TODO: Set your LicenseKey. For more information, see the console.--> <meta-data android:name="com.aliyun.alivc_license.licensefile" android:value="assets/cert/license.crt" /> <!--TODO: Set your LicenseFile to enable ApsaraVideo Player SDK verification.-->Test on a physical device
Connect a physical Android device. After the device is successfully connected, it is displayed as shown in the following figure.

Click the green run button to build the project.

Install and run the short-form drama application on your device.
Integrate the component
The following sections describe how to use the AUIShortVideoList component and its public APIs to implement the list playback feature.
Preparation
Integrate the license for the authorized ApsaraVideo Player SDK.
For more information, see Integrate a license.
Copy the AUIShortVideoList module to your project directory.
In your project's root
settings.gradlefile, add Alibaba Cloud's Maven repository:Groovy DSL
repositories { // aliyun maven maven { url "https://maven.aliyun.com/repository/releases" } }Kotlin DSL
repositories { // aliyun maven maven("https://maven.aliyun.com/repository/releases") }Add the module reference and dependency.
To add a module reference, add the following content to the
settings.gradlefile in the project's root directory:Groovy DSL
// If the AUIShortVideoList module is in the AUIPlayerKits folder: include ':AUIPlayerKits:AUIShortVideoList' // If the AUIShortVideoList module is in the project's root directory: include ':AUIShortVideoList'Kotlin DSL
// If the AUIShortVideoList module is in the AUIPlayerKits folder: include(":AUIPlayerKits:AUIShortVideoList") // If the AUIShortVideoList module is in the project's root directory: include(":AUIShortVideoList")To add a module dependency, add the following content to the
build.gradlefile of the app module:Groovy DSL
// If the AUIShortVideoList module is in the AUIPlayerKits folder: implementation project(':AUIPlayerKits:AUIShortVideoList') // If the AUIShortVideoList module is in the project's root directory: implementation project(':AUIShortVideoList')Kotlin DSL
// If the AUIShortVideoList module is in the AUIPlayerKits folder: implementation(project(":AUIPlayerKits:AUIShortVideoList")) // If the AUIShortVideoList module is in the project's root directory: implementation(project(":AUIShortVideoList"))
Build and run the project to ensure the component is integrated correctly.
NoteAfter integration, it is recommended to create a
git commit. This saves the latest commit ID of the component, providing a crucial reference point for future updates and a clear record of code changes.For integration issues, see Integration FAQ.
After integrating the AUIShortVideoList component, you can copy the following code into your project.
How to use
you can use the AUIShortVideoList component in one of three ways:
AUIShortVideoListActivity
You can start this Activity directly. For the specific call logic, see the following example. To get the
videoInfoListJSONdata, see Retrieve data.Java
// TODO: context is android context Intent intent = new Intent(context, AUIShortVideoListActivity.class); // TODO: videoInfoListJSON is the serialized string of List<VideoInfo> intent.putExtra(AUIShortVideoListView.KEY_VIDEO_INFO_LIST_DATA, videoInfoListJSON); startActivity(intent);Kotlin
// TODO: context is android context val intent = Intent(context, AUIShortVideoListActivity::class.java) // TODO: videoInfoListJSON is the serialized string of List<VideoInfo> intent.putExtra(AUIShortVideoListView.KEY_VIDEO_INFO_LIST_DATA, videoInfoListJSON) startActivity(intent)AUIShortVideoListFragment
You can embed this Fragment within your own Activity or another Fragment. For the specific call logic, see the following example:
In your XML layout, add a FrameLayout to host the Fragment:
<FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" />Initialize the Fragment and add it to the container.
Java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { AUIShortVideoListFragment fragment = new AUIShortVideoListFragment(); Bundle bundle = new Bundle(); // TODO: videoInfoListJSON is the serialized string of List<VideoInfo> bundle.putString(AUIShortVideoListView.KEY_VIDEO_INFO_LIST_DATA, videoInfoListJSON); fragment.setArguments(bundle); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragment_container, fragment) .commit(); } }Kotlin
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (savedInstanceState == null) { val fragment = AUIShortVideoListFragment() val bundle = Bundle() // TODO: videoInfoListJSON is the serialized string of List<VideoInfo> bundle.putString(AUIShortVideoListView.KEY_VIDEO_INFO_LIST_DATA, videoInfoListJSON) fragment.arguments = bundle supportFragmentManager .beginTransaction() .replace(R.id.fragment_container, fragment) .commit() } }
AUIShortVideoListView
You can use this View component directly to build a custom immersive playback page. For the specific call logic, see the following example:
Add the View component to your XML layout:
<!-- 1. Add the short video list View component --> <com.alivc.player.playerkits.shortvideolist.AUIShortVideoListView android:id="@+id/aui_video_list_view" android:layout_width="match_parent" android:layout_height="match_parent" />In your code, get a reference to the View and set its
List<VideoInfo>data source.Java
// 2. Declaration of Short Video List View private AUIShortVideoListView mShortVideoListView; mShortVideoListView = findViewById(R.id.aui_video_list_view); // 3. TODO: Retrieve data and fill it into videoInfoList List<VideoInfo> videoInfoList; // 4. Add List<VideoInfo> type data source to Short Video List View mShortVideoListView.addSources(videoInfoList); // mShortVideoListView.loadSources(videoInfoList);Kotlin
// 2. Declaration of Short Video List View private lateinit var mShortVideoListView: AUIShortVideoListView mShortVideoListView = findViewById(R.id.aui_video_list_view) // 3. TODO: Retrieve data and fill it into videoInfoList val videoInfoList: List<VideoInfo> // 4. Add List<VideoInfo> type data source to Short Video List View mShortVideoListView.addSources(videoInfoList) // mShortVideoListView.loadSources(videoInfoList)
Retrieve data
The AUIShortVideoList component uses the List<VideoInfo> data structure. VideoInfo is a data class that stores video information. The data structure is as follows:
Field | Type | Description | Notes |
id | int | Unique video ID | Used to uniquely identify each video. |
url | String | Video source URL | Can be any supported video format, such as MP4 or M3U8. |
coverUrl | String | Video thumbnail URL | |
author | String | Video author | |
title | String | Video title | |
type | String | Video type | Corresponds to the |
To ensure that the AUIShortVideoList component runs correctly, you must pass the serialized List<VideoInfo> string in the Bundle.
intent.putExtra(AUIShortVideoListView.KEY_VIDEO_INFO_LIST_DATA, videoInfoListJSON);You can obtain the final List<VideoInfo> data source through a network request or by transforming local data, and then serialize it into a JSON string.
Network request
Java
AUIShortVideoListUtil.requestVideoInfoList(new AUIShortVideoListUtil.OnNetworkCallBack<List<VideoInfo>>() { @Override public void onResponse(List<VideoInfo> videoInfoList) { if (videoInfoList == null || videoInfoList.isEmpty()) { // TODO: Request video info list error! return; } String videoInfoListJSON = AUIShortVideoListUtil.serializeVideoInfoListToJson(videoInfoList); // TODO: Use videoInfoList or videoInfoListJSON... } });Kotlin
AUIShortVideoListUtil.requestVideoInfoList(object : AUIShortVideoListUtil.OnNetworkCallBack<List<VideoInfo?>?> { override fun onResponse(videoInfoList: List<VideoInfo?>?) { if (videoInfoList.isNullOrEmpty()) { // TODO: Request video info list error! return } val videoInfoListJSON = AUIShortVideoListUtil.serializeVideoInfoListToJson(videoInfoList) // TODO: Use videoInfoList or videoInfoListJSON... } })Data conversion
Java
ArrayList<VideoInfo> videoInfoList = AUIShortVideoListUtil.assembleVideoInfoList(); if (videoInfoList == null || videoInfoList.isEmpty()) { // TODO: Assemble video info list error! return; } String videoInfoListJSON = AUIShortVideoListUtil.serializeVideoInfoListToJson(videoInfoList); // TODO: Use videoInfoList or videoInfoListJSON...Kotlin
val videoInfoList = AUIShortVideoListUtil.assembleVideoInfoList() if (videoInfoList.isNullOrEmpty()) { // TODO: Assemble video info list error! return } val videoInfoListJSON = AUIShortVideoListUtil.serializeVideoInfoListToJson(videoInfoList) // TODO: Use videoInfoList or videoInfoListJSON...
Integration FAQ
Black screen or other playback issues
Check your ApsaraVideo Player SDK license configuration. For more information, see Integrate a license.
Compilation or runtime errors
Ensure that the configurations in the module, such as compileSdkVersion, buildToolsVersion, minSdkVersion, and targetSdkVersion, are consistent with your main project's settings.
If your project already contains the same third-party library, adjust the version number in the module to ensure compatibility and avoid conflicts.
Playback fails on an emulator
The ApsaraVideo Player SDK for Android does not support running on emulators. After integration, you must test on a physical device.
Error: "Namespace not specified"
Check your Android Gradle Plugin (AGP) version. If you use a later version, such as 8.3.2, you must manually add the namespace setting in each module's build.gradle file. In earlier AGP versions, this configuration is in the package attribute of the module's /src/main/res/AndroidManifest.xml file.
Gradle conflict when handling repository priority
Declare the repository in the settings.gradle file first.
Build scenarios
The AUIShortVideoList component supports low-code integration and can be used to build various short-form video list features. Refer to the examples in AUIPlayerScenes, such as AUIShortDramaList (Short-form drama theater) and AUIShortDramaFeeds (Short-form drama feeds).
Short-form drama theater
Overview
AUIShortDramaList is a scenario-specific module built on the AUIShortVideoList component. It provides a drama detail page and a recommendations page, supporting nested two-level navigation and shared player instances.
Integration
Before you build the short-form drama theater scenario, ensure that you have completed the integration preparation for the AUIShortVideoList component.
Copy the AUIShortDramaList module to your project.
Verify dependencies and add module references for AUIShortDramaList.
Check the component dependency in the
build.gradlefile of the AUIShortDramaList module to ensure it correctly depends on AUIShortVideoList.// If the AUIShortVideoList module is in the AUIPlayerKits folder: implementation project(':AUIPlayerKits:AUIShortVideoList') // If the AUIShortVideoList module is in the project's root directory: implementation project(':AUIShortVideoList')Add the module reference to your root
settings.gradlefile.Groovy DSL
// If the AUIShortDramaList module is in the AUIPlayerScenes folder: include ':AUIPlayerScenes:AUIShortDramaList' // If the AUIShortDramaList module is in the project's root directory: include ':AUIShortDramaList'Kotlin DSL
// If the AUIShortDramaList module is in the AUIPlayerScenes folder: include(":AUIPlayerScenes:AUIShortDramaList") // If the AUIShortDramaList module is in the project's root directory: include(":AUIShortDramaList")Add the module dependency to your app's
build.gradlefile.Groovy DSL
// If the AUIShortDramaList module is in the AUIPlayerScenes folder: implementation project(':AUIPlayerScenes:AUIShortDramaList') // If the AUIShortDramaList module is in the project's root directory: implementation project(':AUIShortDramaList')Kotlin DSL
// If the AUIShortDramaList module is in the AUIPlayerScenes folder: implementation(project(":AUIPlayerScenes:AUIShortDramaList")) // If the AUIShortDramaList module is in the project's root directory: implementation(project(":AUIShortDramaList"))
Build and run the project to ensure correct integration.
How to use
You can start the short-form drama theater Activity directly, as shown below.
Java
// TODO: context is android context
Intent intent = new Intent(context, AUIShortDramaListActivity.class);
startActivity(intent);Kotlin
// TODO: context is android context
val intent = Intent(context, AUIShortDramaListActivity::class.java)
startActivity(intent)Retrieve data
The AUIShortDramaList module uses the List<DramaInfo> data structure. DramaInfo is a data class that stores short drama series information. The data structure is as follows:
Field | Type | Description | Notes |
id | int | Unique series ID | |
title | String | Series title | |
cover | String | Series thumbnail | |
firstDrama | VideoInfo | First episode | This is the first item from the |
dramas | ArrayList<VideoInfo> | List of episodes | This list can be used as a data source for the |
You can retrieve the final List<DramaInfo> data source by making a network request or by converting data:
Network request
Java
AUIShortDramaListUtil.requestDramaInfoList(new AUIShortVideoListUtil.OnNetworkCallBack<List<DramaInfo>>() { @Override public void onResponse(List<DramaInfo> dramaInfoList) { if (dramaInfoList == null || dramaInfoList.isEmpty()) { // TODO: Request drama info list error! return; } // TODO: Use dramaInfoList } });Kotlin
AUIShortDramaListUtil.requestDramaInfoList(object : AUIShortVideoListUtil.OnNetworkCallBack<List<DramaInfo?>?> { override fun onResponse(dramaInfoList: List<DramaInfo?>?) { if (dramaInfoList.isNullOrEmpty()) { // TODO: Request drama info list error! return } // TODO: Use dramaInfoList } })Data conversion
Java
ArrayList<DramaInfo> dramaInfoList = AUIShortDramaListUtil.assembleDramaInfoList(); if (dramaInfoList == null || dramaInfoList.isEmpty()) { // TODO: Assemble drama info list error! return; } // TODO: Use dramaInfoListKotlin
val dramaInfoList = AUIShortDramaListUtil.assembleDramaInfoList() if (dramaInfoList.isNullOrEmpty()) { // TODO: Assemble drama info list error! return } // TODO: Use dramaInfoList
Short-form drama feeds
Overview
AUIShortDramaFeeds is a scenario-specific module for a short-form drama feeds stream that is built on the AUIShortVideoList component. It provides a tabbed feeds interface that supports nested tabs, up/down/left/right swipe gestures for playback, and shared player instances.
Integration
Before you build the short-form drama feeds scenario, ensure that you have completed the integration preparation for the AUIShortVideoList component.
Copy the AUIShortDramaFeeds module to your project.
Check the dependencies of the AUIShortVideoList component, and add the module reference and dependency.
Check the dependency configuration of the AUIShortVideoList component in the
build.gradlefile of the AUIShortDramaFeeds module:// If the AUIShortVideoList module is in the AUIPlayerKits folder: implementation project(':AUIPlayerKits:AUIShortVideoList') // If the AUIShortVideoList module is in the project's root directory: implementation project(':AUIShortVideoList')Add the module reference to your root
settings.gradlefile:Groovy DSL
// If the AUIShortDramaFeeds module is in the AUIPlayerScenes folder: include ':AUIPlayerScenes:AUIShortDramaFeeds' // If the AUIShortDramaFeeds module is in the project's root directory: include ':AUIShortDramaFeeds'Kotlin DSL
// If the AUIShortDramaFeeds module is in the AUIPlayerScenes folder: include(":AUIPlayerScenes:AUIShortDramaFeeds") // If the AUIShortDramaFeeds module is in the project's root directory: include(":AUIShortDramaFeeds")Add the module dependency to your app's
build.gradlefile:Groovy DSL
// If the AUIShortDramaFeeds module is in the AUIPlayerScenes folder: implementation project(':AUIPlayerScenes:AUIShortDramaFeeds') // If the AUIShortDramaFeeds module is in the project's root directory: implementation project(':AUIShortDramaFeeds')Kotlin DSL
// If the AUIShortDramaFeeds module is in the AUIPlayerScenes folder: implementation(project(":AUIPlayerScenes:AUIShortDramaFeeds")) // If the AUIShortDramaFeeds module is in the project's root directory: implementation(project(":AUIShortDramaFeeds"))
Build and run the project to ensure the component is integrated correctly.
How to use
You can start the short-form drama feeds Activity directly. Refer to the example below.
Java
// TODO: context is android context
Intent intent = new Intent(context, AUIShortDramaFeedsActivity.class);
startActivity(intent);kotlin
// TODO: context is android context
val intent = Intent(context, AUIShortDramaFeedsActivity::class.java)
startActivity(intent)Retrieve data
The AUIShortDramaFeeds module uses the List<VideoInfo> data structure. VideoInfo is a data class that stores video information. For more information, see the section of AUIShortVideoList component.
Core features
This component is built using the ApsaraVideo Player SDK, leveraging multiple player instances (AliPlayer), preloading (MediaLoader), and pre-rendering. It utilizes core capabilities such as preloading, pre-rendering, HTTPDNS, and encrypted playback to improve playback start time, stability, and security. For more details, see Advanced features.
Preloading
Using a sliding window strategy, the component dynamically starts and stops preloading tasks for videos. The underlying SDK intelligently adjusts task priority based on network conditions to ensure the currently playing video and upcoming videos receive more network resources. This improves start-up speed and reduces buffering, providing a smooth experience even when scrolling quickly. For more, see Preloading.
Pre-rendering
The component pre-renders the first frame of upcoming videos in the background, reducing black screens and making playback feel seamless. Starting from V6.16.0, the Player SDK supports forced pre-rendering. For more, see Pre-rendering.
Multi-instance player pool
A globally shared, configurable player instance pool is implemented. Through optimized API calls and thread resource management, it achieves optimal performance and resource efficiency in terms of thread management, CPU utilization, and memory usage. This optimization reduces lag during scrolling, making the playback experience smoother.
Picture-in-Picture with auto-play next episode
Using an independent player instance for the floating window ensures continuous rendering when switching episodes. This achieves a seamless, non-disruptive viewing experience and is an engineered implementation of the best practices for PiP playback.
HTTPDNS
HTTPDNS provides faster and more stable DNS resolution. By replacing traditional DNS, it reduces lookup times, improving video loading speed and stability. Since V6.12.0, HTTPDNS is enabled by default. For more, see HTTPDNS.
Video encryption
Short-form dramas are typically 1-3 minute MP4 videos. Since V6.8.0, the Player SDK supports proprietary MP4 encryption, providing security for your video content. For more information, see How to play encrypted videos.
To play a privately encrypted MP4 video, the following conditions must be met:
When the privately encrypted MP4 video is passed to the player, the application must append
etavirp_nuyila=1to the video URL. For example, if the original video URL ishttps://example.aliyundoc.com/test.mp4, the URL passed to the player must behttps://example.aliyundoc.com/test.mp4?etavirp_nuyila=1.The UID associated with your app's license must be the same as the UID used to encrypt the MP4 video.
You can verify a privately encrypted video as follows:
The meta information must contain the
AliyunPrivateKeyUritag.The video cannot be played directly with ffplay.
H.265 adaptive playback
If hardware decoding of an H.265 stream fails and an H.264 backup stream is available, the player will automatically switch to the H.264 stream. If no backup is available, it will fall back to software decoding for H.265. For more, see H.265 adaptive playback.
Adaptive bitrate (ABR) streaming
The Player SDK supports adaptive bitrate streaming for HLS and DASH. You can switch bitrates by calling the player's selectTrack method, enabling automatic video quality adjustment based on network conditions. For more information, see Adaptive bitrate switching.
Screen recording prevention
This feature protects your video content by monitoring for screen recording and screenshot actions and stopping playback if they are detected, effectively preventing unauthorized recording and distribution.
// Android-specific feature to prevent screen recording and screenshots in the app
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);