# uni.createLivePusherContext(livePusherId, component?)

创建并返回 live-pusher 组件上下文 LivePusherContext 对象

参考文档: live-pusher组件文档

# createLivePusherContext 兼容性

Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x

# 参数

名称 类型 必填 默认值 兼容性 描述
livePusherId string -
component ComponentPublicInstance -

# 返回值

类型 描述 必备
LivePusherContext live-pusher 组件上下文对象

# 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 -
-

# switchCamera(options? : LivePusherOptions) : void

switchCamera 切换前后摄像头

# switchCamera 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# toggleTorch(options? : LivePusherOptions) : void

toggleTorch 开关闪光灯

# toggleTorch 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# pause(options? : LivePusherOptions) : void

pause 暂停推流

# pause 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# resume(options? : LivePusherOptions) : void

resume 恢复推流

# resume 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# getMaxZoom(options? : LivePusherOptions) : void

getMaxZoom 获取最大缩放值

# getMaxZoom 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# setZoom(zoom : number, options? : LivePusherOptions) : void

setZoom 设置缩放

# setZoom 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
zoom number -
options LivePusherOptions -
-

# startPreview(options? : LivePusherOptions) : void

startPreview 开启摄像头预览

# startPreview 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# stopPreview(options? : LivePusherOptions) : void

stopPreview 关闭摄像头预览

# stopPreview 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# snapshot(options? : LivePusherOptions) : void

snapshot 快照

# snapshot 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x 4.81 4.81 x
# 参数
名称 类型 必填 默认值 兼容性 描述
options LivePusherOptions -
-

# sendMessage(message : string, options? : LivePusherOptions) : void

sendMessage

# sendMessage 兼容性
Web 微信小程序 Android iOS HarmonyOS
x x - - x
# 参数
名称 类型 必填 默认值 兼容性 描述
message string -
options LivePusherOptions -
-

# 参见

示例代码另见live-pusher组件文档

# 通用类型

# GeneralCallbackResult

名称 类型 必备 默认值 兼容性 描述
errMsg string -
错误信息