@tarojs/taro 3.3.13 → 3.3.14

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.
Files changed (97) hide show
  1. package/package.json +5 -5
  2. package/types/api/ad/index.d.ts +34 -28
  3. package/types/api/alipay/index.d.ts +11 -7
  4. package/types/api/base/debug.d.ts +60 -54
  5. package/types/api/base/env.d.ts +12 -8
  6. package/types/api/base/index.d.ts +87 -83
  7. package/types/api/base/system.d.ts +59 -54
  8. package/types/api/base/update.d.ts +37 -33
  9. package/types/api/base/weapp/app-event.d.ts +147 -131
  10. package/types/api/base/weapp/life-cycle.d.ts +14 -10
  11. package/types/api/canvas/index.d.ts +115 -110
  12. package/types/api/cloud/index.d.ts +99 -94
  13. package/types/api/data-analysis/index.d.ts +68 -64
  14. package/types/api/device/accelerometer.d.ts +57 -50
  15. package/types/api/device/battery.d.ts +19 -15
  16. package/types/api/device/ble.d.ts +241 -228
  17. package/types/api/device/bluetooth.d.ts +207 -194
  18. package/types/api/device/clipboard.d.ts +48 -43
  19. package/types/api/device/compass.d.ts +55 -48
  20. package/types/api/device/contact.d.ts +13 -9
  21. package/types/api/device/gyroscope.d.ts +41 -35
  22. package/types/api/device/iBeacon.d.ts +79 -73
  23. package/types/api/device/motion.d.ts +42 -37
  24. package/types/api/device/network.d.ts +48 -42
  25. package/types/api/device/nfc.d.ts +105 -96
  26. package/types/api/device/performance.d.ts +22 -18
  27. package/types/api/device/phone.d.ts +20 -15
  28. package/types/api/device/scan.d.ts +31 -26
  29. package/types/api/device/screen.d.ts +74 -67
  30. package/types/api/device/vibrate.d.ts +31 -25
  31. package/types/api/device/wifi.d.ts +151 -140
  32. package/types/api/ext/index.d.ts +44 -39
  33. package/types/api/files/index.d.ts +219 -209
  34. package/types/api/framework/index.d.ts +25 -20
  35. package/types/api/location/index.d.ts +140 -136
  36. package/types/api/media/audio.d.ts +135 -127
  37. package/types/api/media/background-audio.d.ts +135 -126
  38. package/types/api/media/camera.d.ts +30 -26
  39. package/types/api/media/editor.d.ts +35 -33
  40. package/types/api/media/image.d.ts +161 -150
  41. package/types/api/media/live.d.ts +88 -82
  42. package/types/api/media/map.d.ts +47 -43
  43. package/types/api/media/recorder.d.ts +90 -84
  44. package/types/api/media/video-processing.d.ts +10 -6
  45. package/types/api/media/video.d.ts +63 -58
  46. package/types/api/network/download.d.ts +34 -30
  47. package/types/api/network/mdns.d.ts +104 -91
  48. package/types/api/network/request.d.ts +83 -79
  49. package/types/api/network/udp.d.ts +20 -16
  50. package/types/api/network/upload.d.ts +60 -56
  51. package/types/api/network/websocket.d.ts +201 -194
  52. package/types/api/open-api/account.d.ts +18 -14
  53. package/types/api/open-api/address.d.ts +27 -23
  54. package/types/api/open-api/authorize.d.ts +30 -26
  55. package/types/api/open-api/card.d.ts +55 -51
  56. package/types/api/open-api/customer-service.d.ts +21 -17
  57. package/types/api/open-api/facial.d.ts +28 -24
  58. package/types/api/open-api/invoice.d.ts +38 -34
  59. package/types/api/open-api/login.d.ts +56 -52
  60. package/types/api/open-api/navigate.d.ts +79 -75
  61. package/types/api/open-api/payment.d.ts +34 -30
  62. package/types/api/open-api/settings.d.ts +49 -45
  63. package/types/api/open-api/soter.d.ts +92 -86
  64. package/types/api/open-api/subscribe-message.d.ts +24 -20
  65. package/types/api/open-api/user-info.d.ts +60 -57
  66. package/types/api/open-api/werun.d.ts +50 -46
  67. package/types/api/route/index.d.ts +122 -118
  68. package/types/api/share/index.d.ts +68 -64
  69. package/types/api/storage/background-fetch.d.ts +40 -35
  70. package/types/api/storage/index.d.ts +267 -262
  71. package/types/api/swan/index.d.ts +47 -42
  72. package/types/api/ui/animation.d.ts +21 -17
  73. package/types/api/ui/background.d.ts +38 -34
  74. package/types/api/ui/custom-component.d.ts +22 -18
  75. package/types/api/ui/fonts.d.ts +26 -21
  76. package/types/api/ui/interaction.d.ts +153 -149
  77. package/types/api/ui/keyboard.d.ts +59 -55
  78. package/types/api/ui/menu.d.ts +10 -6
  79. package/types/api/ui/navigation-bar.d.ts +67 -63
  80. package/types/api/ui/pull-down-refresh.d.ts +33 -29
  81. package/types/api/ui/scroll.d.ts +30 -26
  82. package/types/api/ui/sticky.d.ts +22 -19
  83. package/types/api/ui/tab-bar.d.ts +101 -97
  84. package/types/api/ui/window.d.ts +24 -18
  85. package/types/api/worker/index.d.ts +28 -24
  86. package/types/api/wxml/index.d.ts +42 -38
  87. package/types/global.d.ts +350 -0
  88. package/types/index.d.ts +12 -98
  89. package/types/taro.api.d.ts +94 -0
  90. package/types/taro.component.d.ts +10 -57
  91. package/types/taro.config.d.ts +24 -6
  92. package/types/taro.extend.d.ts +70 -67
  93. package/types/taro.hooks.d.ts +68 -67
  94. package/types/taro.lifecycle.d.ts +47 -28
  95. package/types/api/ad/index.ts +0 -6
  96. package/types/api/alipay/index.ts +0 -7
  97. package/types/api/index.d.ts +0 -352
