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