1 | import { ComponentType } from 'react'
|
2 | import { StandardProps, CommonEventFunction, NetStatus } from './common'
|
3 |
|
4 | /** 实时音视频录制。
|
5 | * 需要用户授权 scope.camera、scope.record
|
6 | * 暂只针对国内主体如下类目的小程序开放,需要先通过类目审核,再在小程序管理后台,“设置”-“接口设置”中自助开通该组件权限。
|
7 | */
|
8 | interface LivePusherProps extends StandardProps {
|
9 | /** 推流地址。目前仅支持 rtmp 格式
|
10 | * @supported weapp
|
11 | */
|
12 | url?: string
|
13 |
|
14 | /** SD(标清), HD(高清), FHD(超清), RTC(实时通话)
|
15 | * @default "RTC"
|
16 | * @supported weapp
|
17 | */
|
18 | mode?: 'SD' | 'HD' | 'FHD' | 'RTC'
|
19 |
|
20 | /** 自动推流
|
21 | * @default false
|
22 | * @supported weapp
|
23 | */
|
24 | autopush?: boolean
|
25 |
|
26 | /** 是否静音。即将废弃,可用 enable-mic 替代
|
27 | * @default false
|
28 | * @deprecated
|
29 | * @supported weapp
|
30 | */
|
31 | muted?: boolean
|
32 |
|
33 | /** 开启摄像头
|
34 | * @default true
|
35 | * @supported weapp
|
36 | */
|
37 | enableCamera?: boolean
|
38 |
|
39 | /** 自动聚集
|
40 | * @default true
|
41 | * @supported weapp
|
42 | */
|
43 | autoFocus?: boolean
|
44 |
|
45 | /** 画面方向
|
46 | * @default "vertical"
|
47 | * @supported weapp
|
48 | */
|
49 | orientation?: keyof LivePusherProps.Orientation
|
50 |
|
51 | /** 美颜,取值范围 0-9 ,0 表示关闭
|
52 | * @default 0
|
53 | * @supported weapp
|
54 | */
|
55 | beauty?: number
|
56 |
|
57 | /** 美白,取值范围 0-9 ,0 表示关闭
|
58 | * @default 0
|
59 | * @supported weapp
|
60 | */
|
61 | whiteness?: number
|
62 |
|
63 | /** 宽高比,可选值有 3:4, 9:16
|
64 | * @default "9:16"
|
65 | * @supported weapp
|
66 | */
|
67 | aspect?: '9:16' | '3:4'
|
68 |
|
69 | /** 最小码率
|
70 | * @default 200
|
71 | * @supported weapp
|
72 | */
|
73 | minBitrate?: number
|
74 |
|
75 | /** 最大码率
|
76 | * @default 1000
|
77 | * @supported weapp
|
78 | */
|
79 | maxBitrate?: number
|
80 |
|
81 | /** 高音质(48KHz)或低音质(16KHz),值为high, low
|
82 | * @default "high"
|
83 | * @supported weapp
|
84 | */
|
85 | audioQuality?: string
|
86 |
|
87 | /** 进入后台时推流的等待画面
|
88 | * @supported weapp
|
89 | */
|
90 | waitingImage?: string
|
91 |
|
92 | /** 等待画面资源的MD5值
|
93 | * @supported weapp
|
94 | */
|
95 | waitingImageHash?: string
|
96 |
|
97 | /** 调整焦距
|
98 | * @default false
|
99 | * @supported weapp
|
100 | */
|
101 | zoom?: boolean
|
102 |
|
103 | /** 前置或后置,值为front, back
|
104 | * @default "front"
|
105 | * @supported weapp
|
106 | */
|
107 | devicePosition?: string
|
108 |
|
109 | /** 进入后台时是否静音
|
110 | * @default false
|
111 | * @supported weapp
|
112 | */
|
113 | backgroundMute?: boolean
|
114 |
|
115 | /** 设置推流画面是否镜像,产生的效果在 LivePlayer 反应到
|
116 | * @default false
|
117 | * @supported weapp
|
118 | * @deprecated
|
119 | */
|
120 | mirror?: boolean
|
121 |
|
122 | /** 设置推流画面是否镜像,产生的效果在 LivePlayer 反应到
|
123 | *
|
124 | * **Note:** 同 mirror 属性,后续 mirror 将废弃
|
125 | * @default false
|
126 | * @supported weapp
|
127 | */
|
128 | remoteMirror?: boolean
|
129 |
|
130 | /** 控制本地预览画面是否镜像
|
131 | * @default "auto"
|
132 | * @supported weapp
|
133 | */
|
134 | localMirror?: keyof LivePusherProps.LocalMirror
|
135 |
|
136 | /** 音频混响类型
|
137 | * @default 0
|
138 | * @supported weapp
|
139 | */
|
140 | audioReverbType?: keyof LivePusherProps.AudioReverbType
|
141 |
|
142 | /** 开启或关闭麦克风
|
143 | * @default true
|
144 | * @supported weapp
|
145 | */
|
146 | enableMic?: boolean
|
147 |
|
148 | /** 是否开启音频自动增益
|
149 | * @default false
|
150 | * @supported weapp
|
151 | */
|
152 | enableAgc?: boolean
|
153 |
|
154 | /** 是否开启音频噪声抑制
|
155 | * @default false
|
156 | * @supported weapp
|
157 | */
|
158 | enableAns?: boolean
|
159 |
|
160 | /** 音量类型
|
161 | * @default "voicecall"
|
162 | * @supported weapp
|
163 | */
|
164 | audioVolumeType?: keyof LivePusherProps.AudioVolumeType
|
165 |
|
166 | /** 上推的视频流的分辨率宽度
|
167 | * @default 360
|
168 | * @supported weapp
|
169 | */
|
170 | videoWidth?: number
|
171 |
|
172 | /** 上推的视频流的分辨率高度
|
173 | * @default 640
|
174 | * @supported weapp
|
175 | */
|
176 | videoHeight?: number
|
177 |
|
178 | /** 设置美颜类型
|
179 | * @default smooth
|
180 | * @supported weapp
|
181 | */
|
182 | beautyStyle?: keyof LivePusherProps.BeautyStyleType
|
183 |
|
184 | /** 设置色彩滤镜
|
185 | * @default standard
|
186 | * @supported weapp
|
187 | */
|
188 | filter?: keyof LivePusherProps.FilterType
|
189 |
|
190 | /** 状态变化事件,detail = {code}
|
191 | * @supported weapp
|
192 | */
|
193 | onStateChange?: CommonEventFunction<LivePusherProps.onStateChangeEventDetail>
|
194 |
|
195 | /** 网络状态通知,detail = {info}
|
196 | * @supported weapp
|
197 | */
|
198 | onNetstatus?: CommonEventFunction<LivePusherProps.onNetstatusEventDetail>
|
199 |
|
200 | /** 渲染错误事件,detail = {errMsg, errCode}
|
201 | * @supported weapp
|
202 | */
|
203 | onError?: CommonEventFunction<LivePusherProps.onErrorEventDetail>
|
204 |
|
205 | /** 背景音开始播放时触发
|
206 | * @supported weapp
|
207 | */
|
208 | onBgmStart?: CommonEventFunction
|
209 |
|
210 | /** 背景音进度变化时触发,detail = {progress, duration}
|
211 | * @supported weapp
|
212 | */
|
213 | onBgmProgress?: CommonEventFunction<LivePusherProps.onBgmProgressEventDetail>
|
214 |
|
215 | /** 背景音播放完成时触发
|
216 | * @supported weapp
|
217 | */
|
218 | onBgmComplete?: CommonEventFunction
|
219 |
|
220 | /** 返回麦克风采集的音量大小
|
221 | * @supported weapp
|
222 | */
|
223 | onAudioVolumeNotify?: CommonEventFunction
|
224 | }
|
225 |
|
226 | declare namespace LivePusherProps {
|
227 | /** orientation 的合法值 */
|
228 | interface Orientation {
|
229 | /** 竖直 */
|
230 | vertical
|
231 | /** 水平 */
|
232 | horizontal
|
233 | }
|
234 | /** localMirror 的合法值 */
|
235 | interface LocalMirror {
|
236 | /** 前置摄像头镜像,后置摄像头不镜像 */
|
237 | auto
|
238 | /** 前后置摄像头均镜像 */
|
239 | enable
|
240 | /** 前后置摄像头均不镜像 */
|
241 | disable
|
242 | }
|
243 | /** audioReverbType 的合法值 */
|
244 | interface AudioReverbType {
|
245 | /** 关闭 */
|
246 | 0
|
247 | /** KTV */
|
248 | 1
|
249 | /** 小房间 */
|
250 | 2
|
251 | /** 大会堂 */
|
252 | 3
|
253 | /** 低沉 */
|
254 | 4
|
255 | /** 洪亮 */
|
256 | 5
|
257 | /** 金属声 */
|
258 | 6
|
259 | /** 磁性 */
|
260 | 7
|
261 | }
|
262 | /** audioVolumeType 的合法值 */
|
263 | interface AudioVolumeType {
|
264 | /** 媒体音量 */
|
265 | media
|
266 | /** 通话音量 */
|
267 | voicecall
|
268 | }
|
269 | /** beautyStyleType 的合法值 */
|
270 | interface BeautyStyleType {
|
271 | /** 光滑美颜 */
|
272 | smooth
|
273 | /** 自然美颜 */
|
274 | nature
|
275 | }
|
276 | /** filterType 的合法值 */
|
277 | interface FilterType {
|
278 | /** 标准 */
|
279 | standard
|
280 | /** 粉嫩 */
|
281 | pink
|
282 | /** 怀旧 */
|
283 | nostalgia
|
284 | /** 蓝调 */
|
285 | blues
|
286 | /** 浪漫 */
|
287 | romantic
|
288 | /** 清凉 */
|
289 | cool
|
290 | /** 清新 */
|
291 | fresher
|
292 | /** 日系 */
|
293 | solor
|
294 | /** 唯美 */
|
295 | aestheticism
|
296 | /** 美白 */
|
297 | whitening
|
298 | /** 樱红 */
|
299 | cerisered
|
300 | }
|
301 | interface onStateChangeEventDetail {
|
302 | /** 状态码 */
|
303 | code: number
|
304 | }
|
305 | interface onNetstatusEventDetail {
|
306 | /** 网络状态 */
|
307 | info: NetStatus
|
308 | }
|
309 | interface onErrorEventDetail {
|
310 | /** 错误信息 */
|
311 | errMsg: string
|
312 | /** 错误码 */
|
313 | errCode: string | number
|
314 | }
|
315 | interface onBgmProgressEventDetail {
|
316 | /** 进展 */
|
317 | progress
|
318 | /** 持续时间 */
|
319 | duration: number
|
320 | }
|
321 | }
|
322 |
|
323 | /** 实时音视频录制。需要用户授权 scope.camera、scope.record
|
324 | * 需要先通过类目审核,再在小程序管理后台,「开发」-「接口设置」中自助开通该组件权限。
|
325 | * @classification media
|
326 | * @supported weapp
|
327 | * @example_react
|
328 | * ```tsx
|
329 | * class App extends Components {
|
330 | * render () {
|
331 | * return (
|
332 | * <LivePusher url='url' mode='RTC' autopush />
|
333 | * )
|
334 | * }
|
335 | * }
|
336 | * ```
|
337 | * @example_vue
|
338 | * ```html
|
339 | * <template>
|
340 | * <live-pusher url="url" mode="RTC" :autopush="true" />
|
341 | * </template>
|
342 | * ```
|
343 | * @see https://developers.weixin.qq.com/miniprogram/dev/component/live-pusher.html
|
344 | */
|
345 | declare const LivePusher: ComponentType<LivePusherProps>
|
346 |
|
347 | export { LivePusher, LivePusherProps }
|