@@ -1,136 +1,68 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace stopVoice {
3
5
  interface Option {
4
6
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
5
- complete?: (res: General.CallbackResult) => void
7
+ complete?: (res: TaroGeneral.CallbackResult) => void
6
8
  /** 接口调用失败的回调函数 */
7
- fail?: (res: General.CallbackResult) => void
9
+ fail?: (res: TaroGeneral.CallbackResult) => void
8
10
  /** 接口调用成功的回调函数 */
9
- success?: (res: General.CallbackResult) => void
11
+ success?: (res: TaroGeneral.CallbackResult) => void
10
12
  }
11
13
  }
12
- /** 结束播放语音。
13
- * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口**
14
- * @supported weapp
15
- * @example
16
- * ```tsx
17
- * Taro.startRecord({
18
- * success: function (res) {
19
- * const filePath = res.tempFilePath
20
- * Taro.playVoice({ filePath })
21
- *
22
- * setTimeout(Taro.stopVoice, 5000)
23
- * }
24
- * })
25
- * ```
26
- * @example
27
- * ```tsx
28
- * Taro.startRecord(params).then(res => {
29
- * const filePath = res.tempFilePath
30
- * Taro.playVoice({ filePath })
31
- *
32
- * setTimeout(Taro.stopVoice, 5000)
33
- * })
34
- * ```
35
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.stopVoice.html
36
- */
37
- function stopVoice(option?: stopVoice.Option): void
38
14
 
39
15
  namespace setInnerAudioOption {
40
16
  interface Option {
41
17
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
42
- complete?: (res: General.CallbackResult) => void
18
+ complete?: (res: TaroGeneral.CallbackResult) => void
43
19
  /** 接口调用失败的回调函数 */
44
- fail?: (res: General.CallbackResult) => void
20
+ fail?: (res: TaroGeneral.CallbackResult) => void
45
21
  /** 是否与其他音频混播,设置为 true 之后,不会终止其他应用或微信内的音乐 */
46
22
  mixWithOther?: boolean
47
23
  /** (仅在 iOS 生效)是否遵循静音开关,设置为 false 之后,即使是在静音模式下,也能播放声音 */
48
24
  obeyMuteSwitch?: boolean
49
25
  /** 接口调用成功的回调函数 */
50
- success?: (res: General.CallbackResult) => void
26
+ success?: (res: TaroGeneral.CallbackResult) => void
51
27
  }
52
28
  }
