uni.createLivePusherContext(livePusherId, component?)
创建并返回 live-pusher 组件上下文 LivePusherContext 对象
参考文档:
live-pusher组件文档
createLivePusherContext 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
livePusherId | string | 是 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| |
component | ComponentPublicInstance | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| |
返回值
LivePusherContext 的方法
start(options? : LivePusherOptions) : void
start
开始推流
start 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | success | (res: UTSJSONObject) => void | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | 4.81 | 4.81 | x |
| 接口调用成功的回调函数 | fail | (res: UTSJSONObject) => void | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | 4.81 | 4.81 | x |
| 接口调用失败的回调函数 | complete | (res: any) => void | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | 4.81 | 4.81 | x |
| 接口调用结束的回调函数(调用成功、失败都会执行) |
|
stop(options? : LivePusherOptions) : void
stop
停止推流
stop 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
switchCamera(options? : LivePusherOptions) : void
switchCamera
切换前后摄像头
switchCamera 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
toggleTorch(options? : LivePusherOptions) : void
toggleTorch
开关闪光灯
toggleTorch 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
pause(options? : LivePusherOptions) : void
pause
暂停推流
pause 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
resume(options? : LivePusherOptions) : void
resume
恢复推流
resume 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
getMaxZoom(options? : LivePusherOptions) : void
getMaxZoom
获取最大缩放值
getMaxZoom 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
setZoom(zoom : number, options? : LivePusherOptions) : void
setZoom
设置缩放
setZoom 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
zoom | number | 是 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
startPreview(options? : LivePusherOptions) : void
startPreview
开启摄像头预览
startPreview 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
stopPreview(options? : LivePusherOptions) : void
stopPreview
关闭摄像头预览
stopPreview 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
snapshot(options? : LivePusherOptions) : void
snapshot
快照
snapshot 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | 4.81 | 4.81 | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
sendMessage(message : string, options? : LivePusherOptions) : void
sendMessage
sendMessage 兼容性
Web | 微信小程序 | Android | iOS | HarmonyOS |
x | x | - | - | x |
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
message | string | 是 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| |
options | LivePusherOptions | 否 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| x | x | - | - | x |
| - |
参见
示例代码另见live-pusher组件文档
通用类型
GeneralCallbackResult
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
errMsg | string | 是 | - |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| - | 4.41 | - | - | - |
| 错误信息 |