Skip to main content
Version: 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自动推流
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设置色彩滤镜
onStateChangeCommonEventFunction<onStateChangeEventDetail>状态变化事件,detail = {code}
onNetstatusCommonEventFunction<onNetstatusEventDetail>网络状态通知,detail = {info}
onErrorCommonEventFunction<onErrorEventDetail>渲染错误事件,detail = {errMsg, errCode}
onBgmStartCommonEventFunction背景音开始播放时触发
onBgmProgressCommonEventFunction<onBgmProgressEventDetail>背景音进度变化时触发,detail = {progress, duration}
onBgmCompleteCommonEventFunction背景音播放完成时触发
onAudioVolumeNotifyCommonEventFunction返回麦克风采集的音量大小

API 支持度

API微信小程序H5React Native
LivePusherProps.url✔️
LivePusherProps.mode✔️
LivePusherProps.autopush✔️
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.onStateChange✔️
LivePusherProps.onNetstatus✔️
LivePusherProps.onError✔️
LivePusherProps.onBgmStart✔️
LivePusherProps.onBgmProgress✔️
LivePusherProps.onBgmComplete✔️
LivePusherProps.onAudioVolumeNotify✔️

Orientation

orientation 的合法值

参数说明
vertical竖直
horizontal水平

LocalMirror

localMirror 的合法值

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

AudioReverbType

audioReverbType 的合法值

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

AudioVolumeType

audioVolumeType 的合法值

参数说明
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持续时间