53
29
 
54
- /** 设置 [InnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.html) 的播放选项。设置之后对当前小程序全局生效。
55
- * @supported weapp
56
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.setInnerAudioOption.html
57
- */
58
- function setInnerAudioOption(option: setInnerAudioOption.Option): Promise<General.CallbackResult>
59
-
60
30
  namespace playVoice {
61
31
  interface Option {
62
32
  /** 需要播放的语音文件的文件路径 */
63
33
  filePath: string
64
34
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
65
- complete?: (res: General.CallbackResult) => void
35
+ complete?: (res: TaroGeneral.CallbackResult) => void
66
36
  /** 指定录音时长,到达指定的录音时长后会自动停止录音,单位:秒 */
67
37
  duration?: number
68
38
  /** 接口调用失败的回调函数 */
69
- fail?: (res: General.CallbackResult) => void
39
+ fail?: (res: TaroGeneral.CallbackResult) => void
70
40
  /** 接口调用成功的回调函数 */
71
- success?: (res: General.CallbackResult) => void
41
+ success?: (res: TaroGeneral.CallbackResult) => void
72
42
  }
73
43
  }
74
- /** 开始播放语音。同时只允许一个语音文件正在播放,如果前一个语音文件还没播放完,将中断前一个语音播放。
75
- * @supported weapp
76
- * @example
77
- * ```tsx
78
- * Taro.startRecord({
79
- * success: function (res) {
80
- * const tempFilePath = res.tempFilePath
81
- * Taro.playVoice({
82
- * filePath: tempFilePath,
83
- * complete: function () { }
84
- * })
85
- * }
86
- * })
87
- * ```
88
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.playVoice.html
89
- */
90
- function playVoice(option: playVoice.Option): Promise<General.CallbackResult>
91
44
 
92
45
  namespace pauseVoice {
93
46
  interface Option {
94
47
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
95
- complete?: (res: General.CallbackResult) => void
48
+ complete?: (res: TaroGeneral.CallbackResult) => void
96
49
  /** 接口调用失败的回调函数 */
97
- fail?: (res: General.CallbackResult) => void
50
+ fail?: (res: TaroGeneral.CallbackResult) => void
98
51
  /** 接口调用成功的回调函数 */
99
- success?: (res: General.CallbackResult) => void
52
+ success?: (res: TaroGeneral.CallbackResult) => void
100
53
  }
101
54
  }
102
- /** 暂停正在播放的语音。再次调用 [Taro.playVoice](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.playVoice.html) 播放同一个文件时,会从暂停处开始播放。如果想从头开始播放,需要先调用 [Taro.stopVoice](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.stopVoice.html)。
103
- * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口**
104
- * @supported weapp
105
- * @example
106
- * ```tsx
107
- * Taro.startRecord({
108
- * success: function (res) {
109
- * var tempFilePath = res.tempFilePath
110
- * Taro.playVoice({
111
- * filePath: tempFilePath
112
- * })
113
- * setTimeout(function() {
114
- * //暂停播放
115
- * Taro.pauseVoice()
116
- * }, 5000)
117
- * }
118
- * })
119
- * ```
120
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.pauseVoice.html
121
- */
122
- function pauseVoice(option?: pauseVoice.Option): void
123
55
 
