跳到主要内容
版本:3.x

LivePusher

实时音视频录制。需要用户授权 scope.camera、scope.record 需要先通过类目审核,再在小程序管理后台,「开发」-「接口设置」中自助开通该组件权限。

支持情况:

参考文档

类型​

ComponentType<LivePusherProps>

示例代码​

class App extends Components {
render () {
return (
<LivePusher url='url' mode='RTC' autopush />
)
}
}

LivePusherProps​

实时音视频录制。 需要用户授权 scope.camera、scope.record 暂只针对国内主体如下类目的小程序开放,需要先通过类目审核,再在小程序管理后台,“设置”-“接口设置”中自助开通该组件权限。

参数类型默认值必填说明
urlstring否推流地址。目前仅支持 rtmp 格式
mode"SD" or "HD" or "FHD" or "RTC""RTC"否SD(标清), HD(高清), FHD(超清), RTC(实时通话)
autopushbooleanfalse否自动推流
enableVideoCustomRenderbooleanfalse否自定义渲染,允许开发者自行处理所采集的视频帧
mutedbooleanfalse否是否静音。即将废弃,可用 enable-mic 替代
不推荐使用
enableCamerabooleantrue否开启摄像头
autoFocusbooleantrue否自动聚集
orientationkeyof Orientation"vertical"否画面方向
beautynumber0否美颜,取值范围 0-9 ,0 表示关闭
whitenessnumber0否美白,取值范围 0-9 ,0 表示关闭
aspect"9:16" or "3:4""9:16"否宽高比,可选值有 3:4, 9:16
minBitratenumber200否最小码率
maxBitratenumber1000否最大码率
audioQualitystring"high"否高音质(48KHz)或低音质(16KHz),值为high, low
waitingImagestring否进入后台时推流的等待画面
waitingImageHashstring否等待画面资源的MD5值
zoombooleanfalse否调整焦距
devicePositionstring"front"否前置或后置,值为front, back
backgroundMutebooleanfalse否进入后台时是否静音
mirrorbooleanfalse否设置推流画面是否镜像,产生的效果在 LivePlayer 反应到
remoteMirrorbooleanfalse否设置推流画面是否镜像,产生的效果在 LivePlayer 反应到

Note: 同 mirror 属性,后续 mirror 将废弃
localMirrorkeyof LocalMirror"auto"否控制本地预览画面是否镜像
audioReverbTypekeyof AudioReverbType0否音频混响类型
enableMicbooleantrue否开启或关闭麦克风
enableAgcbooleanfalse否是否开启音频自动增益
enableAnsbooleanfalse否是否开启音频噪声抑制
audioVolumeTypekeyof AudioVolumeType"voicecall"否音量类型
videoWidthnumber360否上推的视频流的分辨率宽度
videoHeightnumber640否上推的视频流的分辨率高度
beautyStylekeyof BeautyStyleTypesmooth否设置美颜类型
filterkeyof FilterTypestandard否设置色彩滤镜
pictureInPictureModestring or any[]否设置小窗模式: push, pop,空字符串或通过数组形式设置多种模式(如: ["push", "pop"])
customEffectbooleanfalse否是否启动自定义特效,设定后不能更改
skinWhitenessnumber0否自定义特效美白效果,取值 0~1。需要开启 custom-effect
skinSmoothnessnumber0否自定义特效磨皮效果,取值 0~1。需要开启 custom-effect
faceThinnessnumber0否自定义特效瘦脸效果,取值 0~1。需要开启 custom-effect
eyeBignessnumber0否自定义特效大眼效果,取值 0~1。需要开启 custom-effect
voiceChangerTypenumber0否0:关闭变声;1:熊孩子;2:萝莉;3:大叔;4:重金属;6:外国人;7:困兽;8:死肥仔;9:强电流;10:重机械;11:空灵
fpsnumber15否帧率,有效值为 1~30
onStateChangeCommonEventFunction<onStateChangeEventDetail>否状态变化事件,detail = {code}
onErrorCommonEventFunction<onErrorEventDetail>否渲染错误事件,detail = {errMsg, errCode}
onBgmProgressCommonEventFunction<onBgmProgressEventDetail>否背景音进度变化时触发,detail = {progress, duration}
onBgmCompleteCommonEventFunction否背景音播放完成时触发
onAudioVolumeNotifyCommonEventFunction否返回麦克风采集的音量大小
onNetStatusCommonEventFunction否网络状态通知,detail = {info}
onEnterPictureInPicturestring否进入小窗
onLeavePictureInPicturestring否退出小窗
onBgmStartCommonEventFunction否背景音开始播放时触发

