All Products
Search
Document Center

ApsaraVideo VOD:Quick integration

Last Updated:Oct 07, 2023

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

Environment requirements

ItemDescription
Android versionAndroid 4.3 or later
Mobile phone processorOne of the following processor architectures must be used:
  • ARMv7
  • ARM64
Development toolWe recommend that you use Android Studio. The procedures in this topic are based on Android Studio. To download Android Studio, visit Android Studio.

Prerequisites

  • A license for ApsaraVideo Player SDK is registered and the license file AliVideoCert-********.crt is obtained. For more information, see Obtain a license.

  • The package for ApsaraVideo Player SDK for Android and the source code of a demo are downloaded. ApsaraVideo Player SDK for Android V5.4.6.0 and later versions provide a demo that does not support AndroidX and a demo that supports AndroidX. We recommend that you download the SDK package and the demo of the latest version based on your business requirements. For more information about the download links, see SDK overview and download.

The following table describes the folders or files in the SDK package after the package is decompressed.

Table 1. Folders or files in the SDK package

Folder or file

Description

demo

The source code of the demo of ApsaraVideo Player.

JavaDoc

The API references for ApsaraVideo Player.

sdk

The Android Archive (AAR) library of ApsaraVideo Player SDK for Android. For more information about the sdk folder, see Files in the sdk folder.

X.X.XReleaseNote

The release notes of ApsaraVideo Player SDK for Android.

Table 2. Files in the sdk folder

File

Description

AliyunPlayer-x.x.x-full.aar

An AAR package that contains FFmpeg.

AliyunPlayer-x.x.x-part.aar

An AAR package that does not contain FFmpeg.

AlivcArtp-x.x.x.aar

An AAR package that supports the Alibaba Real-time Transport Protocol (ARTP) protocol. This package is optional.

AlivcArtc-x.x.x.aar

An 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, add the AliyunPlayer-x.xx.x-full.aar dependency to your project.

  • If you want to integrate the short video SDK for Android and ApsaraVideo Player SDK for Android at the same time, you must add the AliyunPlayer-x.x.x-part.aar dependency for ApsaraVideo Player SDK and the com.aliyun.video.android:AlivcFFmpeg:x.x.x dependency for both ApsaraVideo Player SDK and the short video SDK to your project.

  • If you include an invalid dependency when you integrate ApsaraVideo Player SDK for Android, an FFmpeg conflict may occur.

limits

ApsaraVideo Player SDK for Android cannot run on simulators. After you integrate ApsaraVideo Player SDK for Android, you must run the SDK on an Android device.

Integrate the SDK by adding local files

Note

The following section describes how to use Android Studio Flamingo | 2022.2.1 to integrate ApsaraVideo Player SDK for Android. You can also follow the procedure to integrate the SDK by using other development tools.

  1. Copy the required AAR package to the libs folder of your project. If the libs folder does not exist, create a libs folder.

    图片
  2. In the build.gradle file of the project, add the flatDir setting to the repositories section of the allprojects block. Sample code:

    flatDir {
       dirs 'libs'
    }
  3. Add the reference to the AAR package and the Conan package to the dependencies block in the build.gradle file of the application. Sample code:

    dependencies {
          implementation fileTree(dir: 'libs', include: ['*.aar'])
          // You need to add the reference to the Conan package to the dependencies block only for ApsaraVideo Player V5.3.0 and earlier versions. 
          implementation 'com.alivc.conan:AlivcConan:x.x.x'
    }
  4. Configure obfuscation rules.

    Add obfuscation rules to the Proguard-rules.pro file of the application. Sample code:

    -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 Gradle

Note

Make sure that the network is accessible 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 error, we recommend that you integrate the SDK by adding local files. For more information, see Integrate the SDK by adding local files.

  1. Add the URL of the Alibaba Cloud Maven repository to the build.gradle file of the project. Sample code:

    maven { url "https://maven.aliyun.com/repository/releases" }

    The following figure shows the result of the preceding operation.gradle集成

  2. Add dependencies to the dependencies block in the build.gradle file of the application. Sample code:

    Note

    Make sure that the version number of the SDK is correct. Otherwise, an error is reported and the dependencies fail to be added. For more information about the versions of ApsaraVideo Player SDK for Android, see Release notes for ApsaraVideo Player SDK for Android.

    implementation 'com.aliyun.sdk.android:AliyunPlayer:x.x.x-full'
    // You need to add the reference to Conan package to the dependencies block only for ApsaraVideo Player V5.3.0 and earlier versions.
    implementation 'com.alivc.conan:AlivcConan:x.x.x'

    The following figure shows the result of the preceding operation.结果

Configure the license

Note
  • You must perform the following operations to configure the license for ApsaraVideo Player SDK for Android V5.4.7.1 and later versions before you use the SDK.

  • You can use ApsaraVideo Player SDK for Android for free. The validity period of the SDK license is one year. By default, the system automatically renews the license free of charge after the license expires.

  • After you configure the license, check the log. If no license-related errors are reported, the license is configured correctly.

  • The configured license file and license key must be used for the application specified by PackageName and Signature. If the license file or license key does not match the application, the authentication fails.

  1. Copy the license file AliVideoCert-********.crt to the Android Studio project. We recommend that you store the file in the assets directory. You can also put the file in the sandbox directory or other directories that you prefer.

  2. Add the following metadata to the AndroidManifest.xml file.

    license1
    • Set the first key to com.aliyun.alivc_license.licensekey and the value to the value of LicenseKey. The key must be in lowercase letters.

    • Set the second key to com.aliyun.alivc_license.licensefile and the value to the path in which the license file is stored. The key must be in lowercase letters.

    <meta-data
        android:name="com.aliyun.alivc_license.licensekey"
        android:value="xxxxxxxxx" />
    <meta-data
        android:name="com.aliyun.alivc_license.licensefile"
        android:value="assets/license.crt" />

FAQ

FAQ about players

References

Basic features

Advanced features