124
56
  namespace getAvailableAudioSources {
125
57
  interface Option {
126
58
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
127
- complete?: (res: General.CallbackResult) => void
59
+ complete?: (res: TaroGeneral.CallbackResult) => void
128
60
  /** 接口调用失败的回调函数 */
129
- fail?: (res: General.CallbackResult) => void
61
+ fail?: (res: TaroGeneral.CallbackResult) => void
130
62
  /** 接口调用成功的回调函数 */
131
63
  success?: (result: SuccessCallbackResult) => void
132
64
  }
133
- interface SuccessCallbackResult extends General.CallbackResult {
65
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
134
66
  /** 支持的音频输入源列表,可在 [RecorderManager.start()](https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.start.html) 接口中使用。返回值定义参考 https://developer.android.com/reference/kotlin/android/media/MediaRecorder.AudioSource */
135
67
  audioSources: Array<keyof audioSources>
136
68
  /** 调用结果 */
@@ -154,46 +86,6 @@ declare namespace Taro {
154
86
  'voice_recognition'
155
87
  }
156
88
  }
157
- /** 获取当前支持的音频输入源
158
- * @supported weapp
159
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.getAvailableAudioSources.html
160
- */
161
- function getAvailableAudioSources(option?: getAvailableAudioSources.Option): Promise<getAvailableAudioSources.SuccessCallbackResult>
162
-
163
- /** 创建内部 audio 上下文 InnerAudioContext 对象。
164
- * @supported weapp, h5
165
- * @example
166
- * ```tsx
167
- * const innerAudioContext = Taro.createInnerAudioContext()
168
- * innerAudioContext.autoplay = true
169
- * innerAudioContext.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
170
- * innerAudioContext.onPlay(() => {
171
- * console.log('开始播放')
172
- * })
173
- * innerAudioContext.onError((res) => {
174
- * console.log(res.errMsg)
175
- * console.log(res.errCode)
176
- * })
177
- * ```
178
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html
179
- */
180
- function createInnerAudioContext(): InnerAudioContext
181
-
182
- /** 创建 audio 上下文 AudioContext 对象。
183
- * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口**
184
- * @supported weapp
185
- * @example
186
- * ```tsx
187
- * const audioCtx = Taro.createAudioContext('myAudio')
188
- * ```
189
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createAudioContext.html
190
- */
191
- function createAudioContext(
192
- /** [audio](https://developers.weixin.qq.com/miniprogram/dev/component/audio.html) 组件的 id */
193
- id: string,
194
- /** 在自定义组件下,当前组件实例的this,以操作组件内 [audio](https://developers.weixin.qq.com/miniprogram/dev/component/audio.html) 组件 */
195
- component?: General.IAnyObject,
196
- ): AudioContext
197
89
 
198
90
  /** `AudioContext` 实例,可通过 `Taro.createAudioContext` 获取。
199
91
  * `AudioContext` 通过 `id` 跟一个 `audio` 组件绑定,操作对应的 audio 组件。
@@ -356,7 +248,7 @@ declare namespace Taro {
356
248
  }
357
249
 
358
250
  namespace InnerAudioContext {
359
- interface onErrorDetail extends General.CallbackResult {
251
+ interface onErrorDetail extends TaroGeneral.CallbackResult {
360
252
  /** 错误码 */
361
253
  errCode: number
362
254
  /** 错误信息 */
@@ -376,4 +268,120 @@ declare namespace Taro {
376
268
  '-1'
377
269
  }
378
270
  }
