The following table lists mandatory requirements.

Background information

Environment requirements

Name Requirement
Android system version Android 4.0 or later
Android API version API 14 or later
CPU architecture support ARM64 and ARMv7
Integrated tool Android Studio

The following table lists optional requirements that provide reference for developers who compile and run the source code. These requirements are used in the development environment to develop the demo.

Name Requirement
Android Studio version 3.1.3
JRE 1.8.0_152-release-1024-b01 x86_64
JVM OpenJDK 64-Bit
Gradle version gradle-4.4-all
Gradle plug-in version com.android.tools.build:gradle:3.0.1

Demo download

Click SDK download. On the download page, find and download the target source code package in the Download link column of the LongVideo source code table.

Directory structure

The following table lists the modules contained in the LongVideo source code package.

Name Description
AlivcLongVideo The module that contains the code related to building a LongVideo application.
Aliyunplayer The module that contains the ApsaraVideo Player SDK.
AliyunVideoCommon The public module that contains some utility classes.
thirdparty-lib The module that contains dependent third-party libraries required by the demo.

SDK

The following table lists the AAR packages for the ApsaraVideo Player SDK.

Name Description
AliyunPlayer-xxx-full.aar The AAR package that contains all libraries required by ApsaraVideo Player.
AliyunPlayer-xxx-part.aar The AAR package that contains the core libraries required by ApsaraVideo Player.

If the project only integrates the ApsaraVideo Player SDK, use the AliyunPlayer-xxx-full.aar package.

If the project integrates both the short video SDK and the ApsaraVideo Player SDK, use the AliyunPlayer-xxx-part.aar package.

You can also integrate the SDK by using the Gradle package.

implementation 'com.aliyun.sdk.android:AliyunPlayer:4.7.0-part'implementation 'com.aliyun.sdk.android:AliyunPlayer:4.7.0-full'

For more information, see New Player SDK: Integration.

Project compilation

Step 1: Download Gradle

Go to the Gradle official website. On the download page, download the distribution package of Gradle 4.4 required by the compilation environment to a local directory. Then, decompress the downloaded package.

Step 2: Import a project

Open Android Studio. On the homepage, click Open an existing Android Studio project to import the ApsaraLongVideo project from the /demo directory of the downloaded demo.

Step 3: Configure local Gradle settings

  • Click Cancel to disable the Gradle wrapper.
  • Select the local directory where the Gradle distribution package is decompressed in Step 1 as the directory of the local Gradle distribution.

Step 4: Compile and run the project

After the compilation, click Run to generate an .apk file and install it on a mobile phone that meets specified hardware requirements.Tips: The demo can run properly on physical devices, but cannot run on virtual machines currently.

Demo integration

Step 1: Copy objects

Copy the objects shown in the following figure to the root directory of the project.

Step 2: Configure Gradle settings

  • Run the following code to configure Gradle settings for the app folder:
buildscript {
    repositories {
        google()
        jcenter()
        maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
        // The maven URL of the project.
        maven { url 'http://4thline.org/m2' }

    }
    apply from: 'thirdparty-lib/config.gradle'
    dependencies {
        classpath externalAndroidBuildGradlePlugin
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
        // The maven URL of the project.
        maven { url 'http://4thline.org/m2' }
        flatDir { dirs 'src/main/libs' }

    }
}
  • Run the following code to download Gradle of a specified version:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
  • Add the following code tothe settings.gradle file:
include ':AliyunVideoCommon'
include ':Aliyunplayer:AlivcPlayerTools'
include ':AlivcLongVideo'
include ':AliyunVideoCommon'
  • Run the following code to configure the build.gradle file in the app folder:
implementation project (':AlivcLongVideo')
implementation project (':AliyunVideoCommon')
implementation project (':Aliyunplayer:AlivcPlayerTools')
implementation externalAndroidAppCompatV7
implementation externalAndroidSupportV4
implementation externalAndroidRecyclerView
implementation externalGSON
implementation externalOKHTTP
implementation externalAndroidMultiDex
  • Note: If an error is reported as shown in the following figure, add the packagingOptions configuration code to the build.gradle file in the app folder.
android {
    defaultConfig {
        ...
    }
    buildTypes {
        ...
    }
    packagingOptions {
        exclude 'META-INF/beans.xml'
    }
}

Step 3: Add permissions

<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<! --Required for installation with automatic URI update-->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

Step 4: Use the demo

The homepage of the LongVideo application is AlivcHomeActivity. Run the following code to go to the homepage:

Intent intent = new Intent(context,AlivcHomeActivity.class);
context.startActivity(intent);

In the provided LongVideo demo, the GlobalNetConstants class provides the configuration code of some request APIs. You can customize the code as needed, including APIs to request STS information and to play videos.