title: LivePlayerContext

sidebar_label: LivePlayerContext

LivePlayerContext 实例,可通过 Taro.createLivePlayerContext 获取。 LivePlayerContext 通过 id 跟一个 live-player 组件绑定,操作对应的 live-player 组件。

支持情况:LivePlayerContext - 图1 LivePlayerContext - 图2 LivePlayerContext - 图3

参考文档

方法

exitFullScreen

退出全屏

支持情况:LivePlayerContext - 图4 LivePlayerContext - 图5 LivePlayerContext - 图6

参考文档

  1. (option?: ExitFullScreenOption) => void
参数 类型
option ExitFullScreenOption

exitPictureInPicture

退出小窗,该方法可在任意页面调用

支持情况:LivePlayerContext - 图7 LivePlayerContext - 图8 LivePlayerContext - 图9

参考文档

  1. (option?: ExitPictureInPictureOption) => void
参数 类型
option ExitPictureInPictureOption

mute

静音

支持情况:LivePlayerContext - 图10 LivePlayerContext - 图11 LivePlayerContext - 图12

参考文档

  1. (option?: MuteOption) => void
参数 类型
option MuteOption

pause

暂停

支持情况:LivePlayerContext - 图13 LivePlayerContext - 图14 LivePlayerContext - 图15

参考文档

  1. (option?: PauseOption) => void
参数 类型
option PauseOption

play

播放

支持情况:LivePlayerContext - 图16 LivePlayerContext - 图17 LivePlayerContext - 图18

参考文档

  1. (option?: PlayOption) => void
参数 类型
option PlayOption

requestFullScreen

进入全屏

支持情况:LivePlayerContext - 图19 LivePlayerContext - 图20 LivePlayerContext - 图21

参考文档

  1. (option: RequestFullScreenOption) => void
参数 类型
option RequestFullScreenOption

requestPictureInPicture

进入全屏

支持情况:LivePlayerContext - 图22 LivePlayerContext - 图23 LivePlayerContext - 图24

参考文档

  1. (option: RequestPictureInPictureOption) => void
参数 类型
option RequestPictureInPictureOption

resume

恢复

支持情况:LivePlayerContext - 图25 LivePlayerContext - 图26 LivePlayerContext - 图27

参考文档

  1. (option?: ResumeOption) => void
参数 类型
option ResumeOption

snapshot

截图

支持情况:LivePlayerContext - 图28 LivePlayerContext - 图29 LivePlayerContext - 图30

参考文档

  1. (option?: SnapshotOption) => void
参数 类型
option SnapshotOption

stop

停止

支持情况:LivePlayerContext - 图31 LivePlayerContext - 图32 LivePlayerContext - 图33

参考文档

  1. (option?: StopOption) => void
参数 类型
option StopOption

参数

ExitFullScreenOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

ExitPictureInPictureOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

MuteOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

PauseOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

PlayOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

RequestFullScreenOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
direction 0 or 90 or -90 设置全屏时的方向

可选值:
- 0: 正常竖向;
- 90: 屏幕逆时针90度;
- -90: 屏幕顺时针90度;
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

RequestPictureInPictureOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

ResumeOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

SnapshotOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (result: SnapshotSuccessCallbackResult) => void 接口调用成功的回调函数

SnapshotSuccessCallbackResult

参数 类型 说明
height string 图片的高度
tempImagePath string 图片文件的临时路径
width string 图片的宽度
errMsg string 调用结果

StopOption

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

API 支持度

API 微信小程序 H5 React Native
LivePlayerContext ✔️
LivePlayerContext.exitFullScreen ✔️
LivePlayerContext.exitPictureInPicture ✔️
LivePlayerContext.mute ✔️
LivePlayerContext.pause ✔️
LivePlayerContext.play ✔️
LivePlayerContext.requestFullScreen ✔️
LivePlayerContext.requestPictureInPicture ✔️
LivePlayerContext.resume ✔️
LivePlayerContext.snapshot ✔️
LivePlayerContext.stop ✔️