271
+
272
+ interface TaroStatic {
273
+ /** 结束播放语音。
274
+ * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口**
275
+ * @supported weapp
276
+ * @example
277
+ * ```tsx
278
+ * Taro.startRecord({
279
+ * success: function (res) {
280
+ * const filePath = res.tempFilePath
281
+ * Taro.playVoice({ filePath })
282
+ *
283
+ * setTimeout(Taro.stopVoice, 5000)
284
+ * }
285
+ * })
286
+ * ```
287
+ * @example
288
+ * ```tsx
289
+ * Taro.startRecord(params).then(res => {
290
+ * const filePath = res.tempFilePath
291
+ * Taro.playVoice({ filePath })
292
+ *
293
+ * setTimeout(Taro.stopVoice, 5000)
294
+ * })
295
+ * ```
296
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.stopVoice.html
297
+ */
298
+ stopVoice(option?: stopVoice.Option): void
299
+
300
+ /** 设置 [InnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.html) 的播放选项。设置之后对当前小程序全局生效。
301
+ * @supported weapp
302
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.setInnerAudioOption.html
303
+ */
304
+ setInnerAudioOption(option: setInnerAudioOption.Option): Promise<TaroGeneral.CallbackResult>
305
+
306
+ /** 开始播放语音。同时只允许一个语音文件正在播放,如果前一个语音文件还没播放完,将中断前一个语音播放。
307
+ * @supported weapp
308
+ * @example
309
+ * ```tsx
310
+ * Taro.startRecord({
311
+ * success: function (res) {
312
+ * const tempFilePath = res.tempFilePath
313
+ * Taro.playVoice({
314
+ * filePath: tempFilePath,
315
+ * complete: function () { }
316
+ * })
317
+ * }
318
+ * })
319
+ * ```
320
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.playVoice.html
321
+ */
322
+ playVoice(option: playVoice.Option): Promise<TaroGeneral.CallbackResult>
323
+
324
+ /** 暂停正在播放的语音。再次调用 [Taro.playVoice](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.playVoice.html) 播放同一个文件时,会从暂停处开始播放。如果想从头开始播放,需要先调用 [Taro.stopVoice](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.stopVoice.html)。
325
+ * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口**
326
+ * @supported weapp
327
+ * @example
328
+ * ```tsx
329
+ * Taro.startRecord({
330
+ * success: function (res) {
331
+ * var tempFilePath = res.tempFilePath
332
+ * Taro.playVoice({
333
+ * filePath: tempFilePath
334
+ * })
335
+ * setTimeout(function() {
336
+ * //暂停播放
337
+ * Taro.pauseVoice()
338
+ * }, 5000)
339
+ * }
340
+ * })
341
+ * ```
342
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.pauseVoice.html
343
+ */
344
+ pauseVoice(option?: pauseVoice.Option): void
345
+
346
+ /** 获取当前支持的音频输入源
347
+ * @supported weapp
348
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.getAvailableAudioSources.html
349
+ */
350
+ getAvailableAudioSources(option?: getAvailableAudioSources.Option): Promise<getAvailableAudioSources.SuccessCallbackResult>
351
+
352
+ /** 创建内部 audio 上下文 InnerAudioContext 对象。
353
+ * @supported weapp, h5
354
+ * @example
355
+ * ```tsx
356
+ * const innerAudioContext = Taro.createInnerAudioContext()
357
+ * innerAudioContext.autoplay = true
358
+ * innerAudioContext.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
359
+ * innerAudioContext.onPlay(() => {
360
+ * console.log('开始播放')
361
+ * })
362
+ * innerAudioContext.onError((res) => {
363
+ * console.log(res.errMsg)
364
+ * console.log(res.errCode)
365
+ * })
366
+ * ```
367
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html
368
+ */
369
+ createInnerAudioContext(): InnerAudioContext
370
+
371
+ /** 创建 audio 上下文 AudioContext 对象。
372
+ * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html) 接口**
373
+ * @supported weapp
374
+ * @example
375
+ * ```tsx
376
+ * const audioCtx = Taro.createAudioContext('myAudio')
377
+ * ```
378
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createAudioContext.html
379
+ */
380
+ createAudioContext(
381
+ /** [audio](https://developers.weixin.qq.com/miniprogram/dev/component/audio.html) 组件的 id */
382
+ id: string,
383
+ /** 在自定义组件下,当前组件实例的this,以操作组件内 [audio](https://developers.weixin.qq.com/miniprogram/dev/component/audio.html) 组件 */
384
+ component?: TaroGeneral.IAnyObject,
385
+ ): AudioContext
386
+ }
379
387
  }
@@ -1,140 +1,68 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace stopBackgroundAudio {
3
5
  interface Option {
4
6
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
5
- complete?: (res: General.CallbackResult) => void
7
+ complete?: (res: TaroGeneral.CallbackResult) => void
6
8
  /** 接口调用失败的回调函数 */
7
- fail?: (res: General.CallbackResult) => void
9
+ fail?: (res: TaroGeneral.CallbackResult) => void
8
10
  /** 接口调用成功的回调函数 */
9
- success?: (res: General.CallbackResult) => void
11
+ success?: (res: TaroGeneral.CallbackResult) => void
10
12
  }
11
13
  }
12
- /**
13
- * 停止播放音乐。
14
- * @supported weapp
15
- * @example
16
- * ```tsx
17
- * Taro.stopBackgroundAudio()
18
- * ```
19
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.stopBackgroundAudio.html
20
- */
21
- function stopBackgroundAudio(option?: stopBackgroundAudio.Option): void
22
14
 
