@tarojs/taro 3.5.0-canary.1 → 3.5.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/html.css +50 -14
- package/html5.css +167 -64
- package/index.js +3 -4
- package/package.json +21 -11
- package/types/api/ad/index.d.ts +2 -2
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/visionkit.d.ts +303 -0
- package/types/api/base/crypto.d.ts +90 -0
- package/types/api/base/debug.d.ts +152 -13
- package/types/api/base/env.d.ts +2 -1
- package/types/api/base/index.d.ts +11 -3
- package/types/api/base/performance.d.ts +195 -0
- package/types/api/base/system.d.ts +541 -103
- package/types/api/base/update.d.ts +60 -8
- package/types/api/base/weapp/app-event.d.ts +99 -37
- package/types/api/base/weapp/life-cycle.d.ts +142 -2
- package/types/api/canvas/index.d.ts +151 -137
- package/types/api/cloud/index.d.ts +17 -2
- package/types/api/data-analysis/index.d.ts +1 -1
- package/types/api/device/accelerometer.d.ts +6 -6
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +2 -2
- package/types/api/device/{ble.d.ts → bluetooth-ble.d.ts} +228 -62
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +67 -2
- package/types/api/device/calendar.d.ts +88 -0
- package/types/api/device/clipboard.d.ts +2 -2
- package/types/api/device/compass.d.ts +3 -3
- package/types/api/device/contact.d.ts +74 -50
- package/types/api/device/gyroscope.d.ts +6 -6
- package/types/api/device/iBeacon.d.ts +33 -19
- package/types/api/{ui → device}/keyboard.d.ts +1 -1
- package/types/api/device/{performance.d.ts → memory.d.ts} +5 -5
- package/types/api/device/motion.d.ts +3 -3
- package/types/api/device/network.d.ts +56 -15
- package/types/api/device/nfc.d.ts +1089 -13
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +1 -1
- package/types/api/device/screen.d.ts +42 -14
- package/types/api/device/vibrate.d.ts +6 -2
- package/types/api/device/wifi.d.ts +44 -9
- package/types/api/ext/index.d.ts +2 -2
- package/types/api/files/index.d.ts +392 -205
- package/types/api/framework/index.d.ts +5 -4
- package/types/api/location/index.d.ts +156 -53
- package/types/api/media/audio.d.ts +629 -38
- package/types/api/media/background-audio.d.ts +9 -9
- package/types/api/media/camera.d.ts +41 -22
- package/types/api/media/editor.d.ts +22 -2
- package/types/api/media/image.d.ts +64 -35
- package/types/api/media/live.d.ts +66 -6
- package/types/api/media/map.d.ts +474 -54
- package/types/api/media/media-recorder.d.ts +92 -0
- package/types/api/media/recorder.d.ts +21 -21
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +11 -7
- package/types/api/media/video.d.ts +47 -18
- package/types/api/media/voip.d.ts +290 -0
- package/types/api/{open-api/navigate.d.ts → navigate/index.d.ts} +65 -27
- package/types/api/network/download.d.ts +61 -19
- package/types/api/network/request.d.ts +129 -41
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +154 -83
- package/types/api/network/upload.d.ts +55 -28
- package/types/api/network/websocket.d.ts +20 -19
- package/types/api/open-api/address.d.ts +1 -1
- package/types/api/open-api/authorize.d.ts +42 -3
- package/types/api/open-api/channels.d.ts +178 -0
- package/types/api/open-api/facial.d.ts +3 -0
- package/types/api/open-api/favorites.d.ts +100 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +2 -2
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +21 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +82 -17
- package/types/api/open-api/soter.d.ts +2 -2
- package/types/api/open-api/subscribe-message.d.ts +89 -4
- package/types/api/open-api/user-info.d.ts +56 -19
- package/types/api/open-api/werun.d.ts +33 -6
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/route/index.d.ts +18 -14
- package/types/api/share/index.d.ts +192 -9
- package/types/api/storage/index.d.ts +38 -92
- package/types/api/swan/index.d.ts +1 -1
- package/types/api/ui/animation.d.ts +105 -155
- package/types/api/ui/background.d.ts +4 -2
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +27 -31
- package/types/api/ui/interaction.d.ts +6 -6
- package/types/api/ui/menu.d.ts +1 -1
- package/types/api/ui/navigation-bar.d.ts +6 -5
- package/types/api/ui/pull-down-refresh.d.ts +2 -2
- package/types/api/ui/scroll.d.ts +75 -7
- package/types/api/ui/sticky.d.ts +4 -4
- package/types/api/ui/tab-bar.d.ts +8 -8
- package/types/api/ui/window.d.ts +22 -2
- package/types/api/worker/index.d.ts +9 -1
- package/types/api/wxml/index.d.ts +116 -112
- package/types/compile.d.ts +57 -6
- package/types/global.d.ts +142 -111
- package/types/taro.api.d.ts +79 -62
- package/types/taro.component.d.ts +21 -65
- package/types/taro.config.d.ts +31 -0
- package/types/taro.extend.d.ts +31 -18
- package/types/taro.hooks.d.ts +55 -3
- package/types/taro.lifecycle.d.ts +21 -14
- package/LICENSE +0 -21
- package/types/api/open-api/payment.d.ts +0 -61
|
@@ -63,7 +63,7 @@ declare module '../../index' {
|
|
|
63
63
|
success?: (result: SuccessCallbackResult) => void
|
|
64
64
|
}
|
|
65
65
|
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
66
|
-
/** 支持的音频输入源列表,可在 [RecorderManager.start()](
|
|
66
|
+
/** 支持的音频输入源列表,可在 [RecorderManager.start()](/docs/apis/media/recorder/RecorderManager#start)用。返回值定义参考 https://developer.android.com/reference/kotlin/android/media/MediaRecorder.AudioSource */
|
|
67
67
|
audioSources: Array<keyof audioSources>
|
|
68
68
|
/** 调用结果 */
|
|
69
69
|
errMsg: string
|
|
@@ -87,8 +87,80 @@ declare module '../../index' {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/** AudioBuffer 接口表示存在内存里的一段短小的音频资源,利用 [WebAudioContext.decodeAudioData](./WebAudioContext#decodeaudiodata) 方法从一个音频文件构建,或者利用 [AudioContext.createBuffer](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/(AudioContext.createBuffer).html) 从原始数据构建。把音频放入 AudioBuffer 后,可以传入到一个 AudioBufferSourceNode 进行播放。
|
|
91
|
+
* @supported weapp
|
|
92
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.html
|
|
93
|
+
*/
|
|
94
|
+
interface AudioBuffer {
|
|
95
|
+
/** 存储在缓存区的PCM数据的采样率(单位为sample/s) */
|
|
96
|
+
sampleRate: number
|
|
97
|
+
|
|
98
|
+
/** 返回存储在缓存区的PCM数据的采样帧率 */
|
|
99
|
+
length: number
|
|
100
|
+
|
|
101
|
+
/** 返回存储在缓存区的PCM数据的时长(单位为秒) */
|
|
102
|
+
duration: number
|
|
103
|
+
|
|
104
|
+
/** 储存在缓存区的PCM数据的通道数 */
|
|
105
|
+
numberOfChannels: number
|
|
106
|
+
|
|
107
|
+
/** 返回一个 Float32Array,包含了带有频道的PCM数据,由频道参数定义(有0代表第一个频道)
|
|
108
|
+
* @supported weapp
|
|
109
|
+
* @example
|
|
110
|
+
* ```tsx
|
|
111
|
+
* const audioCtx = Taro.createWebAudioContext()
|
|
112
|
+
* const myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
|
|
113
|
+
* const nowBuffering = myArrayBuffer.getChannelData(channel);
|
|
114
|
+
* ```
|
|
115
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.getChannelData.html
|
|
116
|
+
*/
|
|
117
|
+
getChannelData(channel: number): Float32Array
|
|
118
|
+
|
|
119
|
+
/** 从 AudioBuffer 的指定频道复制到数组终端。
|
|
120
|
+
* @supported weapp
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* const audioCtx = Taro.createWebAudioContext()
|
|
124
|
+
* const audioBuffer = audioCtx.createFromAudioFile({
|
|
125
|
+
* filePath:'/pages/res/bgm.mp3', // 静态资源
|
|
126
|
+
* mixToMono:true,
|
|
127
|
+
* sampleRate:44100
|
|
128
|
+
* });
|
|
129
|
+
* const channels = audioBuffer.numberOfChannels
|
|
130
|
+
* const anotherArray = new Float32Array(frameCount);
|
|
131
|
+
* const rate = audioBuffer.sampleRate
|
|
132
|
+
* const startOffSet = 0
|
|
133
|
+
* const endOffset = rate * 3;
|
|
134
|
+
* const newAudioBuffer = audioCtx.createBuffer(channels,endOffset - startOffset,rate)
|
|
135
|
+
* const offset = 0
|
|
136
|
+
*
|
|
137
|
+
* for (let channel = 0; channel < channels; channel++) {
|
|
138
|
+
* audioBuffer.copyFromChannel(anotherArray, channel, startOffset);
|
|
139
|
+
* newAudioBuffer.copyToChannel(anotherArray, channel, offset);
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.copyFromChannel.html
|
|
143
|
+
*/
|
|
144
|
+
copyFromChannel(): void
|
|
145
|
+
|
|
146
|
+
/** 从指定数组复制样本到 audioBuffer 的特定通道
|
|
147
|
+
* @supported weapp
|
|
148
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.copyToChannel.html
|
|
149
|
+
*/
|
|
150
|
+
copyToChannel(
|
|
151
|
+
/** 需要复制的源数组 */
|
|
152
|
+
source: Float32Array,
|
|
153
|
+
/** 需要复制到的目的通道号 */
|
|
154
|
+
channelNumber: number,
|
|
155
|
+
/** 复制偏移数据量 */
|
|
156
|
+
startInChannel: number
|
|
157
|
+
): void
|
|
158
|
+
}
|
|
159
|
+
|
|
90
160
|
/** `AudioContext` 实例,可通过 `Taro.createAudioContext` 获取。
|
|
161
|
+
*
|
|
91
162
|
* `AudioContext` 通过 `id` 跟一个 `audio` 组件绑定,操作对应的 audio 组件。
|
|
163
|
+
* @supported weapp
|
|
92
164
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.html
|
|
93
165
|
*/
|
|
94
166
|
interface AudioContext {
|
|
@@ -119,7 +191,7 @@ declare module '../../index' {
|
|
|
119
191
|
src: string,
|
|
120
192
|
): void
|
|
121
193
|
}
|
|
122
|
-
/** InnerAudioContext 实例,可通过 Taro.createInnerAudioContext 接口获取实例。
|
|
194
|
+
/** InnerAudioContext 实例,可通过 [Taro.createInnerAudioContext](./createInnerAudioContext) 接口获取实例。
|
|
123
195
|
*
|
|
124
196
|
* **支持格式**
|
|
125
197
|
*
|
|
@@ -141,7 +213,7 @@ declare module '../../index' {
|
|
|
141
213
|
* ```tsx
|
|
142
214
|
* const innerAudioContext = Taro.createInnerAudioContext()
|
|
143
215
|
* innerAudioContext.autoplay = true
|
|
144
|
-
* innerAudioContext.src = '
|
|
216
|
+
* innerAudioContext.src = 'https://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
|
|
145
217
|
* innerAudioContext.onPlay(() => {
|
|
146
218
|
* console.log('开始播放')
|
|
147
219
|
* })
|
|
@@ -167,7 +239,7 @@ declare module '../../index' {
|
|
|
167
239
|
* @default false
|
|
168
240
|
*/
|
|
169
241
|
loop: boolean
|
|
170
|
-
/** 是否遵循系统静音开关。当此参数为 `false` 时,即使用户打开了静音开关,也能继续发出声音。从 2.3.0 版本开始此参数不生效,使用 [Taro.setInnerAudioOption](
|
|
242
|
+
/** 是否遵循系统静音开关。当此参数为 `false` 时,即使用户打开了静音开关,也能继续发出声音。从 2.3.0 版本开始此参数不生效,使用 [Taro.setInnerAudioOption](/docs/apis/media/audio/setInnerAudioOption) 接口统一设置。
|
|
171
243
|
* @default true
|
|
172
244
|
*/
|
|
173
245
|
obeyMuteSwitch: boolean
|
|
@@ -197,55 +269,105 @@ declare module '../../index' {
|
|
|
197
269
|
buffered: number
|
|
198
270
|
/** origin: 发送完整的 referrer; no-referrer: 不发送 */
|
|
199
271
|
referrerPolicy?: 'origin' | 'no-referrer' | string
|
|
200
|
-
/** 播放
|
|
272
|
+
/** 播放
|
|
273
|
+
* @supported weapp, h5, rn
|
|
274
|
+
*/
|
|
201
275
|
play(): void
|
|
202
|
-
/** 暂停
|
|
276
|
+
/** 暂停
|
|
277
|
+
* @supported weapp, h5, rn
|
|
278
|
+
*/
|
|
203
279
|
pause(): void
|
|
204
|
-
/** 停止
|
|
280
|
+
/** 停止
|
|
281
|
+
* @supported weapp, h5, rn
|
|
282
|
+
*/
|
|
205
283
|
stop(): void
|
|
206
|
-
/** 跳转到指定位置,单位 s
|
|
284
|
+
/** 跳转到指定位置,单位 s
|
|
285
|
+
* @supported weapp, h5, rn
|
|
286
|
+
*/
|
|
207
287
|
seek(position: number): void
|
|
208
|
-
/** 销毁当前实例
|
|
288
|
+
/** 销毁当前实例
|
|
289
|
+
* @supported weapp, h5
|
|
290
|
+
*/
|
|
209
291
|
destroy(): void
|
|
210
|
-
/** 音频进入可以播放状态,但不保证后面可以流畅播放
|
|
292
|
+
/** 音频进入可以播放状态,但不保证后面可以流畅播放
|
|
293
|
+
* @supported weapp, h5, rn
|
|
294
|
+
*/
|
|
211
295
|
onCanplay(callback?: () => void): void
|
|
212
|
-
/** 音频播放事件
|
|
296
|
+
/** 音频播放事件
|
|
297
|
+
* @supported weapp, h5, rn
|
|
298
|
+
*/
|
|
213
299
|
onPlay(callback?: () => void): void
|
|
214
|
-
/** 音频暂停事件
|
|
300
|
+
/** 音频暂停事件
|
|
301
|
+
* @supported weapp, h5, rn
|
|
302
|
+
*/
|
|
215
303
|
onPause(callback?: () => void): void
|
|
216
|
-
/** 音频停止事件
|
|
304
|
+
/** 音频停止事件
|
|
305
|
+
* @supported weapp, h5, rn
|
|
306
|
+
*/
|
|
217
307
|
onStop(callback?: () => void): void
|
|
218
|
-
/** 音频自然播放结束事件
|
|
308
|
+
/** 音频自然播放结束事件
|
|
309
|
+
* @supported weapp, h5, rn
|
|
310
|
+
*/
|
|
219
311
|
onEnded(callback?: () => void): void
|
|
220
|
-
/** 音频播放进度更新事件
|
|
312
|
+
/** 音频播放进度更新事件
|
|
313
|
+
* @supported weapp, h5, rn
|
|
314
|
+
*/
|
|
221
315
|
onTimeUpdate(callback?: () => void): void
|
|
222
|
-
/** 音频播放错误事件
|
|
316
|
+
/** 音频播放错误事件
|
|
317
|
+
* @supported weapp, h5, rn
|
|
318
|
+
*/
|
|
223
319
|
onError(callback?: (res: InnerAudioContext.onErrorDetail) => void): void
|
|
224
|
-
/** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发
|
|
320
|
+
/** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发
|
|
321
|
+
* @supported weapp, h5, rn
|
|
322
|
+
*/
|
|
225
323
|
onWaiting(callback?: () => void): void
|
|
226
|
-
/** 音频进行 seek 操作事件
|
|
324
|
+
/** 音频进行 seek 操作事件
|
|
325
|
+
* @supported weapp, h5, rn
|
|
326
|
+
*/
|
|
227
327
|
onSeeking(callback?: () => void): void
|
|
228
|
-
/** 音频完成 seek 操作事件
|
|
328
|
+
/** 音频完成 seek 操作事件
|
|
329
|
+
* @supported weapp, h5, rn
|
|
330
|
+
*/
|
|
229
331
|
onSeeked(callback?: () => void): void
|
|
230
|
-
/** 取消监听 onCanplay 事件
|
|
332
|
+
/** 取消监听 onCanplay 事件
|
|
333
|
+
* @supported weapp, h5, rn
|
|
334
|
+
*/
|
|
231
335
|
offCanplay(callback?: () => void): void
|
|
232
|
-
/** 取消监听 onPlay 事件
|
|
336
|
+
/** 取消监听 onPlay 事件
|
|
337
|
+
* @supported weapp, h5, rn
|
|
338
|
+
*/
|
|
233
339
|
offPlay(callback?: () => void): void
|
|
234
|
-
/** 取消监听 onPause 事件
|
|
340
|
+
/** 取消监听 onPause 事件
|
|
341
|
+
* @supported weapp, h5, rn
|
|
342
|
+
*/
|
|
235
343
|
offPause(callback?: () => void): void
|
|
236
|
-
/** 取消监听 onStop 事件
|
|
344
|
+
/** 取消监听 onStop 事件
|
|
345
|
+
* @supported weapp, h5, rn
|
|
346
|
+
*/
|
|
237
347
|
offStop(callback?: () => void): void
|
|
238
|
-
/** 取消监听 onEnded 事件
|
|
348
|
+
/** 取消监听 onEnded 事件
|
|
349
|
+
* @supported weapp, h5, rn
|
|
350
|
+
*/
|
|
239
351
|
offEnded(callback?: () => void): void
|
|
240
|
-
/** 取消监听 onTimeUpdate 事件
|
|
352
|
+
/** 取消监听 onTimeUpdate 事件
|
|
353
|
+
* @supported weapp, h5, rn
|
|
354
|
+
*/
|
|
241
355
|
offTimeUpdate(callback?: () => void): void
|
|
242
|
-
/** 取消监听 onError 事件
|
|
356
|
+
/** 取消监听 onError 事件
|
|
357
|
+
* @supported weapp, h5, rn
|
|
358
|
+
*/
|
|
243
359
|
offError(callback?: () => void): void
|
|
244
|
-
/** 取消监听 onWaiting 事件
|
|
360
|
+
/** 取消监听 onWaiting 事件
|
|
361
|
+
* @supported weapp, h5, rn
|
|
362
|
+
*/
|
|
245
363
|
offWaiting(callback?: () => void): void
|
|
246
|
-
/** 取消监听 onSeeking 事件
|
|
364
|
+
/** 取消监听 onSeeking 事件
|
|
365
|
+
* @supported weapp, h5, rn
|
|
366
|
+
*/
|
|
247
367
|
offSeeking(callback?: () => void): void
|
|
248
|
-
/** 取消监听 onSeeked 事件
|
|
368
|
+
/** 取消监听 onSeeked 事件
|
|
369
|
+
* @supported weapp, h5, rn
|
|
370
|
+
*/
|
|
249
371
|
offSeeked(callback?: () => void): void
|
|
250
372
|
}
|
|
251
373
|
|
|
@@ -271,9 +393,396 @@ declare module '../../index' {
|
|
|
271
393
|
}
|
|
272
394
|
}
|
|
273
395
|
|
|
396
|
+
/** MediaAudioPlayer 实例,可通过 [Taro.createMediaAudioPlayer](./createMediaAudioPlayer) 接口获取实例。
|
|
397
|
+
* @supported weapp
|
|
398
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.html
|
|
399
|
+
*/
|
|
400
|
+
interface MediaAudioPlayer {
|
|
401
|
+
/** 音量。范围 0~1
|
|
402
|
+
* @default 1
|
|
403
|
+
*/
|
|
404
|
+
volume: number
|
|
405
|
+
|
|
406
|
+
/** 启动播放器
|
|
407
|
+
* @supported weapp
|
|
408
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.start.html
|
|
409
|
+
*/
|
|
410
|
+
start(): Promise<void>
|
|
411
|
+
|
|
412
|
+
/** 添加音频源
|
|
413
|
+
* @supported weapp
|
|
414
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.addAudioSource.html
|
|
415
|
+
*/
|
|
416
|
+
addAudioSource(
|
|
417
|
+
/** 视频解码器实例。作为音频源添加到音频播放器中 */
|
|
418
|
+
source: VideoDecoder
|
|
419
|
+
): Promise<void>
|
|
420
|
+
|
|
421
|
+
/** 移除音频源
|
|
422
|
+
* @supported weapp
|
|
423
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.removeAudioSource.html
|
|
424
|
+
*/
|
|
425
|
+
removeAudioSource(
|
|
426
|
+
/** 视频解码器实例 */
|
|
427
|
+
source: VideoDecoder
|
|
428
|
+
): Promise<void>
|
|
429
|
+
|
|
430
|
+
/** 停止播放器
|
|
431
|
+
* @supported weapp
|
|
432
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.stop.html
|
|
433
|
+
*/
|
|
434
|
+
stop(): Promise<void>
|
|
435
|
+
|
|
436
|
+
/** 销毁播放器
|
|
437
|
+
* @supported weapp
|
|
438
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.destroy.html
|
|
439
|
+
*/
|
|
440
|
+
destroy(): Promise<void>
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** WebAudioContext 实例,通过 [Taro.createWebAudioContext](./createWebAudioContext) 接口获取该实例。
|
|
444
|
+
* @supported weapp
|
|
445
|
+
* @example
|
|
446
|
+
* 监听状态
|
|
447
|
+
*
|
|
448
|
+
* ```tsx
|
|
449
|
+
* const audioCtx = Taro.createWebAudioContext()
|
|
450
|
+
* audioCtx.onstatechange = () => {
|
|
451
|
+
* console.log(ctx.state)
|
|
452
|
+
* }
|
|
453
|
+
* setTimeout(audioCtx.suspend, 1000)
|
|
454
|
+
* setTimeout(audioCtx.resume, 2000)
|
|
455
|
+
* ```
|
|
456
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.html
|
|
457
|
+
*/
|
|
458
|
+
interface WebAudioContext {
|
|
459
|
+
/** 当前 WebAudio 上下文的状态。
|
|
460
|
+
*
|
|
461
|
+
* 可能的值如下:suspended(暂停)、running(正在运行)、closed(已关闭)。
|
|
462
|
+
* 需要注意的是,不要在 audioContext close 后再访问 state 属性
|
|
463
|
+
*/
|
|
464
|
+
state: string
|
|
465
|
+
|
|
466
|
+
/** 可写属性,开发者可以对该属性设置一个监听函数,当 WebAudio 状态改变的时候,会触发开发者设置的监听函数。 */
|
|
467
|
+
onstatechange: () => void
|
|
468
|
+
|
|
469
|
+
/** 获取当前上下文的时间戳。 */
|
|
470
|
+
currentTime: number
|
|
471
|
+
|
|
472
|
+
/** 当前上下文的最终目标节点,一般是音频渲染设备。 */
|
|
473
|
+
destination: WebAudioContextNode
|
|
474
|
+
|
|
475
|
+
/** 空间音频监听器。 */
|
|
476
|
+
listener: AudioListener
|
|
477
|
+
|
|
478
|
+
/** 采样率,通常在 8000-96000 之间,通常 44100hz 的采样率最为常见。 */
|
|
479
|
+
sampleRate: number
|
|
480
|
+
|
|
481
|
+
/** 关闭WebAudioContext
|
|
482
|
+
*
|
|
483
|
+
* **注意事项**
|
|
484
|
+
* 同步关闭对应的 WebAudio 上下文。close 后会立即释放当前上下文的资源,**不要在 close 后再次访问 state 属性**。
|
|
485
|
+
* @supported weapp
|
|
486
|
+
* @example
|
|
487
|
+
* ```tsx
|
|
488
|
+
* const audioCtx = Taro.createWebAudioContext()
|
|
489
|
+
* audioCtx.close().then(() => {
|
|
490
|
+
* console.log(audioCtx.state) // bad case:不应该在close后再访问state
|
|
491
|
+
* })
|
|
492
|
+
* ```
|
|
493
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.close.html
|
|
494
|
+
*/
|
|
495
|
+
close(): Promise<void>
|
|
496
|
+
|
|
497
|
+
/** 同步恢复已经被暂停的 WebAudioContext 上下文
|
|
498
|
+
* @supported weapp
|
|
499
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.resume.html
|
|
500
|
+
*/
|
|
501
|
+
resume(): Promise<void>
|
|
502
|
+
|
|
503
|
+
/** 同步暂停 WebAudioContext 上下文
|
|
504
|
+
* @supported weapp
|
|
505
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.suspend.html
|
|
506
|
+
*/
|
|
507
|
+
suspend(): Promise<void>
|
|
508
|
+
|
|
509
|
+
/** 创建一个 IIRFilterNode
|
|
510
|
+
* @supported weapp
|
|
511
|
+
* @example
|
|
512
|
+
* ```tsx
|
|
513
|
+
* let lowPassCoefs = [
|
|
514
|
+
* {
|
|
515
|
+
* frequency: 200,
|
|
516
|
+
* feedforward: [0.00020298, 0.0004059599, 0.00020298],
|
|
517
|
+
* feedback: [1.0126964558, -1.9991880801, 0.9873035442]
|
|
518
|
+
* },
|
|
519
|
+
* {
|
|
520
|
+
* frequency: 500,
|
|
521
|
+
* feedforward: [0.0012681742, 0.0025363483, 0.0012681742],
|
|
522
|
+
* feedback: [1.0317185917, -1.9949273033, 0.9682814083]
|
|
523
|
+
* },
|
|
524
|
+
* {
|
|
525
|
+
* frequency: 1000,
|
|
526
|
+
* feedforward: [0.0050662636, 0.0101325272, 0.0050662636],
|
|
527
|
+
* feedback: [1.0632762845, -1.9797349456, 0.9367237155]
|
|
528
|
+
* },
|
|
529
|
+
* {
|
|
530
|
+
* frequency: 5000,
|
|
531
|
+
* feedforward: [0.1215955842, 0.2431911684, 0.1215955842],
|
|
532
|
+
* feedback: [1.2912769759, -1.5136176632, 0.7087230241]
|
|
533
|
+
* }
|
|
534
|
+
* ]
|
|
535
|
+
*
|
|
536
|
+
* const feedForward = lowPassCoefs[filterNumber].feedforward
|
|
537
|
+
* const feedBack = lowPassCoefs[filterNumber].feedback
|
|
538
|
+
* const iirFilter = audioContext.createIIRFilter(feedForward, feedBack)
|
|
539
|
+
* ```
|
|
540
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createIIRFilter.html
|
|
541
|
+
*/
|
|
542
|
+
createIIRFilter(
|
|
543
|
+
/** 一个浮点值数组,指定IIR滤波器传递函数的前馈(分子)系数。 */
|
|
544
|
+
feedforward: number[],
|
|
545
|
+
/** 一个浮点值数组,指定IIR滤波器传递函数的反馈(分母)系数。 */
|
|
546
|
+
feedback: number[]
|
|
547
|
+
): IIRFilterNode
|
|
548
|
+
|
|
549
|
+
/** 创建一个 WaveShaperNode
|
|
550
|
+
* @supported weapp
|
|
551
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createWaveShaper.html
|
|
552
|
+
*/
|
|
553
|
+
createWaveShaper(): WaveShaperNode
|
|
554
|
+
|
|
555
|
+
/** 创建一个 ConstantSourceNode
|
|
556
|
+
* @supported weapp
|
|
557
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createConstantSource.html
|
|
558
|
+
*/
|
|
559
|
+
createConstantSource(): ConstantSourceNode
|
|
560
|
+
|
|
561
|
+
/** 创建一个 OscillatorNode
|
|
562
|
+
* @supported weapp
|
|
563
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createOscillator.html
|
|
564
|
+
*/
|
|
565
|
+
createOscillator(): OscillatorNode
|
|
566
|
+
|
|
567
|
+
/** 创建一个 GainNode
|
|
568
|
+
* @supported weapp
|
|
569
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createGain.html
|
|
570
|
+
*/
|
|
571
|
+
createGain(): GainNode
|
|
572
|
+
|
|
573
|
+
/** 创建一个 PeriodicWaveNode
|
|
574
|
+
*
|
|
575
|
+
* **注意**
|
|
576
|
+
* `real` 和 `imag` 数组必须拥有一样的长度,否则抛出错误
|
|
577
|
+
*
|
|
578
|
+
* ```tsx
|
|
579
|
+
* const real = new Float32Array(2)
|
|
580
|
+
* const imag = new Float32Array(2)
|
|
581
|
+
* real[0] = 0
|
|
582
|
+
* imag[0] = 0
|
|
583
|
+
* real[1] = 1
|
|
584
|
+
* imag[1] = 0
|
|
585
|
+
*
|
|
586
|
+
* const waveNode = audioContext.createPeriodicWave(real, imag, {disableNormalization: true})
|
|
587
|
+
* ```
|
|
588
|
+
* @supported weapp
|
|
589
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createPeriodicWave.html
|
|
590
|
+
*/
|
|
591
|
+
createPeriodicWave(
|
|
592
|
+
/** 一组余弦项(传统上是A项) */
|
|
593
|
+
real: Float32Array,
|
|
594
|
+
/** 一组余弦项(传统上是A项) */
|
|
595
|
+
imag: Float32Array,
|
|
596
|
+
/** 一个字典对象,它指定是否应该禁用规范化(默认启用规范化) */
|
|
597
|
+
constraints: WebAudioContext.createPeriodicWave.Constraints
|
|
598
|
+
): PeriodicWave
|
|
599
|
+
|
|
600
|
+
/** 创建一个BiquadFilterNode
|
|
601
|
+
* @supported weapp
|
|
602
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBiquadFilter.html
|
|
603
|
+
*/
|
|
604
|
+
createBiquadFilter(): BiquadFilterNode
|
|
605
|
+
|
|
606
|
+
/** 创建一个 BufferSourceNode 实例,通过 AudioBuffer 对象来播放音频数据。
|
|
607
|
+
* @supported weapp
|
|
608
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBufferSource.html
|
|
609
|
+
*/
|
|
610
|
+
createBufferSource(): AudioBufferSourceNode
|
|
611
|
+
|
|
612
|
+
/** 创建一个ChannelMergerNode
|
|
613
|
+
* @supported weapp
|
|
614
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createChannelMerger.html
|
|
615
|
+
*/
|
|
616
|
+
createChannelMerger(
|
|
617
|
+
/** 输出流中需要保持的输入流的个数 */
|
|
618
|
+
numberOfInputs: number
|
|
619
|
+
): ChannelMergerNode
|
|
620
|
+
|
|
621
|
+
/** 创建一个ChannelSplitterNode
|
|
622
|
+
* @supported weapp
|
|
623
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createChannelSplitter.html
|
|
624
|
+
*/
|
|
625
|
+
createChannelSplitter(
|
|
626
|
+
/** 要分别输出的输入音频流中的通道数 */
|
|
627
|
+
numberOfOutputs: number
|
|
628
|
+
): ChannelSplitterNode
|
|
629
|
+
|
|
630
|
+
/** 创建一个DelayNode
|
|
631
|
+
* @supported weapp
|
|
632
|
+
* @example
|
|
633
|
+
* ```tsx
|
|
634
|
+
* let audioCtx = Taro.createWebAudioContext()
|
|
635
|
+
* const delayNode = audioCtx.createDelay(5)
|
|
636
|
+
* ```
|
|
637
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createDelay.html
|
|
638
|
+
*/
|
|
639
|
+
createDelay(
|
|
640
|
+
/** 最大延迟时间 */
|
|
641
|
+
maxDelayTime: number
|
|
642
|
+
): DelayNode
|
|
643
|
+
|
|
644
|
+
/** 创建一个DynamicsCompressorNode
|
|
645
|
+
* @supported weapp
|
|
646
|
+
* @example
|
|
647
|
+
* ```tsx
|
|
648
|
+
* let audioCtx = Taro.createWebAudioContext()
|
|
649
|
+
* let compressor = audioCtx.createDynamicsCompressor()
|
|
650
|
+
*
|
|
651
|
+
* compressor.threshold.value = -50
|
|
652
|
+
* compressor.knee.value = 40
|
|
653
|
+
* compressor.ratio.value = 12
|
|
654
|
+
* compressor.attack.value = 0
|
|
655
|
+
* compressor.release.value = 0.25
|
|
656
|
+
* ```
|
|
657
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createDynamicsCompressor.html
|
|
658
|
+
*/
|
|
659
|
+
createDynamicsCompressor(): DynamicsCompressorNode
|
|
660
|
+
|
|
661
|
+
/** 创建一个ScriptProcessorNode
|
|
662
|
+
* @supported weapp
|
|
663
|
+
* @example
|
|
664
|
+
* ```tsx
|
|
665
|
+
* let audioCtx = Taro.createWebAudioContext()
|
|
666
|
+
* const sampleSize = 4096
|
|
667
|
+
* audioContext.createScriptProcessor(sampleSize, 1, 1)
|
|
668
|
+
* ```
|
|
669
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createScriptProcessor.html
|
|
670
|
+
*/
|
|
671
|
+
createScriptProcessor(
|
|
672
|
+
/** 缓冲区大小,以样本帧为单位 */
|
|
673
|
+
bufferSize: number,
|
|
674
|
+
/** 用于指定输入 node 的声道的数量 */
|
|
675
|
+
numberOfInputChannels: number,
|
|
676
|
+
/** 用于指定输出 node 的声道的数量 */
|
|
677
|
+
numberOfOutputChannels: number
|
|
678
|
+
): ScriptProcessorNode
|
|
679
|
+
|
|
680
|
+
/** 创建一个PannerNode
|
|
681
|
+
* @supported weapp
|
|
682
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createPanner.html
|
|
683
|
+
*/
|
|
684
|
+
createPanner(): PannerNode
|
|
685
|
+
|
|
686
|
+
/** 创建一个AudioBuffer,代表着一段驻留在内存中的短音频
|
|
687
|
+
* @supported weapp
|
|
688
|
+
* @example
|
|
689
|
+
* ```tsx
|
|
690
|
+
* const audioCtx = Taro.createWebAudioContext()
|
|
691
|
+
* const channels = 2, frameCount = audioCtx.sampleRate * 2.0
|
|
692
|
+
* const myArrayBuffer = audioCtx.createBuffer(channels, frameCount, audioCtx.sampleRate)
|
|
693
|
+
* ```
|
|
694
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.createBuffer.html
|
|
695
|
+
*/
|
|
696
|
+
createBuffer(
|
|
697
|
+
/** 定义了 buffer 中包含的声频通道数量的整数 */
|
|
698
|
+
numOfChannels: number,
|
|
699
|
+
/** 代表 buffer 中的样本帧数的整数 */
|
|
700
|
+
length: number,
|
|
701
|
+
/** 线性音频样本的采样率,即每一秒包含的关键帧的个数 */
|
|
702
|
+
sampleRate: number
|
|
703
|
+
): AudioBuffer
|
|
704
|
+
|
|
705
|
+
/** 异步解码一段资源为AudioBuffer。
|
|
706
|
+
* @supported weapp
|
|
707
|
+
* @example
|
|
708
|
+
* ```tsx
|
|
709
|
+
* Taro.request({
|
|
710
|
+
* url: url, // 音频 url
|
|
711
|
+
* responseType: 'arraybuffer',
|
|
712
|
+
* success: res => {
|
|
713
|
+
* audioCtx.decodeAudioData(res.data, buffer => {
|
|
714
|
+
* console.log(buffer)
|
|
715
|
+
* }, err => {
|
|
716
|
+
* console.error('decodeAudioData fail', err)
|
|
717
|
+
* })
|
|
718
|
+
* }
|
|
719
|
+
* })
|
|
720
|
+
* ```
|
|
721
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.decodeAudioData.html
|
|
722
|
+
*/
|
|
723
|
+
decodeAudioData(): AudioBuffer
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
namespace WebAudioContext {
|
|
727
|
+
namespace createPeriodicWave {
|
|
728
|
+
/** 字典对象 */
|
|
729
|
+
interface Constraints {
|
|
730
|
+
/** 如果指定为 true 则禁用标准化
|
|
731
|
+
* @default false
|
|
732
|
+
*/
|
|
733
|
+
disableNormalization?: boolean
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/** 一类音频处理模块,不同的Node具备不同的功能,如GainNode(音量调整)等。一个 WebAudioContextNode 可以通过上下文来创建。
|
|
739
|
+
*
|
|
740
|
+
* > 目前已经支持以下Node: IIRFilterNode WaveShaperNode ConstantSourceNode ChannelMergerNode OscillatorNode GainNode BiquadFilterNode PeriodicWaveNode BufferSourceNode ChannelSplitterNode ChannelMergerNode DelayNode DynamicsCompressorNode ScriptProcessorNode PannerNode
|
|
741
|
+
* @supported weapp
|
|
742
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContextNode.html
|
|
743
|
+
*/
|
|
744
|
+
interface WebAudioContextNode {
|
|
745
|
+
/** 右手笛卡尔坐标系中X轴的位置。 */
|
|
746
|
+
positionX: number
|
|
747
|
+
|
|
748
|
+
/** 右手笛卡尔坐标系中Y轴的位置。 */
|
|
749
|
+
positionY: number
|
|
750
|
+
|
|
751
|
+
/** 右手笛卡尔坐标系中Z轴的位置。 */
|
|
752
|
+
positionZ: number
|
|
753
|
+
|
|
754
|
+
/** 表示监听器的前向系统在同一笛卡尔坐标系中的水平位置,作为位置(位置x,位置和位置和位置)值。 */
|
|
755
|
+
forwardX: number
|
|
756
|
+
|
|
757
|
+
/** 表示听众的前向方向在同一笛卡尔坐标系中作为位置(位置x,位置和位置和位置)值的垂直位置。 */
|
|
758
|
+
forwardY: number
|
|
759
|
+
|
|
760
|
+
/** 表示与position (positionX、positionY和positionZ)值在同一笛卡尔坐标系下的听者前进方向的纵向(前后)位置。 */
|
|
761
|
+
forwardZ: number
|
|
762
|
+
|
|
763
|
+
/** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向前方向的水平位置。 */
|
|
764
|
+
upX: number
|
|
765
|
+
|
|
766
|
+
/** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向上方向的水平位置。 */
|
|
767
|
+
upY: number
|
|
768
|
+
|
|
769
|
+
/** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向后方向的水平位置。 */
|
|
770
|
+
upZ: number
|
|
771
|
+
|
|
772
|
+
/** 设置监听器的方向
|
|
773
|
+
* @supported weapp
|
|
774
|
+
*/
|
|
775
|
+
setOrientation(...args: any[]): void
|
|
776
|
+
|
|
777
|
+
/** 设置监听器的位置
|
|
778
|
+
* @supported weapp
|
|
779
|
+
*/
|
|
780
|
+
setPosition(...args: any[]): void
|
|
781
|
+
}
|
|
782
|
+
|
|
274
783
|
interface TaroStatic {
|
|
275
784
|
/** 结束播放语音。
|
|
276
|
-
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](
|
|
785
|
+
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](./createInnerAudioContext) 接口**
|
|
277
786
|
* @supported weapp
|
|
278
787
|
* @example
|
|
279
788
|
* ```tsx
|
|
@@ -299,7 +808,7 @@ declare module '../../index' {
|
|
|
299
808
|
*/
|
|
300
809
|
stopVoice(option?: stopVoice.Option): void
|
|
301
810
|
|
|
302
|
-
/** 设置 [InnerAudioContext](
|
|
811
|
+
/** 设置 [InnerAudioContext](/docs/apis/media/audio/InnerAudioContext)项。设置之后对当前小程序全局生效。
|
|
303
812
|
* @supported weapp
|
|
304
813
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.setInnerAudioOption.html
|
|
305
814
|
*/
|
|
@@ -323,8 +832,8 @@ declare module '../../index' {
|
|
|
323
832
|
*/
|
|
324
833
|
playVoice(option: playVoice.Option): Promise<TaroGeneral.CallbackResult>
|
|
325
834
|
|
|
326
|
-
/** 暂停正在播放的语音。再次调用 [Taro.playVoice](
|
|
327
|
-
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](
|
|
835
|
+
/** 暂停正在播放的语音。再次调用 [Taro.playVoice](/docs/apis/media/audio/stopVoice)。
|
|
836
|
+
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](./createInnerAudioContext) 接口**
|
|
328
837
|
* @supported weapp
|
|
329
838
|
* @example
|
|
330
839
|
* ```tsx
|
|
@@ -351,13 +860,95 @@ declare module '../../index' {
|
|
|
351
860
|
*/
|
|
352
861
|
getAvailableAudioSources(option?: getAvailableAudioSources.Option): Promise<getAvailableAudioSources.SuccessCallbackResult>
|
|
353
862
|
|
|
863
|
+
/** 创建 WebAudio 上下文。
|
|
864
|
+
* @supported weapp
|
|
865
|
+
* @example
|
|
866
|
+
* 一个简单的播放demo
|
|
867
|
+
*
|
|
868
|
+
* ```tsx
|
|
869
|
+
* const audioCtx = Taro.createWebAudioContext()
|
|
870
|
+
*
|
|
871
|
+
* const loadAudio = (url) => {
|
|
872
|
+
* return new Promise((resolve) => {
|
|
873
|
+
* Taro.request({
|
|
874
|
+
* url,
|
|
875
|
+
* responseType: 'arraybuffer',
|
|
876
|
+
* success: res => {
|
|
877
|
+
* console.log('res.data', res.data)
|
|
878
|
+
* audioCtx.decodeAudioData(res.data, buffer => {
|
|
879
|
+
* resolve(buffer)
|
|
880
|
+
* }, err => {
|
|
881
|
+
* console.error('decodeAudioData fail', err)
|
|
882
|
+
* reject()
|
|
883
|
+
* })
|
|
884
|
+
* },
|
|
885
|
+
* fail: res => {
|
|
886
|
+
* console.error('request fail', res)
|
|
887
|
+
* reject()
|
|
888
|
+
* }
|
|
889
|
+
* })
|
|
890
|
+
* })
|
|
891
|
+
* }
|
|
892
|
+
*
|
|
893
|
+
* const play = () => {
|
|
894
|
+
* loadAudio('xxx-test.mp3').then(buffer => {
|
|
895
|
+
* const source = audioCtx.createBufferSource()
|
|
896
|
+
* source.buffer = buffer
|
|
897
|
+
* source.connect(audioCtx.destination)
|
|
898
|
+
* source.start()
|
|
899
|
+
* }).catch(() => {
|
|
900
|
+
* console.log('fail')
|
|
901
|
+
* })
|
|
902
|
+
* }
|
|
903
|
+
*
|
|
904
|
+
* play()
|
|
905
|
+
* ```
|
|
906
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createWebAudioContext.html
|
|
907
|
+
*/
|
|
908
|
+
createWebAudioContext(): WebAudioContext
|
|
909
|
+
|
|
910
|
+
/** 创建媒体音频播放器对象 [MediaAudioPlayer](./MediaAudioPlayer) 对象,可用于播放视频解码器 [VideoDecoder](/docs/apis/media/video-decoder/VideoDecoder) 输出的音频
|
|
911
|
+
*
|
|
912
|
+
* **注意事项**
|
|
913
|
+
* - iOS 7.0.15 mediaAudioPlayer 播放网络视频资源会出现音频卡顿,本地视频没有这个问题,将下一个客户端版本修复。
|
|
914
|
+
* @supported weapp
|
|
915
|
+
* @example
|
|
916
|
+
* ```tsx
|
|
917
|
+
* // 创建视频解码器,具体参数见 createVideoDecoder 文档
|
|
918
|
+
* const videoDecoder = Taro.createVideoDecoder()
|
|
919
|
+
* // 创建媒体音频播放器
|
|
920
|
+
* const mediaAudioPlayer = Taro.createMediaAudioPlayer()
|
|
921
|
+
* // 启动视频解码器
|
|
922
|
+
* videoDecoder.start()
|
|
923
|
+
* // 启动播放器
|
|
924
|
+
* mediaAudioPlayer.start().then(() => {
|
|
925
|
+
* // 添加播放器音频来源
|
|
926
|
+
* mediaAudioPlayer.addAudioSource(videoDecoder).then(res => {
|
|
927
|
+
* videoDecoder.getFrameData() // 建议在 requestAnimationFrame 里获取每一帧视频数据
|
|
928
|
+
* console.log(res)
|
|
929
|
+
* })
|
|
930
|
+
*
|
|
931
|
+
* // 移除播放器音频来源
|
|
932
|
+
* mediaAudioPlayer.removeAudioSource(videoDecoder).then()
|
|
933
|
+
* // 停止播放器
|
|
934
|
+
* mediaAudioPlayer.stop().then()
|
|
935
|
+
* // 销毁播放器
|
|
936
|
+
* mediaAudioPlayer.destroy().then()
|
|
937
|
+
* // 设置播放器音量
|
|
938
|
+
* mediaAudioPlayer.volume = 0.5
|
|
939
|
+
* })
|
|
940
|
+
*```
|
|
941
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createMediaAudioPlayer.html
|
|
942
|
+
*/
|
|
943
|
+
createMediaAudioPlayer(): MediaAudioPlayer
|
|
944
|
+
|
|
354
945
|
/** 创建内部 audio 上下文 InnerAudioContext 对象。
|
|
355
|
-
* @supported weapp, h5
|
|
946
|
+
* @supported weapp, h5, rn, tt
|
|
356
947
|
* @example
|
|
357
948
|
* ```tsx
|
|
358
949
|
* const innerAudioContext = Taro.createInnerAudioContext()
|
|
359
950
|
* innerAudioContext.autoplay = true
|
|
360
|
-
* innerAudioContext.src = '
|
|
951
|
+
* innerAudioContext.src = 'https://storage.360buyimg.com/jdrd-blog/27.mp3'
|
|
361
952
|
* innerAudioContext.onPlay(() => {
|
|
362
953
|
* console.log('开始播放')
|
|
363
954
|
* })
|
|
@@ -371,7 +962,7 @@ declare module '../../index' {
|
|
|
371
962
|
createInnerAudioContext(): InnerAudioContext
|
|
372
963
|
|
|
373
964
|
/** 创建 audio 上下文 AudioContext 对象。
|
|
374
|
-
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](
|
|
965
|
+
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](./createInnerAudioContext) 接口**
|
|
375
966
|
* @supported weapp
|
|
376
967
|
* @example
|
|
377
968
|
* ```tsx
|
|
@@ -380,9 +971,9 @@ declare module '../../index' {
|
|
|
380
971
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createAudioContext.html
|
|
381
972
|
*/
|
|
382
973
|
createAudioContext(
|
|
383
|
-
/** [audio](
|
|
974
|
+
/** [audio](/docs/components/media/audio) 组件的 id */
|
|
384
975
|
id: string,
|
|
385
|
-
/** 在自定义组件下,当前组件实例的this,以操作组件内 [audio](
|
|
976
|
+
/** 在自定义组件下,当前组件实例的this,以操作组件内 [audio](/docs/components/media/audio) 组件 */
|
|
386
977
|
component?: TaroGeneral.IAnyObject,
|
|
387
978
|
): AudioContext
|
|
388
979
|
}
|