All Products
Search
Document Center

Integration

Last Updated: Sep 19, 2019

Note: This topic describes integration of ApsaraVideo Player SDK V4.5.0 and later.

Supported systems

Android 4.0 and later versions are supported. That is, the value of the apiLevel parameter must be equal to or greater than 14.
The mobile phone chip must adopt the ARMv7 or ARM64 architecture.

Development environment

We recommend that you use Android Studio as the development tool. This document is based on the Android Studio development environment.

Integration method

Integration using local files

Download SDK

Download the latest version of ApsaraVideo Player SDK from here. Decompress the SDK package to obtain AAR packages.

SDK structure

The SDK package contains two AAR packages.
AliyunPlayer-4.5.0-full.aar is a complete AAR package that contains FFmpeg dynamic frameworks.
AliyunPlayer-4.5.0-part.aar is an AAR package that does not contain FFmpeg dynamic frameworks.

SDK description

The SDK package contains two AAR packages. You need to select the AAR package as required:

  1. If you integrate a player SDK without the feature of short video playback, use AliyunPlayer-4.5.0-full.aar as the dependency package.
  2. To integrate a player SDK that supports short video playback, you need to use AliyunPlayer-4.5.0-part.aar as the dependency package. In addition, you need to add the com.aliyun.video.android:AlivcFFmpeg:1.0.0 package, the version of which is compatible for both the player SDK and the short video SDK.

An FFmpeg error may occur if you choose an incorrect dependency package for SDK integration.

Procedure

  1. In Xcode, copy the required AAR package to the libs directory of your project. Create a libs directory if it does not exist.

  1. In the build.gradle file, declare the position of the libs directory in the repositories part of the allprojects block, and add Alibaba Cloud Maven repository URL to the build.gradle file:
  1. maven {
  2. url 'https://maven.aliyun.com/repository/releases'
  3. }
  4. flatDir {
  5. dirs 'libs'
  6. }

The following figure shows the build.gradle file after you declare the position of the libs directory and add the Maven repository URL.

  1. Add the reference to the AAR package and the Gradle package com.alivc.conan:AlivcConan:0.9.5 to the dependencies part in the build.gradle file.
  1. dependencies {
  2. implementation fileTree(dir: 'libs', include: ['*.jar'])
  3. // Other dependencies.
  4. // Two dependency packages of ApsaraVideo Player.
  5. implementation (name:'AliyunPlayer-4.5.0-full',ext:'aar')
  6. implementation 'com.alivc.conan:AlivcConan:0.9.5'
  7. }

The following figure shows the result of the above operations.

  1. Build the project. After the ApsaraVideo Player SDK is integrated, the APK file size increases by about 7.5 MB.

Integration using the Gradle package

  1. Add Alibaba Cloud Maven repository URL to the buildscript block and the allprojects block in the build.gradle file.
  1. maven(){
  2. url 'https://maven.aliyun.com/repository/releases'
  3. }

The following figure shows the build.gradle file after you add the URL.

  1. Add the reference to the AAR package and the Gradle package com.alivc.conan:AlivcConan:0.9.5 to the dependencies part in the build.gradle file.
  1. implementation 'com.aliyun.sdk.android:AliyunPlayer:4.5.0-full'
  2. implementation 'com.alivc.conan:AlivcConan:0.9.5'

The following figure shows the build.gradle file after you add the reference.

  1. Build the project.

Size of the integration package

After the ApsaraVideo Player SDK is integrated, the APK file size increases by about 7.5 MB.

Proguard rules

  1. -keep class com.alivc.**{*;}
  2. -keep class com.aliyun.**{*;}
  3. -dontwarn com.alivc.**
  4. -dontwarn com.aliyun.**