23
15
  namespace seekBackgroundAudio {
24
16
  interface Option {
25
17
  /** 音乐位置,单位:秒 */
26
18
  position: number
27
19
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
28
- complete?: (res: General.CallbackResult) => void
20
+ complete?: (res: TaroGeneral.CallbackResult) => void
29
21
  /** 接口调用失败的回调函数 */
30
- fail?: (res: General.CallbackResult) => void
22
+ fail?: (res: TaroGeneral.CallbackResult) => void
31
23
  /** 接口调用成功的回调函数 */
32
- success?: (res: General.CallbackResult) => void
24
+ success?: (res: TaroGeneral.CallbackResult) => void
33
25
  }
34
26
  }
35
- /** 控制音乐播放进度。
36
- * @supported weapp
37
- * @example
38
- * ```tsx
39
- * Taro.seekBackgroundAudio({
40
- * position: 30
41
- * })
42
- * ```
43
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.seekBackgroundAudio.html
44
- */
45
- function seekBackgroundAudio(option: seekBackgroundAudio.Option): Promise<General.CallbackResult>
46
27
 
47
28
  namespace playBackgroundAudio {
48
29
  interface Option {
49
30
  /** 音乐链接,目前支持的格式有 m4a, aac, mp3, wav */
50
31
  dataUrl: string
51
32
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
52
- complete?: (res: General.CallbackResult) => void
33
+ complete?: (res: TaroGeneral.CallbackResult) => void
53
34
  /** 封面URL */
54
35
  coverImgUrl?: string
55
36
  /** 接口调用失败的回调函数 */
56
- fail?: (res: General.CallbackResult) => void
37
+ fail?: (res: TaroGeneral.CallbackResult) => void
57
38
  /** 接口调用成功的回调函数 */
58
- success?: (res: General.CallbackResult) => void
39
+ success?: (res: TaroGeneral.CallbackResult) => void
59
40
  /** 音乐标题 */
60
41
  title?: string
61
42
  }
62
43
  }
63
- /** 使用后台播放器播放音乐,对于微信客户端来说,只能同时有一个后台音乐在播放。当用户离开小程序后,音乐将暂停播放;当用户点击“显示在聊天顶部”时,音乐不会暂停播放;当用户在其他小程序占用了音乐播放器,原有小程序内的音乐将停止播放。
64
- * @supported weapp
65
- * @example
66
- * ```tsx
67
- * Taro.playBackgroundAudio({
68
- * dataUrl: '',
69
- * title: '',
70
- * coverImgUrl: ''
71
- * })
72
- * ```
73
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.playBackgroundAudio.html
74
- */
75
- function playBackgroundAudio(option: playBackgroundAudio.Option): Promise<General.CallbackResult>
76
44
 
77
45
  namespace pauseBackgroundAudio {
78
46
  interface Option {
79
47
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
80
- complete?: (res: General.CallbackResult) => void
48
+ complete?: (res: TaroGeneral.CallbackResult) => void
81
49
  /** 接口调用失败的回调函数 */
82
- fail?: (res: General.CallbackResult) => void
50
+ fail?: (res: TaroGeneral.CallbackResult) => void
83
51
  /** 接口调用成功的回调函数 */
84
- success?: (res: General.CallbackResult) => void
52
+ success?: (res: TaroGeneral.CallbackResult) => void
85
53
  }
86
54
  }
87
- /** 暂停播放音乐。
88
- * @supported weapp
89
- * @example
90
- * ```tsx
91
- * Taro.pauseBackgroundAudio()
92
- * ```
93
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.pauseBackgroundAudio.html
94
- */
95
- function pauseBackgroundAudio(option?: pauseBackgroundAudio.Option): void
96
-
97
- /** 监听音乐停止。
98
- *
99
- * **bug & tip:**
100
- *
101
- * 1. `bug`: `iOS` `6.3.30` Taro.seekBackgroundAudio 会有短暂延迟
102
- * @supported weapp
103
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioStop.html
104
- */
105
- function onBackgroundAudioStop(
106
- /** 音乐停止事件的回调函数 */
107
- callback: (res: General.CallbackResult) => void,
108
- ): void
109
-
110
- /** 监听音乐播放。
111
- * @supported weapp
112
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioPlay.html
113
- */
114
- function onBackgroundAudioPlay(
115
- /** 音乐播放事件的回调函数 */
116
- callback: (res: General.CallbackResult) => void,
117
- ): void
118
-
119
- /** 监听音乐暂停。
120
- * @supported weapp
121
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioPause.html
122
- */
123
- function onBackgroundAudioPause(
124
- /** 音乐暂停事件的回调函数 */
125
- callback: (res: General.CallbackResult) => void,
126
- ): void
127
55
 
