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

方法
exitCasting
退出投屏。仅支持在 tap 事件回调内调用。
支持情况:

(option?: ExitCastingOption) => void
| 参数 | 类型 |
|---|---|
| option | ExitCastingOption |
exitFullScreen
退出全屏
支持情况:

(option?: ExitFullScreenOption) => void
| 参数 | 类型 |
|---|---|
| option | ExitFullScreenOption |
exitPictureInPicture
退出小窗,该方法可在任意页面调用
支持情况:

(option?: ExitPictureInPictureOption) => void
| 参数 | 类型 |
|---|---|
| option | ExitPictureInPictureOption |
mute
静音
支持情况:

(option?: MuteOption) => void
| 参数 | 类型 |
|---|---|
| option | MuteOption |
pause
暂停
支持情况:

(option?: PauseOption) => void
| 参数 | 类型 |
|---|---|
| option | PauseOption |
play
播放
支持情况:

(option?: PlayOption) => void
| 参数 | 类型 |
|---|---|
| option | PlayOption |
reconnectCasting
重连投屏设备。仅支持在 tap 事件回调内调用。
支持情况:

(option?: ReconnectCastingOption) => void
| 参数 | 类型 |
|---|---|
| option | ReconnectCastingOption |
requestFullScreen
进入全屏
支持情况:

(option: RequestFullScreenOption) => void
| 参数 | 类型 |
|---|---|
| option | RequestFullScreenOption |
requestPictureInPicture
进入全屏
支持情况:

(option: RequestPictureInPictureOption) => void
| 参数 | 类型 |
|---|---|
| option | RequestPictureInPictureOption |
resume
恢复
支持情况:

(option?: ResumeOption) => void
| 参数 | 类型 |
|---|---|
| option | ResumeOption |
snapshot
截图
支持情况:

(option?: SnapshotOption) => void
| 参数 | 类型 |
|---|---|
| option | SnapshotOption |
startCasting
开始投屏, 拉起半屏搜索设备。仅支持在 tap 事件回调内调用
支持情况:

(option?: StartCastingOption) => void
| 参数 | 类型 |
|---|---|
| option | StartCastingOption |
stop
停止
支持情况:

(option?: StopOption) => void
| 参数 | 类型 |
|---|---|
| option | StopOption |
switchCasting
切换投屏设备。仅支持在 tap 事件回调内调用。
支持情况:

(option?: SwitchCastingOption) => void
| 参数 | 类型 |
|---|---|
| option | SwitchCastingOption |
参数
ExitCastingOption
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| complete | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| fail | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用失败的回调函数 |
| success | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用成功的回调函数 |
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 | 否 | 接口调用成功的回调函数 |
ReconnectCastingOption
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| 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 | 调用结果 |
StartCastingOption
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| complete | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| fail | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用失败的回调函数 |
| success | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用成功的回调函数 |
StopOption
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| complete | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| fail | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用失败的回调函数 |
| success | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用成功的回调函数 |
SwitchCastingOption
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| complete | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| fail | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用失败的回调函数 |
| success | (res: TaroGeneral.CallbackResult) => void | 否 | 接口调用成功的回调函数 |
API 支持度
| API | 微信小程序 | H5 | React Native | Harmony |
|---|---|---|---|---|
| LivePlayerContext | ✔️ | |||
| LivePlayerContext.exitCasting | ✔️ | |||
| LivePlayerContext.exitFullScreen | ✔️ | |||
| LivePlayerContext.exitPictureInPicture | ✔️ | |||
| LivePlayerContext.mute | ✔️ | |||
| LivePlayerContext.pause | ✔️ | |||
| LivePlayerContext.play | ✔️ | |||
| LivePlayerContext.reconnectCasting | ✔️ | |||
| LivePlayerContext.requestFullScreen | ✔️ | |||
| LivePlayerContext.requestPictureInPicture | ✔️ | |||
| LivePlayerContext.resume | ✔️ | |||
| LivePlayerContext.snapshot | ✔️ | |||
| LivePlayerContext.startCasting | ✔️ | |||
| LivePlayerContext.stop | ✔️ | |||
| LivePlayerContext.switchCasting | ✔️ |