This topic describes the environment requirements, integration methods, and usage notes of ApsaraVideo Player SDK for Android.

Environment requirements

Item Description
Android version Android 4.3 or later
Mobile phone processor One of the following processor architectures must be used:
  • ARMv7
  • ARM64
Development tool We recommend that you use Android Studio. The procedures in this topic are based on Android Studio. To download Android Studio, visit Android Studio.

Prerequisites

The ApsaraVideo Player SDK for Android package is downloaded before you integrate the SDK by using on-premises files. The SDK package contains ApsaraVideo Player SDK for Android and the source code of a demo. We recommend that you download the SDK of the latest version. For more information about how to download the SDK, see SDK download.

The following table describes the folders or files in the SDK folder after the SDK package is decompressed.
Table 1. Folders or files in the SDK folder
Folder or file Description
demo The source code of the demo of ApsaraVideo Player.
JavaDoc The API reference of ApsaraVideo Player.
sdk The Android Archive (AAR) library of ApsaraVideo Player SDK for Android. For more information about the files in the sdk folder, see Table 2.
X.X.XReleaseNote The release notes.
Table 2. Files in the sdk folder
File Description
AliyunPlayer-x.x.x-full.aar The AAR package that contains the FFmpeg dynamic library.
AliyunPlayer-x.x.x-part.aar The AAR package that does not contain the FFmpeg dynamic library.
AlivcArtp-x.x.x.aar The AAR package that supports the Alibaba Real-time Transport Protocol (ARTP) protocol. This package is optional.
AlivcArtc-x.x.x.aar The AAR package that supports the Alibaba Real-Time Communication (ARTC) protocol. This package is optional.
Note
  • If you do not integrate the short video SDK, use the AliyunPlayer-x.xx.x-full.aar package as the dependency.
  • If you want to integrate the short video SDK, you must use the AliyunPlayer-x.x.x-part.aar package as a dependency for ApsaraVideo Player SDK. In addition, you must use the com.aliyun.video.android:AlivcFFmpeg:x.x.x package as a dependency for both ApsaraVideo Player SDK and the short video SDK.
  • If you include an invalid dependency for SDK integration, an FFmpeg error may occur.

Integrate the SDK by using on-premises files

  1. Copy the AAR packages to the libs folder of your project. If the libs folder does not exist, create the folder.
    The libs folder
  2. In the build.gradle file of the project, add the flatDir setting to the repositories section of the allprojects block. The following sample code provides an example:
    flatDir {
       dirs 'libs'
    }
  3. Add the reference to the AAR packages and the Conan package com.alivc.conan:AlivcConan:x.x.x to the dependencies block in the build.gradle file of the application. The following sample code provides an example:
    dependencies {
          implementation fileTree(dir: 'libs', include: ['*.aar'])
          // You need to add the reference to the Conan package com.alivc.conan:AlivcConan:x.x.x to the dependencies block only for ApsaraVideo Player whose version is earlier than V5.3.0. 
          implementation 'com.alivc.conan:AlivcConan:x.x.x'
    }
  4. Configure ProGuard rules.
    Add ProGuard rules to the proguard-rules.pro file of the application. The following sample code provides an example:
    -keep class com.alivc.**{*;}
    -keep class com.aliyun.**{*;}
    -keep class com.cicada.**{*;}
    -dontwarn com.alivc.**
    -dontwarn com.aliyun.**
    -dontwarn com.cicada.**

Integrate the SDK by using the Gradle package

Note Make sure that the network is normal and you can access the Alibaba Cloud Maven repository. If you cannot download the ApsaraVideo Player SDK for Android package from the Maven repository due to a network failure, we recommend that you integrate the SDK by using on-premises files. For more information, see Integrate the SDK by using on-premises files.
  1. Add the URL of the Alibaba Cloud Maven repository to the build.gradle file of the project. The following sample code provides an example:
    maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
    The following figure shows the result of the preceding operations.Integrate the SDK by using the Gradle package
  2. Add the reference to the AAR packages to the dependencies block in the build.gradle file of the application. The following sample code provides an example:
    Note Make sure that the version number of the SDK is correct. Otherwise, an error is reported and the reference fails to be added.
    implementation 'com.aliyun.sdk.android:AliyunPlayer:x.x.x-full'
    // You need to add the reference to the Conan package com.alivc.conan:AlivcConan:x.x.x to the dependencies block only for ApsaraVideo Player whose version is earlier than V5.3.0.
    implementation 'com.alivc.conan:AlivcConan:x.x.x'
    The following figure shows the result of the preceding operations.Result

FAQ

FAQ about players

References for feature implementation

Basic features

Advanced features