2_3-快速集成-鸿蒙
1 Preparation
Download the project demo in advance and prepare a URL, preferably a viewing URL for Polyv Cloud Live or Cloud Video on Demand, to experience the full functionality.
2 Environment Requirements
| Name | Requirement |
|---|---|
| compatibleSdkVersion | >= 4.1.0(11) |
3 Project Configuration
3.1 Integrate SDK
Modify the oh-package.json5 file of the module to integrate the SDK.
"dependencies": {
// WebViewSDK
"plvwebsdk": "version"
}
3.2 Required Permissions
The permissions required by the current SDK are as follows:
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.GET_NETWORK_INFO"
},
{
"name": "ohos.permission.CAMERA",
"reason": "$string:plv_permission_camera_reason",
"usedScene": {
"when": "inuse"
}
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "$string:plv_permission_microphone_reason",
"usedScene": {
"when": "inuse"
}
}
]
3.3 Page Navigation
The demo provides two pages for navigation:
PLVInputPageis the entry page for a single WebView page demo, demonstrating how to configure and use a single WebView page.PLVFeedWebPageis the entry page for multiple WebView pages demo, demonstrating the use of WebView pages in a Feed stream.
You can choose which page to integrate based on your project needs.
3.4 Project Configuration
Please configure the following core code in EntryAbility:
export default class PLVEntryAbility extends UIAbility {
...
onWindowStageCreate(windowStage: window.WindowStage): void {
// demo核心代码, 绑定windowStage
PLVWebViewWindowManager.setWindowStage(windowStage)
....
}
onForeground(): void {
// Ability has brought to foreground
PLVLogger.info(TAG, 'Ability onForeground');
// demo核心代码
PLVWebViewWindowManager?.onForeground()
}
onBackground(): void {
// Ability has back to background
PLVLogger.info(TAG, 'Ability onBackground');
// demo核心代码
PLVWebViewWindowManager?.onBackground()
}
}
Ensure that PLVWebViewWindowManager.setWindowStage(windowStage) is called before using the floating window feature.
The floating window feature relies on windowStage to function.
3.5 Parameter Modification
All parameter configurations in the demo are set in PLVWebViewConfig. You can choose the UA to use, the video playback URL, whether to enable floating windows, etc.
注意:如果需要到Saas页面的小窗功能的情况,必须在UA中带上Android和PLVUAConfig.defaultUA字段
PLVWebViewConfig()
.setUrl("https://www.polyv.net") // 设置需要加载Url
.setUa("Android" + PLVUAConfig.defaultUA) // 设置当前UA
.setSupportAutoFloating(false) // 设置是否支持自动小窗
.setAllowFloatingWindow(true) // 设置是否支持开启小窗功能
Configure accordingly based on your requirements.
For more detailed features, refer to the complete project demo.
