LivePusherContext
The LivePusherContext instance can be obtained with Taro.createLivePusherContext.
LivePusherContext is bound to the unique live-pusher component on the page to use the live-pusher component.
Methods
pause
Pauses stream pushing
(option?: PauseOption) => void
| Property | Type |
|---|---|
| option | PauseOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.pause | ✔️ |
pauseBGM
Pauses BGM
(option?: PauseBGMOption) => void
| Property | Type |
|---|---|
| option | PauseBGMOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.pauseBGM | ✔️ |
playBGM
Plays BGM
(option: PlayBGMOption) => void
| Property | Type |
|---|---|
| option | PlayBGMOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.playBGM | ✔️ |
resume
Resumes stream pushing
(option?: ResumeOption) => void
| Property | Type |
|---|---|
| option | ResumeOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.resume | ✔️ |
resumeBGM
Resumes BGM
(option?: ResumeBGMOption) => void
| Property | Type |
|---|---|
| option | ResumeBGMOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.resumeBGM | ✔️ |
setBGMVolume
Sets BGM volume
(option: SetBGMVolumeOption) => void
| Property | Type |
|---|---|
| option | SetBGMVolumeOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.setBGMVolume | ✔️ |
snapshot
Snapshot
(option?: SnapshotOption) => void
| Property | Type |
|---|---|
| option | SnapshotOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.snapshot | ✔️ |
start
Starts stream pushing and enables camera preview
(option?: StartOption) => void
| Property | Type |
|---|---|
| option | StartOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.start | ✔️ |
startPreview
Enables camera preview
(option?: StartPreviewOption) => void
| Property | Type |
|---|---|
| option | StartPreviewOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.startPreview | ✔️ |
stop
Stops stream pushing and stops camera preview
(option?: StopOption) => void
| Property | Type |
|---|---|
| option | StopOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.stop | ✔️ |
stopBGM
Stops BGM
(option?: StopBGMOption) => void
| Property | Type |
|---|---|
| option | StopBGMOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.stopBGM | ✔️ |
stopPreview
Disables camera preview
(option?: StopPreviewOption) => void
| Property | Type |
|---|---|
| option | StopPreviewOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.stopPreview | ✔️ |
switchCamera
Switches between the front and rear cameras
(option?: SwitchCameraOption) => void
| Property | Type |
|---|---|
| option | SwitchCameraOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.switchCamera | ✔️ |
toggleTorch
Toggles torch
(option?: ToggleTorchOption) => void
| Property | Type |
|---|---|
| option | ToggleTorchOption |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.toggleTorch | ✔️ |
Parameters
PauseOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
PauseBGMOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
PlayBGMOption
| Property | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | The URL of the audio added to the BGM |
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
ResumeOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
ResumeBGMOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
SetBGMVolumeOption
| Property | Type | Required | Description |
|---|---|---|---|
| volume | string | Yes | Volume. Its values range from 0 to 1. |
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
SnapshotOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
StartOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
StartPreviewOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
StopOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
StopBGMOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
StopPreviewOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
SwitchCameraOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
ToggleTorchOption
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| LivePusherContext.pause | ✔️ | ||
| LivePusherContext.pauseBGM | ✔️ | ||
| LivePusherContext.playBGM | ✔️ | ||
| LivePusherContext.resume | ✔️ | ||
| LivePusherContext.resumeBGM | ✔️ | ||
| LivePusherContext.setBGMVolume | ✔️ | ||
| LivePusherContext.snapshot | ✔️ | ||
| LivePusherContext.start | ✔️ | ||
| LivePusherContext.startPreview | ✔️ | ||
| LivePusherContext.stop | ✔️ | ||
| LivePusherContext.stopBGM | ✔️ | ||
| LivePusherContext.stopPreview | ✔️ | ||
| LivePusherContext.switchCamera | ✔️ | ||
| LivePusherContext.toggleTorch | ✔️ |