128
56
  namespace getBackgroundAudioPlayerState {
129
57
  interface Option {
130
58
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
131
- complete?: (res: General.CallbackResult) => void
59
+ complete?: (res: TaroGeneral.CallbackResult) => void
132
60
  /** 接口调用失败的回调函数 */
133
- fail?: (res: General.CallbackResult) => void
61
+ fail?: (res: TaroGeneral.CallbackResult) => void
134
62
  /** 接口调用成功的回调函数 */
135
63
  success?: (result: SuccessCallbackResult) => void
136
64
  }
137
- interface SuccessCallbackResult extends General.CallbackResult {
65
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
138
66
  /** 选定音频的播放位置(单位:s),只有在音乐播放中时返回 */
139
67
  currentPosition: number
140
68
  /** 歌曲数据链接,只有在音乐播放中时返回 */
@@ -157,42 +85,6 @@ declare namespace Taro {
157
85
  2
158
86
  }
159
87
  }
160
- /** 获取后台音乐播放状态。
161
- * **注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.getBackgroundAudioManager](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioManager.html) 接口**
162
- * @supported weapp
163
- * @example
164
- * ```tsx
165
- * Taro.getBackgroundAudioPlayerState({
166
- * success: function (res) {
167
- * var status = res.status
168
- * var dataUrl = res.dataUrl
169
- * var currentPosition = res.currentPosition
170
- * var duration = res.duration
171
- * var downloadPercent = res.downloadPercent
172
- * }
173
- * })
174
- * ```
175
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioPlayerState.html
176
- */
177
- function getBackgroundAudioPlayerState(option?: getBackgroundAudioPlayerState.Option): Promise<getBackgroundAudioPlayerState.SuccessCallbackResult>
178
-
179
- /** 获取**全局唯一**的背景音频管理器。
180
- * 小程序切入后台,如果音频处于播放状态,可以继续播放。但是后台状态不能通过调用API操纵音频的播放状态。
181
- *
182
- * 从微信客户端6.7.2版本开始,若需要在小程序切后台后继续播放音频,需要在 [app.json](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html) 中配置 `requiredBackgroundModes` 属性。开发版和体验版上可以直接生效,正式版还需通过审核。
183
- * @supported weapp
184
- * @example
185
- * ```tsx
186
- * const backgroundAudioManager = Taro.getBackgroundAudioManager()
187
- * backgroundAudioManager.title = '此时此刻'
188
- * backgroundAudioManager.epname = '此时此刻'
189
- * backgroundAudioManager.singer = '许巍'
190
- * backgroundAudioManager.coverImgUrl = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000'
191
- * backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' // 设置了 src 之后会自动播放
192
- * ```
193
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioManager.html
194
- */
195
- function getBackgroundAudioManager(): BackgroundAudioManager
196
88
 
197
89
  /** BackgroundAudioManager 实例,可通过 [Taro.getBackgroundAudioManager](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioManager.html) 获取。
198
90
  * @example
@@ -273,4 +165,121 @@ declare namespace Taro {
273
165
  /** 背景音频完成跳转操作事件 */
274
166
  onSeeked(callback?: () => void): void
275
167
  }