API 支持度​

API微信小程序QQ 小程序H5React NativeHarmony
LivePusherProps.url✔️✔️
LivePusherProps.mode✔️✔️
LivePusherProps.autopush✔️✔️
LivePusherProps.enableVideoCustomRender✔️
LivePusherProps.muted✔️✔️
LivePusherProps.enableCamera✔️✔️
LivePusherProps.autoFocus✔️✔️
LivePusherProps.orientation✔️✔️
LivePusherProps.beauty✔️✔️
LivePusherProps.whiteness✔️✔️
LivePusherProps.aspect✔️✔️
LivePusherProps.minBitrate✔️✔️
LivePusherProps.maxBitrate✔️✔️
LivePusherProps.audioQuality✔️✔️
LivePusherProps.waitingImage✔️✔️
LivePusherProps.waitingImageHash✔️✔️
LivePusherProps.zoom✔️✔️
LivePusherProps.devicePosition✔️✔️
LivePusherProps.backgroundMute✔️✔️
LivePusherProps.mirror✔️✔️
LivePusherProps.remoteMirror✔️
LivePusherProps.localMirror✔️
LivePusherProps.audioReverbType✔️✔️
LivePusherProps.enableMic✔️
LivePusherProps.enableAgc✔️
LivePusherProps.enableAns✔️
LivePusherProps.audioVolumeType✔️
LivePusherProps.videoWidth✔️
LivePusherProps.videoHeight✔️
LivePusherProps.beautyStyle✔️
LivePusherProps.filter✔️
LivePusherProps.pictureInPictureMode✔️
LivePusherProps.customEffect✔️
LivePusherProps.skinWhiteness✔️
LivePusherProps.skinSmoothness✔️
LivePusherProps.faceThinness✔️
LivePusherProps.eyeBigness✔️
LivePusherProps.voiceChangerType✔️
LivePusherProps.fps✔️
LivePusherProps.onStateChange✔️✔️
LivePusherProps.onError✔️✔️
LivePusherProps.onBgmProgress✔️✔️
LivePusherProps.onBgmComplete✔️✔️
LivePusherProps.onAudioVolumeNotify✔️
LivePusherProps.onNetStatus✔️✔️
LivePusherProps.onEnterPictureInPicture✔️
LivePusherProps.onLeavePictureInPicture✔️
LivePusherProps.onBgmStart✔️✔️

Orientation​

orientation 的合法值

参数说明
vertical竖直
horizontal水平

LocalMirror​

localMirror 的合法值

参数说明
auto前置摄像头镜像,后置摄像头不镜像
enable前后置摄像头均镜像
disable前后置摄像头均不镜像

AudioReverbType​

audioReverbType 的合法值

参数说明
0关闭
1KTV
2小房间
3大会堂
4低沉
5洪亮
6金属声
7磁性

AudioVolumeType​

audioVolumeType 的合法值

参数说明
auto自动
media媒体音量
voicecall通话音量

BeautyStyleType​

beautyStyleType 的合法值

参数说明
smooth光滑美颜
nature自然美颜

FilterType​

filterType 的合法值

参数说明
standard标准
pink粉嫩
nostalgia怀旧
blues蓝调
romantic浪漫
cool清凉
fresher清新
solor日系
aestheticism唯美
whitening美白
cerisered樱红

onStateChangeEventDetail​

参数类型说明
codenumber状态码

onNetstatusEventDetail​

参数类型说明
infoNetStatus网络状态

onErrorEventDetail​

参数类型说明
errMsgstring错误信息
errCodestring or number错误码

onBgmProgressEventDetail​

参数类型说明
progressany进展
durationnumber持续时间