uni.createLivePlayerContext(livePlayerId, component?)
创建并返回 live-player 组件上下文 LivePlayerContext 对象
参考文档:
live-player组件文档
createLivePlayerContext 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
返回值
LivePlayerContext 的方法
play(options?: LivePlayerOptions) : void
play
播放
play 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| options | LivePlayerOptions | 否 | | | 方法调用参数 |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | | success | (res: UTSJSONObject) => void | 否 | | | 接口调用成功的回调函数 | | fail | (res: UTSJSONObject) => void | 否 | | | 接口调用失败的回调函数 | | complete | (res: any) => void | 否 | | | 接口调用结束的回调函数(调用成功、失败都会执行) |
|
pause(options?: LivePlayerOptions) : void
pause
暂停
pause 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
stop(options?: LivePlayerOptions) : void
stop
停止
stop 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
resume(options?: LivePlayerOptions) : void
resume
恢复
resume 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
mute(options?: LivePlayerOptions): void
mute
静音
mute 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
requestFullScreen(options?: LivePlayerOptions): void
requestFullScreen
全屏
requestFullScreen 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
exitFullScreen(options?: LivePlayerOptions): void
exitFullScreen
退出全屏
exitFullScreen 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | 4.81 | x |
参数
参见
示例代码另见live-player组件文档
通用类型
GeneralCallbackResult
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| errMsg | string | 是 | | | 错误信息 |