title: LivePusherContext

sidebar_label: LivePusherContext

LivePusherContext 实例,可通过 Taro.createLivePusherContext 获取。 LivePusherContext 与页面内唯一的 live-pusher 组件绑定,操作对应的 live-pusher 组件。

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

参考文档

方法

pause

暂停推流

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

参考文档

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

pauseBGM

暂停背景音

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

参考文档

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

playBGM

播放背景音

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

参考文档

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

resume

恢复推流

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

参考文档

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

resumeBGM

恢复背景音

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

参考文档

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

sendMessage

发送SEI消息

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

参考文档

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

setBGMVolume

设置背景音音量

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

参考文档

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

setMICVolume

设置麦克风音量

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

参考文档

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

snapshot

快照

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

参考文档

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

start

开始推流,同时开启摄像头预览

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

参考文档

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

startPreview

开启摄像头预览

支持情况:LivePusherContext - 图34 LivePusherContext - 图35 LivePusherContext - 图36

参考文档

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

stop

停止推流,同时停止摄像头预览

支持情况:LivePusherContext - 图37 LivePusherContext - 图38 LivePusherContext - 图39

参考文档

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

stopBGM

停止背景音

支持情况:LivePusherContext - 图40 LivePusherContext - 图41 LivePusherContext - 图42

参考文档

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

stopPreview

关闭摄像头预览

支持情况:LivePusherContext - 图43 LivePusherContext - 图44 LivePusherContext - 图45

参考文档

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

switchCamera

切换前后摄像头

支持情况:LivePusherContext - 图46 LivePusherContext - 图47 LivePusherContext - 图48

参考文档

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

toggleTorch

切换手电筒

支持情况:LivePusherContext - 图49 LivePusherContext - 图50 LivePusherContext - 图51

参考文档

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

参数

PauseOption

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

PauseBGMOption

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

PlayBGMOption

参数 类型 必填 说明
url string 加入背景混音的资源地址
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 接口调用成功的回调函数

ResumeBGMOption

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

SendMessageOption

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

SetBGMVolumeOption

参数 类型 必填 说明
volume number 音量大小,范围是 0-1
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

SetMICVolumeOption

参数 类型 必填 说明
volume number 音量大小,范围是 0-1
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 (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

StartOption

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

StartPreviewOption

参数 类型 必填 说明
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 接口调用成功的回调函数

StopBGMOption

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

StopPreviewOption

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

SwitchCameraOption

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

ToggleTorchOption

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

API 支持度

API 微信小程序 H5 React Native
LivePusherContext ✔️
LivePusherContext.pause ✔️
LivePusherContext.pauseBGM ✔️
LivePusherContext.playBGM ✔️
LivePusherContext.resume ✔️
LivePusherContext.resumeBGM ✔️
LivePusherContext.sendMessage ✔️
LivePusherContext.setBGMVolume ✔️
LivePusherContext.setMICVolume ✔️
LivePusherContext.snapshot ✔️
LivePusherContext.start ✔️
LivePusherContext.startPreview ✔️
LivePusherContext.stop ✔️
LivePusherContext.stopBGM ✔️
LivePusherContext.stopPreview ✔️
LivePusherContext.switchCamera ✔️
LivePusherContext.toggleTorch ✔️