168
+
169
+ interface TaroStatic {
170
+ /**
171
+ * 停止播放音乐。
172
+ * @supported weapp
173
+ * @example
174
+ * ```tsx
175
+ * Taro.stopBackgroundAudio()
176
+ * ```
177
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.stopBackgroundAudio.html
178
+ */
179
+ stopBackgroundAudio(option?: stopBackgroundAudio.Option): void
180
+
181
+ /** 控制音乐播放进度。
182
+ * @supported weapp
183
+ * @example
184
+ * ```tsx
185
+ * Taro.seekBackgroundAudio({
186
+ * position: 30
187
+ * })
188
+ * ```
189
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.seekBackgroundAudio.html
190
+ */
191
+ seekBackgroundAudio(option: seekBackgroundAudio.Option): Promise<TaroGeneral.CallbackResult>
192
+
193
+ /** 使用后台播放器播放音乐,对于微信客户端来说,只能同时有一个后台音乐在播放。当用户离开小程序后,音乐将暂停播放;当用户点击“显示在聊天顶部”时,音乐不会暂停播放;当用户在其他小程序占用了音乐播放器,原有小程序内的音乐将停止播放。
194
+ * @supported weapp
195
+ * @example
196
+ * ```tsx
197
+ * Taro.playBackgroundAudio({
198
+ * dataUrl: '',
199
+ * title: '',
200
+ * coverImgUrl: ''
201
+ * })
202
+ * ```
203
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.playBackgroundAudio.html
204
+ */
205
+ playBackgroundAudio(option: playBackgroundAudio.Option): Promise<TaroGeneral.CallbackResult>
206
+
207
+ /** 暂停播放音乐。
208
+ * @supported weapp
209
+ * @example
210
+ * ```tsx
211
+ * Taro.pauseBackgroundAudio()
212
+ * ```
213
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.pauseBackgroundAudio.html
214
+ */
215
+ pauseBackgroundAudio(option?: pauseBackgroundAudio.Option): void
216
+
217
+ /** 监听音乐停止。
218
+ *
219
+ * **bug & tip:**
220
+ *
221
+ * 1. `bug`: `iOS` `6.3.30` Taro.seekBackgroundAudio 会有短暂延迟
222
+ * @supported weapp
223
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioStop.html
224
+ */
225
+ onBackgroundAudioStop(
226
+ /** 音乐停止事件的回调函数 */
227
+ callback: (res: TaroGeneral.CallbackResult) => void,
228
+ ): void
229
+
230
+ /** 监听音乐播放。
231
+ * @supported weapp
232
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioPlay.html
233
+ */
234
+ onBackgroundAudioPlay(
235
+ /** 音乐播放事件的回调函数 */
236
+ callback: (res: TaroGeneral.CallbackResult) => void,
237
+ ): void
238
+
239
+ /** 监听音乐暂停。
240
+ * @supported weapp
241
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.onBackgroundAudioPause.html
242
+ */
243
+ onBackgroundAudioPause(
244
+ /** 音乐暂停事件的回调函数 */
245
+ callback: (res: TaroGeneral.CallbackResult) => void,
246
+ ): void
247
+
248
+ /** 获取后台音乐播放状态。
249
+ * **注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.getBackgroundAudioManager](https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioManager.html) 接口**
250
+ * @supported weapp
251
+ * @example
252
+ * ```tsx
253
+ * Taro.getBackgroundAudioPlayerState({
254
+ * success: function (res) {
255
+ * var status = res.status
256
+ * var dataUrl = res.dataUrl
257
+ * var currentPosition = res.currentPosition
258
+ * var duration = res.duration
259
+ * var downloadPercent = res.downloadPercent
260
+ * }
261
+ * })
262
+ * ```
263
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioPlayerState.html
264
+ */
265
+ getBackgroundAudioPlayerState(option?: getBackgroundAudioPlayerState.Option): Promise<getBackgroundAudioPlayerState.SuccessCallbackResult>
266
+
267
+ /** 获取**全局唯一**的背景音频管理器。
268
+ * 小程序切入后台,如果音频处于播放状态,可以继续播放。但是后台状态不能通过调用API操纵音频的播放状态。
269
+ *
270
+ * 从微信客户端6.7.2版本开始,若需要在小程序切后台后继续播放音频,需要在 [app.json](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html) 中配置 `requiredBackgroundModes` 属性。开发版和体验版上可以直接生效,正式版还需通过审核。
271
+ * @supported weapp
272
+ * @example
273
+ * ```tsx
274
+ * const backgroundAudioManager = Taro.getBackgroundAudioManager()
275
+ * backgroundAudioManager.title = '此时此刻'
276
+ * backgroundAudioManager.epname = '此时此刻'
277
+ * backgroundAudioManager.singer = '许巍'
278
+ * backgroundAudioManager.coverImgUrl = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000'
279
+ * backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' // 设置了 src 之后会自动播放
280
+ * ```
281
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/wx.getBackgroundAudioManager.html
282
+ */
283
+ getBackgroundAudioManager(): BackgroundAudioManager
284
+ }
276
285
  }