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