2-快速集成
1 Account Preparation
Before integrating the Multi-Scene SDK project, please register an account on the Polyv official website and activate the cloud live streaming service.
To log in to live streaming in the Demo, you need the appId (App ID), appSecret (App Secret), userId (Account ID), and channelId (Channel ID) from the live streaming system. For playback, you additionally need the vid (Playback Video ID) from the corresponding channel's playback list. You can obtain these parameters by logging into the live streaming backend and navigating to Developer Information.
2 Environment Requirements
| Name | Requirement |
|---|---|
| compatibleSdkVersion | >= 5.0.0(12) |
| abiFilters | arm64-v8a only |
3 Integrating Multi-Scene Project
3.1 Importing the Live Watch Module
Copy the scenes_liveWatch module from the demo project to the root directory of your project, and modify the project's build-profile.json5 file to add a reference to the scenes_liveWatch module:
{
"name": "scenes_liveWatch",
"srcPath": "./scenes_liveWatch"
}
3.2 Configuring the Player SDK
The video playback functionality of the Multi-Scene SDK depends on the Player SDK. Therefore, before initializing the Multi-Scene SDK, you need to modify the module's oh-package.json5 file to add the Player SDK dependency:
{
"dependencies": {
// 播放器 SDK 对外接口依赖
"@polyvharmony/media-player-sdk": "version",
// 播放器内核依赖
"@polyvharmony/media-player-core-ijk": "version"
}
}
Components of the Player SDK, such as the playback engine, log printing, and data storage, need to be configured before playing videos. You can refer to the PLVMediaPlayerStartUp class in the demo project to complete the initial configuration of the Player SDK.
// 配置全局 AppContext
PLVMediaPlayerAppContext.getInstance().setupAppContext(context)
// 配置日志
PLVCommonLogger.loggerImpl = new PLVLoggerImpl()
// 配置数据存储
PLVKVStore.setupImplement(new PLVKVStoreOhosImpl(context))
// 配置播放内核
PLVMediaPlayerFactory.getInstance().register(PLVMediaPlayerCoreIjkProvider.getInstance())
3.3 Initializing the Multi-Scene SDK
The Multi-Scene SDK needs to be initialized in the onWindowStageCreate method of the module's Ability. You can refer to the PLVEntryAbility class in the demo project:
PLVLiveSceneSDK.init(context, windowStage)
3.4 Navigating to the Live Watch Page
The demo module provides two pages:
PLVLoginPageis the login page for the project demo, demonstrating how to navigate to the live watch page.PLVLWWatchPageis the live watch page, supporting live streaming and playback videos, as well as chat room and interactive features.
You can navigate to the live watch page from any page in your project based on your actual needs.
3.5 Parameter Modification
To play videos from your account in the demo project, you need to configure the login parameters required by the project.
In the demo project, login parameters are configured in the PLVLoginPage class under the pages folder:
- liveUserId/playbackUserId: Account ID
- liveChannelId/playbackChannelId: Channel ID
- liveAppId/playbackAppId: App ID
- liveAppSecret/playbackAppSecret: App Secret
- playbackVid: Playback Video ID
- viewerId: Student (User) ID
- viewerName: Student (User) Nickname
- viewerAvatar: Student (User) Avatar URL
