@spcsn/taro 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
interface MediaRecorder {
|
|
5
|
+
/** 销毁录制器
|
|
6
|
+
* @supported weapp
|
|
7
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.destroy.html
|
|
8
|
+
*/
|
|
9
|
+
destroy(): Promise<void>
|
|
10
|
+
/** 取消监听录制事件
|
|
11
|
+
* @supported weapp
|
|
12
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.off.html
|
|
13
|
+
*/
|
|
14
|
+
off(
|
|
15
|
+
/** 事件名 */
|
|
16
|
+
eventName: keyof MediaRecorder.on.EventName,
|
|
17
|
+
/** 事件触发时执行的回调函数 */
|
|
18
|
+
callback: MediaRecorder.on.Callback
|
|
19
|
+
): Promise<void>
|
|
20
|
+
/** 注册监听录制事件的回调函数
|
|
21
|
+
* @supported weapp
|
|
22
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.on.html
|
|
23
|
+
*/
|
|
24
|
+
on(
|
|
25
|
+
/** 事件名 */
|
|
26
|
+
eventName: keyof MediaRecorder.on.EventName,
|
|
27
|
+
/** 事件触发时执行的回调函数 */
|
|
28
|
+
callback: MediaRecorder.on.Callback
|
|
29
|
+
): Promise<void>
|
|
30
|
+
/** 暂停录制
|
|
31
|
+
* @supported weapp
|
|
32
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.pause.html
|
|
33
|
+
*/
|
|
34
|
+
pause(): Promise<void>
|
|
35
|
+
/** 请求下一帧录制,在 callback 里完成一帧渲染后开始录制当前帧
|
|
36
|
+
* @supported weapp
|
|
37
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.requestFrame.html
|
|
38
|
+
*/
|
|
39
|
+
requestFrame(callback: MediaRecorder.requestFrame.Callback): Promise<void>
|
|
40
|
+
/** 恢复录制
|
|
41
|
+
* @supported weapp
|
|
42
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.resume.html
|
|
43
|
+
*/
|
|
44
|
+
resume(): Promise<void>
|
|
45
|
+
/** 开始录制
|
|
46
|
+
* @supported weapp
|
|
47
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.start.html
|
|
48
|
+
*/
|
|
49
|
+
start(): Promise<void>
|
|
50
|
+
/** 结束录制
|
|
51
|
+
* @supported weapp
|
|
52
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/MediaRecorder.stop.html
|
|
53
|
+
*/
|
|
54
|
+
stop(): Promise<void>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
namespace MediaRecorder {
|
|
58
|
+
namespace on {
|
|
59
|
+
/** eventName 的合法值 */
|
|
60
|
+
interface EventName {
|
|
61
|
+
/** 录制开始事件。 */
|
|
62
|
+
start
|
|
63
|
+
/** 录制结束事件。返回 {tempFilePath, duration, fileSize} */
|
|
64
|
+
stop
|
|
65
|
+
/** 录制暂停事件。 */
|
|
66
|
+
pause
|
|
67
|
+
/** 录制继续事件。 */
|
|
68
|
+
resume
|
|
69
|
+
/** 录制时间更新事件。 */
|
|
70
|
+
timeupdate
|
|
71
|
+
}
|
|
72
|
+
/** 事件触发时执行的回调函数 */
|
|
73
|
+
type Callback = (res?: {
|
|
74
|
+
tempFilePath: string
|
|
75
|
+
duration: number
|
|
76
|
+
fileSize: number
|
|
77
|
+
}) => void
|
|
78
|
+
}
|
|
79
|
+
namespace requestFrame {
|
|
80
|
+
/** 事件触发时执行的回调函数 */
|
|
81
|
+
type Callback = () => void
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
namespace createMediaRecorder {
|
|
86
|
+
/**
|
|
87
|
+
* createMediaRecorder Option
|
|
88
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/wx.createMediaRecorder.html
|
|
89
|
+
*/
|
|
90
|
+
interface Option {
|
|
91
|
+
/** 指定录制的时长(s),到达自动停止。最大 7200,最小 5
|
|
92
|
+
* @default 600
|
|
93
|
+
*/
|
|
94
|
+
duration?: number
|
|
95
|
+
/** 视频比特率(kbps),最小值 600,最大值 3000
|
|
96
|
+
* @default 1000
|
|
97
|
+
*/
|
|
98
|
+
videoBitsPerSecond?: number
|
|
99
|
+
/** 视频关键帧间隔
|
|
100
|
+
* @default 12
|
|
101
|
+
*/
|
|
102
|
+
gop?: number
|
|
103
|
+
/** 视频 fps
|
|
104
|
+
* @default 24
|
|
105
|
+
*/
|
|
106
|
+
fps?: number
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface TaroStatic {
|
|
111
|
+
/** 创建 WebGL 画面录制器,可逐帧录制在 WebGL 上渲染的画面并导出视频文件
|
|
112
|
+
* @supported weapp
|
|
113
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/media-recorder/wx.createMediaRecorder.html
|
|
114
|
+
*/
|
|
115
|
+
createMediaRecorder(canvas?: Canvas | OffscreenCanvas, option?: createMediaRecorder.Option): MediaRecorder
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
namespace stopRecord {
|
|
5
|
+
interface Option {
|
|
6
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
7
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
8
|
+
/** 接口调用失败的回调函数 */
|
|
9
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
10
|
+
/** 接口调用成功的回调函数 */
|
|
11
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
namespace startRecord {
|
|
16
|
+
interface Option {
|
|
17
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
18
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
19
|
+
/** 接口调用失败的回调函数 */
|
|
20
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
21
|
+
/** 接口调用成功的回调函数 */
|
|
22
|
+
success?: (result: SuccessCallbackResult) => void
|
|
23
|
+
}
|
|
24
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
25
|
+
/** 录音文件的临时路径 */
|
|
26
|
+
tempFilePath: string
|
|
27
|
+
/** 调用结果 */
|
|
28
|
+
errMsg: string
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
namespace RecorderManager {
|
|
33
|
+
/** 录音错误事件的回调函数 */
|
|
34
|
+
type OnErrorCallback = (
|
|
35
|
+
result: OnErrorCallbackResult,
|
|
36
|
+
) => void
|
|
37
|
+
interface OnErrorCallbackResult extends TaroGeneral.CallbackResult {
|
|
38
|
+
/** 错误信息 */
|
|
39
|
+
errMsg: string
|
|
40
|
+
}
|
|
41
|
+
/** 已录制完指定帧大小的文件事件的回调函数 */
|
|
42
|
+
type OnFrameRecordedCallback = (
|
|
43
|
+
result: OnFrameRecordedCallbackResult,
|
|
44
|
+
) => void
|
|
45
|
+
interface OnFrameRecordedCallbackResult {
|
|
46
|
+
/** 录音分片数据 */
|
|
47
|
+
frameBuffer: ArrayBuffer
|
|
48
|
+
/** 当前帧是否正常录音结束前的最后一帧 */
|
|
49
|
+
isLastFrame: boolean
|
|
50
|
+
}
|
|
51
|
+
/** 录音结束事件的回调函数 */
|
|
52
|
+
type OnStopCallback = (result: OnStopCallbackResult) => void
|
|
53
|
+
interface OnStopCallbackResult {
|
|
54
|
+
/** 录音总时长,单位:ms */
|
|
55
|
+
duration: number
|
|
56
|
+
/** 录音文件大小,单位:Byte */
|
|
57
|
+
fileSize: number
|
|
58
|
+
/** 录音文件的临时路径 */
|
|
59
|
+
tempFilePath: string
|
|
60
|
+
}
|
|
61
|
+
interface StartOption {
|
|
62
|
+
/** 指定录音的音频输入源,可通过 [Taro.getAvailableAudioSources()](/docs/apis/media/audio/getAvailableAudioSources) 获取当前可用的音频源 */
|
|
63
|
+
audioSource?: keyof AudioSource
|
|
64
|
+
/** 录音的时长,单位 ms,最大值 600000(10 分钟) */
|
|
65
|
+
duration?: number
|
|
66
|
+
/** 编码码率,有效值见下表格 */
|
|
67
|
+
encodeBitRate?: number
|
|
68
|
+
/** 音频格式 */
|
|
69
|
+
format?: keyof Format
|
|
70
|
+
/** 指定帧大小,单位 KB。传入 frameSize 后,每录制指定帧大小的内容后,会回调录制的文件内容,不指定则不会回调。暂仅支持 mp3 格式。 */
|
|
71
|
+
frameSize?: number
|
|
72
|
+
/** 录音通道数 */
|
|
73
|
+
numberOfChannels?: keyof NumberOfChannels
|
|
74
|
+
/** 采样率 */
|
|
75
|
+
sampleRate?: keyof SampleRate
|
|
76
|
+
}
|
|
77
|
+
/** 指定录音的音频输入源 */
|
|
78
|
+
interface AudioSource {
|
|
79
|
+
/** 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用 */
|
|
80
|
+
'auto'
|
|
81
|
+
/** 手机麦克风,仅限 iOS */
|
|
82
|
+
'buildInMic'
|
|
83
|
+
/** 耳机麦克风,仅限 iOS */
|
|
84
|
+
'headsetMic'
|
|
85
|
+
/** 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android */
|
|
86
|
+
'mic'
|
|
87
|
+
/** 同 mic,适用于录制音视频内容,仅限 Android */
|
|
88
|
+
'camcorder'
|
|
89
|
+
/** 同 mic,适用于实时沟通,仅限 Android */
|
|
90
|
+
'voice_communication'
|
|
91
|
+
/** 同 mic,适用于语音识别,仅限 Android */
|
|
92
|
+
'voice_recognition'
|
|
93
|
+
}
|
|
94
|
+
/** 音频格式 */
|
|
95
|
+
interface Format {
|
|
96
|
+
/** mp3 格式 */
|
|
97
|
+
mp3
|
|
98
|
+
/** aac 格式 */
|
|
99
|
+
aac
|
|
100
|
+
/** wav 格式 */
|
|
101
|
+
wav
|
|
102
|
+
/** pcm 格式 */
|
|
103
|
+
PCM
|
|
104
|
+
}
|
|
105
|
+
/** 录音通道数 */
|
|
106
|
+
interface NumberOfChannels {
|
|
107
|
+
/** 1 个通道 */
|
|
108
|
+
1
|
|
109
|
+
/** 2 个通道 */
|
|
110
|
+
2
|
|
111
|
+
}
|
|
112
|
+
/** 采样率 */
|
|
113
|
+
interface SampleRate {
|
|
114
|
+
/** 8000 采样率
|
|
115
|
+
* @codeRate 16000 ~ 48000
|
|
116
|
+
*/
|
|
117
|
+
8000
|
|
118
|
+
/** 11025 采样率
|
|
119
|
+
* @codeRate 16000 ~ 48000
|
|
120
|
+
*/
|
|
121
|
+
11025
|
|
122
|
+
/** 12000 采样率
|
|
123
|
+
* @codeRate 24000 ~ 64000
|
|
124
|
+
*/
|
|
125
|
+
12000
|
|
126
|
+
/** 16000 采样率
|
|
127
|
+
* @codeRate 24000 ~ 96000
|
|
128
|
+
*/
|
|
129
|
+
16000
|
|
130
|
+
/** 22050 采样率
|
|
131
|
+
* @codeRate 32000 ~ 128000
|
|
132
|
+
*/
|
|
133
|
+
22050
|
|
134
|
+
/** 24000 采样率
|
|
135
|
+
* @codeRate 32000 ~ 128000
|
|
136
|
+
*/
|
|
137
|
+
24000
|
|
138
|
+
/** 32000 采样率
|
|
139
|
+
* @codeRate 48000 ~ 192000
|
|
140
|
+
*/
|
|
141
|
+
32000
|
|
142
|
+
/** 44100 采样率
|
|
143
|
+
* @codeRate 64000 ~ 320000
|
|
144
|
+
*/
|
|
145
|
+
44100
|
|
146
|
+
/** 48000 采样率
|
|
147
|
+
* @codeRate 64000 ~ 320000
|
|
148
|
+
*/
|
|
149
|
+
48000
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** 全局唯一的录音管理器
|
|
154
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.html
|
|
155
|
+
*/
|
|
156
|
+
interface RecorderManager {
|
|
157
|
+
/** 监听录音错误事件
|
|
158
|
+
* @supported weapp, rn, tt
|
|
159
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onError.html
|
|
160
|
+
*/
|
|
161
|
+
onError(
|
|
162
|
+
/** 录音错误事件的回调函数 */
|
|
163
|
+
callback: RecorderManager.OnErrorCallback,
|
|
164
|
+
): void
|
|
165
|
+
/** 监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。
|
|
166
|
+
* @supported weapp, tt
|
|
167
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onFrameRecorded.html
|
|
168
|
+
*/
|
|
169
|
+
onFrameRecorded(
|
|
170
|
+
/** 已录制完指定帧大小的文件事件的回调函数 */
|
|
171
|
+
callback: RecorderManager.OnFrameRecordedCallback,
|
|
172
|
+
): void
|
|
173
|
+
/** 监听录音因为受到系统占用而被中断开始事件。以下场景会触发此事件:微信语音聊天、微信视频聊天。此事件触发后,录音会被暂停。pause 事件在此事件后触发
|
|
174
|
+
* @supported weapp
|
|
175
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onInterruptionBegin.html
|
|
176
|
+
*/
|
|
177
|
+
onInterruptionBegin(
|
|
178
|
+
/** 录音因为受到系统占用而被中断开始事件的回调函数 */
|
|
179
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
180
|
+
): void
|
|
181
|
+
/** 监听录音中断结束事件。在收到 interruptionBegin 事件之后,小程序内所有录音会暂停,收到此事件之后才可再次录音成功。
|
|
182
|
+
* @supported weapp
|
|
183
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onInterruptionEnd.html
|
|
184
|
+
*/
|
|
185
|
+
onInterruptionEnd(
|
|
186
|
+
/** 录音中断结束事件的回调函数 */
|
|
187
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
188
|
+
): void
|
|
189
|
+
/** 监听录音暂停事件
|
|
190
|
+
* @supported weapp, rn, tt
|
|
191
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onPause.html
|
|
192
|
+
*/
|
|
193
|
+
onPause(
|
|
194
|
+
/** 录音暂停事件的回调函数 */
|
|
195
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
196
|
+
): void
|
|
197
|
+
/** 监听录音继续事件
|
|
198
|
+
* @supported weapp, rn, tt
|
|
199
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onResume.html
|
|
200
|
+
*/
|
|
201
|
+
onResume(
|
|
202
|
+
/** 录音继续事件的回调函数 */
|
|
203
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
204
|
+
): void
|
|
205
|
+
/** 监听录音开始事件
|
|
206
|
+
* @supported weapp, rn, tt
|
|
207
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onStart.html
|
|
208
|
+
*/
|
|
209
|
+
onStart(
|
|
210
|
+
/** 录音开始事件的回调函数 */
|
|
211
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
212
|
+
): void
|
|
213
|
+
/** 监听录音结束事件
|
|
214
|
+
* @supported weapp, rn, tt
|
|
215
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onStop.html
|
|
216
|
+
*/
|
|
217
|
+
onStop(
|
|
218
|
+
/** 录音结束事件的回调函数 */
|
|
219
|
+
callback: RecorderManager.OnStopCallback,
|
|
220
|
+
): void
|
|
221
|
+
/** 暂停录音
|
|
222
|
+
* @supported weapp, rn
|
|
223
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.pause.html
|
|
224
|
+
*/
|
|
225
|
+
pause(): void
|
|
226
|
+
/** 继续录音
|
|
227
|
+
* @supported weapp, rn, tt
|
|
228
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.resume.html
|
|
229
|
+
*/
|
|
230
|
+
resume(): void
|
|
231
|
+
/** 开始录音
|
|
232
|
+
* @supported weapp, rn, tt
|
|
233
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.start.html
|
|
234
|
+
*/
|
|
235
|
+
start(option: RecorderManager.StartOption): void
|
|
236
|
+
/** 停止录音
|
|
237
|
+
* @supported weapp, rn, tt
|
|
238
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.stop.html
|
|
239
|
+
*/
|
|
240
|
+
stop(): void
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface TaroStatic {
|
|
244
|
+
/** 停止录音。
|
|
245
|
+
* @supported weapp
|
|
246
|
+
* @example
|
|
247
|
+
* ```tsx
|
|
248
|
+
* Taro.startRecord({
|
|
249
|
+
* success: function (res) {
|
|
250
|
+
* var tempFilePath = res.tempFilePath
|
|
251
|
+
* },
|
|
252
|
+
* fail: function (res) {
|
|
253
|
+
* //录音失败
|
|
254
|
+
* }
|
|
255
|
+
* })
|
|
256
|
+
* setTimeout(function() {
|
|
257
|
+
* //结束录音
|
|
258
|
+
* Taro.stopRecord()
|
|
259
|
+
* }, 10000)
|
|
260
|
+
* ```
|
|
261
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.stopRecord.html
|
|
262
|
+
*/
|
|
263
|
+
stopRecord(option?: stopRecord.Option): void
|
|
264
|
+
|
|
265
|
+
/** 开始录音。当主动调用`Taro.stopRecord`,或者录音超过1分钟时自动结束录音,返回录音文件的临时文件路径。当用户离开小程序时,此接口无法调用。
|
|
266
|
+
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.getRecorderManager](/docs/apis/media/recorder/getRecorderManager) 接口**
|
|
267
|
+
* 需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.record
|
|
268
|
+
* @supported weapp
|
|
269
|
+
* @example
|
|
270
|
+
* ```tsx
|
|
271
|
+
* Taro.startRecord({
|
|
272
|
+
* success: function (res) {
|
|
273
|
+
* const tempFilePath = res.tempFilePath
|
|
274
|
+
* }
|
|
275
|
+
* })
|
|
276
|
+
* setTimeout(function () {
|
|
277
|
+
* Taro.stopRecord() // 结束录音
|
|
278
|
+
* }, 10000)
|
|
279
|
+
* ```
|
|
280
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.startRecord.html
|
|
281
|
+
*/
|
|
282
|
+
startRecord(option: startRecord.Option): Promise<startRecord.SuccessCallbackResult>
|
|
283
|
+
|
|
284
|
+
/** 获取**全局唯一**的录音管理器 RecorderManager
|
|
285
|
+
* @supported weapp, rn
|
|
286
|
+
* @example
|
|
287
|
+
* ```tsx
|
|
288
|
+
* const recorderManager = Taro.getRecorderManager()
|
|
289
|
+
* recorderManager.onStart(() => {
|
|
290
|
+
* console.log('recorder start')
|
|
291
|
+
* })
|
|
292
|
+
* recorderManager.onPause(() => {
|
|
293
|
+
* console.log('recorder pause')
|
|
294
|
+
* })
|
|
295
|
+
* recorderManager.onStop((res) => {
|
|
296
|
+
* console.log('recorder stop', res)
|
|
297
|
+
* const { tempFilePath } = res
|
|
298
|
+
* })
|
|
299
|
+
* recorderManager.onFrameRecorded((res) => {
|
|
300
|
+
* const { frameBuffer } = res
|
|
301
|
+
* console.log('frameBuffer.byteLength', frameBuffer.byteLength)
|
|
302
|
+
* })
|
|
303
|
+
* const options = {
|
|
304
|
+
* duration: 10000,
|
|
305
|
+
* sampleRate: 44100,
|
|
306
|
+
* numberOfChannels: 1,
|
|
307
|
+
* encodeBitRate: 192000,
|
|
308
|
+
* format: 'aac',
|
|
309
|
+
* frameSize: 50
|
|
310
|
+
* }
|
|
311
|
+
* recorderManager.start(options)
|
|
312
|
+
* ```
|
|
313
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.getRecorderManager.html
|
|
314
|
+
*/
|
|
315
|
+
getRecorderManager(): RecorderManager
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
interface VideoDecoder {
|
|
5
|
+
/** 获取下一帧的解码数据
|
|
6
|
+
* @supported weapp
|
|
7
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.getFrameData.html
|
|
8
|
+
*/
|
|
9
|
+
getFrameData(): Promise<VideoDecoder.getFrameData.Result>
|
|
10
|
+
/** 取消监听录制事件
|
|
11
|
+
* @supported weapp
|
|
12
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.off.html
|
|
13
|
+
*/
|
|
14
|
+
off(
|
|
15
|
+
/** 事件名 */
|
|
16
|
+
eventName: keyof VideoDecoder.on.EventName,
|
|
17
|
+
/** 事件触发时执行的回调函数 */
|
|
18
|
+
callback: VideoDecoder.on.Callback
|
|
19
|
+
): void
|
|
20
|
+
/** 注册监听录制事件的回调函数
|
|
21
|
+
* @supported weapp
|
|
22
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.on.html
|
|
23
|
+
*/
|
|
24
|
+
on(
|
|
25
|
+
/** 事件名 */
|
|
26
|
+
eventName: keyof VideoDecoder.on.EventName,
|
|
27
|
+
/** 事件触发时执行的回调函数 */
|
|
28
|
+
callback: VideoDecoder.on.Callback
|
|
29
|
+
): void
|
|
30
|
+
/** 移除解码器
|
|
31
|
+
* @supported weapp
|
|
32
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.remove.html
|
|
33
|
+
*/
|
|
34
|
+
remove(): Promise<void>
|
|
35
|
+
/** 跳到某个时间点解码
|
|
36
|
+
* @supported weapp
|
|
37
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.seek.html
|
|
38
|
+
*/
|
|
39
|
+
seek(
|
|
40
|
+
/** 跳转的解码位置,单位 ms */
|
|
41
|
+
position: number
|
|
42
|
+
): Promise<void>
|
|
43
|
+
/** 开始解码
|
|
44
|
+
* @supported weapp
|
|
45
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.start.html
|
|
46
|
+
*/
|
|
47
|
+
start(option: VideoDecoder.start.Option): Promise<void>
|
|
48
|
+
/** 停止解码
|
|
49
|
+
* @supported weapp
|
|
50
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/VideoDecoder.stop.html
|
|
51
|
+
*/
|
|
52
|
+
stop(): Promise<void>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
namespace VideoDecoder {
|
|
56
|
+
namespace getFrameData {
|
|
57
|
+
interface Result {
|
|
58
|
+
/** 帧数据宽度 */
|
|
59
|
+
width: number
|
|
60
|
+
/** 帧数据高度 */
|
|
61
|
+
height: number
|
|
62
|
+
/** 帧数据 */
|
|
63
|
+
data: ArrayBuffer
|
|
64
|
+
/** 帧原始 pts */
|
|
65
|
+
pkPts: number
|
|
66
|
+
/** 帧原始 dts */
|
|
67
|
+
pkDts: number
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
namespace on {
|
|
71
|
+
/** eventName 的合法值 */
|
|
72
|
+
interface EventName {
|
|
73
|
+
/** 开始事件。返回 {width, height} */
|
|
74
|
+
start
|
|
75
|
+
/** 结束事件。 */
|
|
76
|
+
stop
|
|
77
|
+
/** seek 完成事件。 */
|
|
78
|
+
seek
|
|
79
|
+
/** 缓冲区变化事件。 */
|
|
80
|
+
bufferchange
|
|
81
|
+
/** 解码结束事件。 */
|
|
82
|
+
ended
|
|
83
|
+
}
|
|
84
|
+
/** 事件触发时执行的回调函数 */
|
|
85
|
+
type Callback = (res?: {
|
|
86
|
+
width: number
|
|
87
|
+
height: number
|
|
88
|
+
}) => void
|
|
89
|
+
}
|
|
90
|
+
namespace start {
|
|
91
|
+
interface Option {
|
|
92
|
+
/** 需要解码的视频源文件。 */
|
|
93
|
+
source: string
|
|
94
|
+
/** 解码模式。0:按 pts 解码;1:以最快速度解码
|
|
95
|
+
* @default 1
|
|
96
|
+
*/
|
|
97
|
+
mode?: number
|
|
98
|
+
/** 是否不需要音频轨道
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
abortAudio?: boolean
|
|
102
|
+
/** 是否不需要视频轨道
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
abortVideo?: boolean
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface TaroStatic {
|
|
111
|
+
/** 创建视频解码器,可逐帧获取解码后的数据
|
|
112
|
+
* @supported weapp
|
|
113
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-decoder/wx.createVideoDecoder.html
|
|
114
|
+
*/
|
|
115
|
+
createVideoDecoder(): VideoDecoder
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
/** 创建音视频处理容器,最终可将容器中的轨道合成一个视频
|
|
5
|
+
*
|
|
6
|
+
* > 可通过 [Taro.createMediaContainer](./createMediaContainer) 创建
|
|
7
|
+
* @supported weapp
|
|
8
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.html
|
|
9
|
+
*/
|
|
10
|
+
interface MediaContainer {
|
|
11
|
+
/** 将音频或视频轨道添加到容器
|
|
12
|
+
* @supported weapp
|
|
13
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.addTrack.html
|
|
14
|
+
*/
|
|
15
|
+
addTrack(
|
|
16
|
+
/** 要添加的音频或视频轨道 */
|
|
17
|
+
track: MediaTrack,
|
|
18
|
+
): void
|
|
19
|
+
/** 将容器销毁,释放资源
|
|
20
|
+
* @supported weapp
|
|
21
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.destroy.html
|
|
22
|
+
*/
|
|
23
|
+
destroy(): void
|
|
24
|
+
/** 将容器内的轨道合并并导出视频文件
|
|
25
|
+
* @supported weapp
|
|
26
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.export.html
|
|
27
|
+
*/
|
|
28
|
+
export(): void
|
|
29
|
+
/** 将传入的视频源分离轨道。不会自动将轨道添加到待合成的容器里。
|
|
30
|
+
* @supported weapp
|
|
31
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.extractDataSource.html
|
|
32
|
+
*/
|
|
33
|
+
extractDataSource(option: MediaContainer.ExtractDataSourceOption): void
|
|
34
|
+
/** 将音频或视频轨道从容器中移除
|
|
35
|
+
* @supported weapp
|
|
36
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.removeTrack.html
|
|
37
|
+
*/
|
|
38
|
+
removeTrack(
|
|
39
|
+
/** 要移除的音频或视频轨道 */
|
|
40
|
+
track: MediaTrack,
|
|
41
|
+
): void
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
namespace MediaContainer {
|
|
45
|
+
interface ExtractDataSourceOption {
|
|
46
|
+
/** 视频源地址,只支持本地文件 */
|
|
47
|
+
source: string
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 可通过 [MediaContainer.extractDataSource](/docs/apis/media/video-processing/MediaContainer#extractdatasource) 返回。
|
|
52
|
+
* [MediaTrack](/docs/apis/media/video-processing/MediaTrack) 音频或视频轨道,可以对轨道进行一些操作
|
|
53
|
+
* @supported weapp
|
|
54
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaTrack.html
|
|
55
|
+
*/
|
|
56
|
+
interface MediaTrack {
|
|
57
|
+
/** 轨道类型
|
|
58
|
+
* @readonly
|
|
59
|
+
*/
|
|
60
|
+
kind: keyof MediaTrack.Kind
|
|
61
|
+
/** 轨道长度
|
|
62
|
+
* @readonly
|
|
63
|
+
*/
|
|
64
|
+
duration: number
|
|
65
|
+
/** 音量,音频轨道下有效,可写 */
|
|
66
|
+
volume: number
|
|
67
|
+
}
|
|
68
|
+
namespace MediaTrack {
|
|
69
|
+
interface Kind {
|
|
70
|
+
/** 音频轨道 */
|
|
71
|
+
audio
|
|
72
|
+
/** 视频轨道 */
|
|
73
|
+
video
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface TaroStatic {
|
|
78
|
+
/** 创建音视频处理容器,最终可将容器中的轨道合成一个视频
|
|
79
|
+
* @supported weapp
|
|
80
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/wx.createMediaContainer.html
|
|
81
|
+
*/
|
|
82
|
+
createMediaContainer(): MediaContainer
|
|
83
|
+
}
|
|
84
|
+
}
|