tencent cloud

腾讯云超级应用服务

动态与公告
【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
产品简介
产品概述
产品优势
应用场景
购买指南
计费概述
按量计费(后付费)
续费指引
停服说明
快速入门
套餐管理
概述
控制台账号管理
存储配置
加速配置
品牌化配置
平台功能
控制台登录
用户和权限体系
小程序管理
小游戏管理
应用管理
商业化
平台管理
用户管理
团队管理
运营管理
安全中心
代码接入指引
Demo 及 SDK 获取
Android
iOS
Flutter
App 服务端接入指南
GUID 生成规则
小程序开发指南
小程序介绍与开发环境
小程序代码组成
指南
框架
组件
API
服务端
JS SDK
基础库
IDE 使用指南
小游戏开发指南
指南
API
服务端
实践教程
小程序登录实践教程
小程序订阅消息实践教程
支付相关实践教程
广告接入实践教程
小游戏订阅消息实践教程
相关协议
数据处理和安全协议

实时音视频

PDF
フォーカスモード
フォントサイズ
最終更新日: 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
-
接口调用结束的回调函数(调用成功、失败都会执行)


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック