Back to Uni App

Create Live Player Context

docs/api/create-live-player-context.md

2.3.37.0 KB
Original Source
<!-- ## uni.createLivePlayerContext() @createliveplayercontext -->

::: sourceCode

uni.createLivePlayerContext(livePlayerId, component?) @createliveplayercontext

:::

创建并返回 live-player 组件上下文 LivePlayerContext 对象

参考文档: live-player组件文档

createLivePlayerContext 兼容性

Web微信小程序AndroidiOSHarmonyOS
<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.814.81<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
livePlayerIdstring-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x
componentComponentPublicInstance-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x

返回值

类型描述必备
LivePlayerContextlive-player 组件上下文对象

LivePlayerContext 的方法 @liveplayercontext-values

play(options?: LivePlayerOptions) : void @play

play 播放

play 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePlayerOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x方法调用参数

options 的属性描述

名称类型必备默认值兼容性描述
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(options?: LivePlayerOptions) : void @pause

pause 暂停

pause 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePlayerOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x方法调用参数

stop(options?: LivePlayerOptions) : void @stop

stop 停止

stop 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePlayerOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x方法调用参数

resume(options?: LivePlayerOptions) : void @resume

resume 恢复

resume 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePlayerOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x方法调用参数

mute(options?: LivePlayerOptions): void @mute

mute 静音

mute 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePlayerOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x方法调用参数

requestFullScreen(options?: LivePlayerOptions): void @requestfullscreen

requestFullScreen 全屏

requestFullScreen 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePlayerOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x方法调用参数

exitFullScreen(options?: LivePlayerOptions): void @exitfullscreen

exitFullScreen 退出全屏

exitFullScreen 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePlayerOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x方法调用参数
<!-- UTSAPIJSON.createLivePlayerContext.example -->

参见

示例代码另见live-player组件文档

<!-- UTSAPIJSON.createLivePlayerContext.example -->

通用类型

GeneralCallbackResult

名称类型必备默认值兼容性描述
errMsgstring-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -错误信息