2-快速集成
1 Account Preparation
Before integrating the Player SDK project, please register an account on the Polyv website and activate the cloud video-on-demand service.
To play on-demand videos under your account, the player must complete on-demand account authentication. For basic integration, you can use account parameters such as userId from the on-demand system. You can log in to the on-demand backend and obtain these from the API interface.
For security reasons, it is not recommended to write secretKey in plaintext into client code or app configuration files. In a production environment, it is more advisable to store secretKey on your server. The server should generate the token required for playback or download and then deliver it to the client. For playback scenarios, refer to "Configure Incoming Token" in 4-Encrypted Video Copyright Protection. For download scenarios, refer to "Custom Incoming Token" in 5-Video Download.
2 Environment Requirements
| Name | Requirement |
|---|---|
| minSdkVersion | 21 (Android 5.0) |
| abiFilters | arm64-v8a, armeabi-v7a, armeabi, x86_64, x86 |
3 Integrating the Player Project
3.1 Import the Common Module (Required)
Copy the common module from the demo project to the root directory of your project, and modify the settings.gradle file of your project to add a reference to the common module:
include(":common")
3.2 Import the Long Video Scene Module (Optional)
Copy the scenes-single-video module from the demo project to the root directory of your project, and modify the settings.gradle file of your project to add a reference to the long video scene module:
include(":scenes-single-video")
3.3 Import the Short Video Scene Module (Optional)
Copy the scenes-feed-video module from the demo project to the root directory of your project, and modify the settings.gradle file of your project to add a reference to the short video scene module:
include(":scenes-feed-video")
3.4 Integrate Scene Layouts into Pages
The activity folder in the demo module provides integration demonstrations for scene layouts:
- The
PLVMediaPlayerSingleVideoActivityclass demonstrates how to integrate the layout for a long video scene. - The
PLVMediaPlayerFeedVideoActivityclass demonstrates how to integrate the layout for a short video scene.
You can refer to the integration methods of these two classes to integrate the layouts into your business pages.
3.5 Configure the Maven Repository
The Player SDK is stored in a private repository. You need to add the Maven repository configuration to the settings.gradle file of your project (or the build.gradle file for older Gradle versions):
repositories {
maven {
credentials {
username = "609cc5623a10edbf36da9615"
password = "EbkbzTNHRJ=P"
}
url = uri("https://packages.aliyun.com/maven/repository/2102846-release-8EVsoM/")
}
}
3.6 Modify Demo Parameters
To play videos under your account in the demo project, you need to modify the default configuration parameters of the project.
In the demo project, the default video data is configured in the PLVMockMediaResourceData class under the mock folder. You can modify the following parameters:
mockAuthentication: Configure account information.mockViewerParam: Configure viewer information.setup(): Configure the video data source.
