docs/api/create-live-player-context.md
::: sourceCode
:::
创建并返回 live-player 组件上下文 LivePlayerContext 对象
参考文档: live-player组件文档
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.81 | 4.81 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| livePlayerId | string | 是 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | |
| component | ComponentPublicInstance | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x |
| 类型 | 描述 | 必备 |
|---|---|---|
| LivePlayerContext | live-player 组件上下文对象 | 否 |
play 播放
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | x | 4.81 | 4.81 | x |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | LivePlayerOptions | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | 方法调用参数 |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| success | (res: UTSJSONObject) => void | 否 | - | Web: x; 微信小程序: x; Android: 4.81; iOS: 4.81; HarmonyOS: x | 接口调用成功的回调函数 |
| fail | (res: UTSJSONObject) => void | 否 | - | Web: x; 微信小程序: x; Android: 4.81; iOS: 4.81; HarmonyOS: x | 接口调用失败的回调函数 |
| complete | (res: any) => void | 否 | - | Web: x; 微信小程序: x; Android: 4.81; iOS: 4.81; HarmonyOS: x | 接口调用结束的回调函数(调用成功、失败都会执行) |
pause 暂停
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | x | 4.81 | 4.81 | x |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | LivePlayerOptions | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | 方法调用参数 |
stop 停止
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | x | 4.81 | 4.81 | x |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | LivePlayerOptions | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | 方法调用参数 |
resume 恢复
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | x | 4.81 | 4.81 | x |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | LivePlayerOptions | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | 方法调用参数 |
mute 静音
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | x | 4.81 | 4.81 | x |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | LivePlayerOptions | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | 方法调用参数 |
requestFullScreen 全屏
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | x | 4.81 | 4.81 | x |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | LivePlayerOptions | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | 方法调用参数 |
exitFullScreen 退出全屏
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | x | 4.81 | 4.81 | x |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | LivePlayerOptions | 否 | - | Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x | 方法调用参数 |
示例代码另见live-player组件文档
<!-- UTSAPIJSON.createLivePlayerContext.example -->| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| errMsg | string | 是 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 错误信息 |