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

方法
pause
暂停推流
支持情况:

(option?: PauseOption) => void
| 参数 | 类型 |
|---|---|
| option | PauseOption |
pauseBGM
暂停背景音
支持情况:

(option?: PauseBGMOption) => void
| 参数 | 类型 |
|---|---|
| option | PauseBGMOption |
playBGM
播放背景音
支持情况:

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

(option?: ResumeOption) => void
| 参数 | 类型 |
|---|---|
| option | ResumeOption |
resumeBGM
恢复背景音
支持情况:

(option?: ResumeBGMOption) => void
| 参数 | 类型 |
|---|---|
| option | ResumeBGMOption |
sendMessage
发送SEI消息
支持情况:

(option?: SendMessageOption) => void
| 参数 | 类型 |
|---|---|
| option | SendMessageOption |
setBGMVolume
设置背景音音量
支持情况:

(option: SetBGMVolumeOption) => void
| 参数 | 类型 |
|---|---|
| option | SetBGMVolumeOption |
setMICVolume
设置麦克风音量
支持情况:

(option: SetMICVolumeOption) => void
| 参数 | 类型 |
|---|---|
| option | SetMICVolumeOption |
snapshot
快照
支持情况:

(option?: SnapshotOption) => void
| 参数 | 类型 |
|---|---|
| option | SnapshotOption |
start
开始推流,同时开启摄像头预览
支持情况:

(option?: StartOption) => void
| 参数 | 类型 |
|---|---|
| option | StartOption |
startPreview
开启摄像头预览
支持情况:

(option?: StartPreviewOption) => void
| 参数 | 类型 |
|---|---|
| option | StartPreviewOption |
stop
停止推流,同时停止摄像头预览
支持情况:

(option?: StopOption) => void
| 参数 | 类型 |
|---|---|
| option | StopOption |
stopBGM
停止背景音
支持情况:

(option?: StopBGMOption) => void
| 参数 | 类型 |
|---|---|
| option | StopBGMOption |
stopPreview
关闭摄像头预览
支持情况:

(option?: StopPreviewOption) => void
| 参数 | 类型 |
|---|---|
| option | StopPreviewOption |
switchCamera
切换前后摄像头
支持情况:

(option?: SwitchCameraOption) => void
| 参数 | 类型 |
|---|---|
| option | SwitchCameraOption |
toggleTorch
切换手电筒
支持情况:

(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 | ✔️ |