tencent cloud

实时音视频
最后更新时间:2025-11-28 09:52:31
实时音视频
最后更新时间: 2025-11-28 09:52:31

createLivePusherContext

该 API 使用方法为 LivePusherContext wx.createLivePusherContext()
说明:
基础库 1.4.96 开始支持,低版本需做兼容处理。
功能说明:创建 live-pusher 上下文 LivePusherContext 对象。
返回值:LivePusherContext

LivePusherContext

LivePusherContext 实例,可通过 wx.createLivePusherContext
LivePusherContext 与页面内唯一的 live-pusher 组件绑定,操作对应的 live-pusher 组件。

.start

该方法使用方式为 LivePusherContext.start(Object object)
功能说明:开始推流,同时开启摄像头预览。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.stop

该方法使用方式为 LivePusherContext.stop(Object object)
功能说明:停止推流,同时停止摄像头预览。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.pause

该方法使用方式为 LivePlayerContext.pause(Object object)
功能说明:暂停推流。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.resume

该方法使用方式为 LivePusherContext.resume(Object object)
功能说明:恢复推流。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.switchCamera

该方法使用方式为 LivePusherContext.switchCamera(Object object)
功能说明:切换前后摄像头。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.snapshot

该方法使用方式为 LivePusherContext.snapshot(Object object)
功能说明:快照。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)
object.success回调函数:参数 Object res
属性
类型
说明
tempImagePath
string
图片文件的临时路径
width
string
图片的宽度
height
string
图片的高度

.toggleTorch

该方法使用方式为 LivePusherContext.toggleTorch(Object object)
功能说明:切换手电筒。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.playBGM

该方法使用方式为 LivePusherContext.playBGM(Object object)
功能说明:播放背景音。
参数及说明:Object object。
属性
类型
默认值
必填
说明
url
String
-
加入背景混音的资源地址
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.stopBGM

该方法使用方式为 LivePusherContext.stopBGM(Object object)
功能说明:停止背景音。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.pauseBGM

该方法使用方式为 LivePusherContext.pauseBGM(Object object)
功能说明:暂停背景音。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.resumeBGM

该方法使用方式为 LivePusherContext.resumeBGM(Object object)
功能说明:恢复背景音。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.setBGMPosition

该方法使用方式为 LivePusherContext.setBGMPosition(Object object)
功能说明:设置背景音进度。
参数及说明:Object object。
属性
类型
默认值
必填
说明
position
Number
-
背景音进度,单位:秒
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.setMICVolume

该方法使用方式为 LivePusherContext.setMICVolume(Object object)
功能说明:设置麦克风音量。
参数及说明:Object object。
属性
类型
默认值
必填
说明
volume
String
-
音量大小,范围是 0.0-1.0
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.setBGMVolume

该方法使用方式为 LivePusherContext.setBGMVolume(Object object)
功能说明:设置背景音音量。
参数及说明:Object object。
属性
类型
默认值
必填
说明
volume
String
-
音量大小,范围是 0.0-1.0
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.setAudioReverbType

该方法使用方式为 LivePusherContext.setAudioReverbType(Object object)
功能说明:设置混音类型。
参数及说明:Object object。
属性
类型
默认值
必填
说明
audioReverbType
Number
-
混音类型,0 ~ 6 分别对应 "关闭混响", "KTV", "小房间", "大会堂", "低沉", "洪亮", "磁性"
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.startPreview

该方法使用方式为 LivePusherContext.startPreview(Object object)
功能说明:开启摄像头预览。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.stopPreview

该方法使用方式为 LivePusherContext.stopPreview(Object object)
功能说明:关闭摄像头预览。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.startAudioRecord

该方法使用方式为 LivePusherContext.startAudioRecord(Object object)
功能说明:开始录音,当主动调用 LivePusherContext.stopAudioRecord 时,或者录音超过1分钟时自动结束录音。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.stopAudioRecord

该方法使用方式为 LivePusherContext.stopAudioRecord(Object object)
功能说明:结束录音。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)
object.success 回调函数参数:Object res。
属性
类型
说明
tempFilePath
String
录音文件的临时路径 (本地路径)

createLivePlayerContext

该 API 使用方法为 LivePlayerContext wx.createLivePlayerContext(string id, Object this)
说明:
基础库 1.4.96 开始支持,低版本需做兼容处理。
功能说明:创建 live-player 上下文 LivePlayerContext 对象。
参数及说明:
string id,live-player 组件的 id;
Object this,在自定义组件下,当前组件实例的 this,以操作组件内 live-player 组件。
返回值:LivePlayerContext

LivePlayerContext

.exitfullscreen

该方法使用方式为 LivePlayerContext.exitFullScreen(Object object)
功能说明:退出全屏。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.mute

该方法使用方式为 LivePlayerContext.mute(Object object)
功能说明:静音。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.pause

该方法使用方式为 LivePlayerContext.pause(Object object)
功能说明:暂停。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.play

该方法使用方式为 LivePlayerContext.play(Object object)
功能说明:播放。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.requestFullScreen

该方法使用方式为 LivePlayerContext.requestFullScreen(Object object)
功能说明:进入全屏。
参数及说明:Object object。
属性
类型
默认值
必填
说明
direction
Number
0
设置全屏时的方向
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)
object.direction 的合法值。
说明
0
正常竖向
90
屏幕逆时针 90 度
-90
屏幕顺时针 90 度

.resume

该方法使用方式为 LivePlayerContext.resume(Object object)
功能说明:恢复。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

.snapshot

该方法使用方式为 LivePlayerContext.snapshot(Object object)
功能说明:截图。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)
object.success 回调函数参数:Object res。
属性
类型
说明
tempImagePath
String
图片文件的临时路径
width
String
图片的宽度
height
String
图片的高度

.stop

该方法使用方式为 LivePlayerContext.stop(Object object)
功能说明:停止。
参数及说明:Object object。
属性
类型
默认值
必填
说明
success
Function
-
接口调用成功的回调函数
fail
Function
-
接口调用失败的回调函数
complete
Function
-
接口调用结束的回调函数(调用成功、失败都会执行)

本页内容是否解决了您的问题?
您也可以 联系销售 提交工单 以寻求帮助。

文档反馈