Back to Uni App

Create Live Pusher Context

docs/api/create-live-pusher-context.md

2.3.39.5 KB
Original Source
<!-- ## uni.createLivePusherContext() @createlivepushercontext -->

::: sourceCode

uni.createLivePusherContext(livePusherId, component?) @createlivepushercontext

:::

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

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

createLivePusherContext 兼容性

Web微信小程序AndroidiOSHarmonyOS
<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a><a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>4.814.81<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
livePusherIdstring-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x
componentComponentPublicInstance-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x

返回值

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

LivePusherContext 的方法 @livepushercontext-values

start(options? : LivePusherOptions) : void @start

start 开始推流

start 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x

options 的属性描述

名称类型必备默认值兼容性描述
success(res: UTSJSONObject) => void-Web: x; 微信小程序: x; Android: 4.81; iOS: 4.81; HarmonyOS: x接口调用成功的回调函数
fail(res: UTSJSONObject) => void-Web: x; 微信小程序: x; Android: 4.81; iOS: 4.81; HarmonyOS: x接口调用失败的回调函数
complete(res: any) => void-Web: x; 微信小程序: x; Android: 4.81; iOS: 4.81; HarmonyOS: x接口调用结束的回调函数(调用成功、失败都会执行)

stop(options? : LivePusherOptions) : void @stop

stop 停止推流

stop 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

switchCamera(options? : LivePusherOptions) : void @switchcamera

switchCamera 切换前后摄像头

switchCamera 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

toggleTorch(options? : LivePusherOptions) : void @toggletorch

toggleTorch 开关闪光灯

toggleTorch 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

pause(options? : LivePusherOptions) : void @pause

pause 暂停推流

pause 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

resume(options? : LivePusherOptions) : void @resume

resume 恢复推流

resume 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

getMaxZoom(options? : LivePusherOptions) : void @getmaxzoom

getMaxZoom 获取最大缩放值

getMaxZoom 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

setZoom(zoom : number, options? : LivePusherOptions) : void @setzoom

setZoom 设置缩放

setZoom 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
zoomnumber-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

startPreview(options? : LivePusherOptions) : void @startpreview

startPreview 开启摄像头预览

startPreview 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

stopPreview(options? : LivePusherOptions) : void @stoppreview

stopPreview 关闭摄像头预览

stopPreview 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

snapshot(options? : LivePusherOptions) : void @snapshot

snapshot 快照

snapshot 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx4.814.81x
参数
名称类型必填默认值兼容性描述
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-

sendMessage(message : string, options? : LivePusherOptions) : void @sendmessage

sendMessage

sendMessage 兼容性
Web微信小程序AndroidiOSHarmonyOS
xx--x
参数
名称类型必填默认值兼容性描述
messagestring-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x
optionsLivePusherOptions-Web: x; 微信小程序: x; Android: -; iOS: -; HarmonyOS: x-
<!-- UTSAPIJSON.createLivePusherContext.example -->

参见

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

<!-- UTSAPIJSON.createLivePusherContext.example -->

通用类型

GeneralCallbackResult

名称类型必备默认值兼容性描述
errMsgstring-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -错误信息