@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.
- package/package.json +5 -5
- package/types/api/ad/index.d.ts +34 -28
- package/types/api/alipay/index.d.ts +11 -7
- package/types/api/base/debug.d.ts +60 -54
- package/types/api/base/env.d.ts +12 -8
- package/types/api/base/index.d.ts +87 -83
- package/types/api/base/system.d.ts +59 -54
- package/types/api/base/update.d.ts +37 -33
- package/types/api/base/weapp/app-event.d.ts +147 -131
- package/types/api/base/weapp/life-cycle.d.ts +14 -10
- package/types/api/canvas/index.d.ts +115 -110
- package/types/api/cloud/index.d.ts +99 -94
- package/types/api/data-analysis/index.d.ts +68 -64
- package/types/api/device/accelerometer.d.ts +57 -50
- package/types/api/device/battery.d.ts +19 -15
- package/types/api/device/ble.d.ts +241 -228
- package/types/api/device/bluetooth.d.ts +207 -194
- package/types/api/device/clipboard.d.ts +48 -43
- package/types/api/device/compass.d.ts +55 -48
- package/types/api/device/contact.d.ts +13 -9
- package/types/api/device/gyroscope.d.ts +41 -35
- package/types/api/device/iBeacon.d.ts +79 -73
- package/types/api/device/motion.d.ts +42 -37
- package/types/api/device/network.d.ts +48 -42
- package/types/api/device/nfc.d.ts +105 -96
- package/types/api/device/performance.d.ts +22 -18
- package/types/api/device/phone.d.ts +20 -15
- package/types/api/device/scan.d.ts +31 -26
- package/types/api/device/screen.d.ts +74 -67
- package/types/api/device/vibrate.d.ts +31 -25
- package/types/api/device/wifi.d.ts +151 -140
- package/types/api/ext/index.d.ts +44 -39
- package/types/api/files/index.d.ts +219 -209
- package/types/api/framework/index.d.ts +25 -20
- package/types/api/location/index.d.ts +140 -136
- package/types/api/media/audio.d.ts +135 -127
- package/types/api/media/background-audio.d.ts +135 -126
- package/types/api/media/camera.d.ts +30 -26
- package/types/api/media/editor.d.ts +35 -33
- package/types/api/media/image.d.ts +161 -150
- package/types/api/media/live.d.ts +88 -82
- package/types/api/media/map.d.ts +47 -43
- package/types/api/media/recorder.d.ts +90 -84
- package/types/api/media/video-processing.d.ts +10 -6
- package/types/api/media/video.d.ts +63 -58
- package/types/api/network/download.d.ts +34 -30
- package/types/api/network/mdns.d.ts +104 -91
- package/types/api/network/request.d.ts +83 -79
- package/types/api/network/udp.d.ts +20 -16
- package/types/api/network/upload.d.ts +60 -56
- package/types/api/network/websocket.d.ts +201 -194
- package/types/api/open-api/account.d.ts +18 -14
- package/types/api/open-api/address.d.ts +27 -23
- package/types/api/open-api/authorize.d.ts +30 -26
- package/types/api/open-api/card.d.ts +55 -51
- package/types/api/open-api/customer-service.d.ts +21 -17
- package/types/api/open-api/facial.d.ts +28 -24
- package/types/api/open-api/invoice.d.ts +38 -34
- package/types/api/open-api/login.d.ts +56 -52
- package/types/api/open-api/navigate.d.ts +79 -75
- package/types/api/open-api/payment.d.ts +34 -30
- package/types/api/open-api/settings.d.ts +49 -45
- package/types/api/open-api/soter.d.ts +92 -86
- package/types/api/open-api/subscribe-message.d.ts +24 -20
- package/types/api/open-api/user-info.d.ts +60 -57
- package/types/api/open-api/werun.d.ts +50 -46
- package/types/api/route/index.d.ts +122 -118
- package/types/api/share/index.d.ts +68 -64
- package/types/api/storage/background-fetch.d.ts +40 -35
- package/types/api/storage/index.d.ts +267 -262
- package/types/api/swan/index.d.ts +47 -42
- package/types/api/ui/animation.d.ts +21 -17
- package/types/api/ui/background.d.ts +38 -34
- package/types/api/ui/custom-component.d.ts +22 -18
- package/types/api/ui/fonts.d.ts +26 -21
- package/types/api/ui/interaction.d.ts +153 -149
- package/types/api/ui/keyboard.d.ts +59 -55
- package/types/api/ui/menu.d.ts +10 -6
- package/types/api/ui/navigation-bar.d.ts +67 -63
- package/types/api/ui/pull-down-refresh.d.ts +33 -29
- package/types/api/ui/scroll.d.ts +30 -26
- package/types/api/ui/sticky.d.ts +22 -19
- package/types/api/ui/tab-bar.d.ts +101 -97
- package/types/api/ui/window.d.ts +24 -18
- package/types/api/worker/index.d.ts +28 -24
- package/types/api/wxml/index.d.ts +42 -38
- package/types/global.d.ts +350 -0
- package/types/index.d.ts +12 -98
- package/types/taro.api.d.ts +94 -0
- package/types/taro.component.d.ts +10 -57
- package/types/taro.config.d.ts +24 -6
- package/types/taro.extend.d.ts +70 -67
- package/types/taro.hooks.d.ts +68 -67
- package/types/taro.lifecycle.d.ts +47 -28
- package/types/api/ad/index.ts +0 -6
- package/types/api/alipay/index.ts +0 -7
- package/types/api/index.d.ts +0 -352
|
@@ -1,109 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace stopRecord {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
5
|
-
complete?: (res:
|
|
7
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
6
8
|
/** 接口调用失败的回调函数 */
|
|
7
|
-
fail?: (res:
|
|
9
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
8
10
|
/** 接口调用成功的回调函数 */
|
|
9
|
-
success?: (res:
|
|
11
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
|
-
/** 停止录音。
|
|
13
|
-
* @supported weapp
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* Taro.startRecord({
|
|
17
|
-
* success: function (res) {
|
|
18
|
-
* var tempFilePath = res.tempFilePath
|
|
19
|
-
* },
|
|
20
|
-
* fail: function (res) {
|
|
21
|
-
* //录音失败
|
|
22
|
-
* }
|
|
23
|
-
* })
|
|
24
|
-
* setTimeout(function() {
|
|
25
|
-
* //结束录音
|
|
26
|
-
* Taro.stopRecord()
|
|
27
|
-
* }, 10000)
|
|
28
|
-
* ```
|
|
29
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.stopRecord.html
|
|
30
|
-
*/
|
|
31
|
-
function stopRecord(option?: stopRecord.Option): void
|
|
32
14
|
|
|
33
15
|
namespace startRecord {
|
|
34
16
|
interface Option {
|
|
35
17
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
36
|
-
complete?: (res:
|
|
18
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
37
19
|
/** 接口调用失败的回调函数 */
|
|
38
|
-
fail?: (res:
|
|
20
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
39
21
|
/** 接口调用成功的回调函数 */
|
|
40
22
|
success?: (result: SuccessCallbackResult) => void
|
|
41
23
|
}
|
|
42
|
-
interface SuccessCallbackResult extends
|
|
24
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
43
25
|
/** 录音文件的临时路径 */
|
|
44
26
|
tempFilePath: string
|
|
45
27
|
/** 调用结果 */
|
|
46
28
|
errMsg: string
|
|
47
29
|
}
|
|
48
30
|
}
|
|
49
|
-
/** 开始录音。当主动调用`Taro.stopRecord`,或者录音超过1分钟时自动结束录音,返回录音文件的临时文件路径。当用户离开小程序时,此接口无法调用。
|
|
50
|
-
* **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.getRecorderManager](https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.getRecorderManager.html) 接口**
|
|
51
|
-
* 需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.record
|
|
52
|
-
* @supported weapp
|
|
53
|
-
* @example
|
|
54
|
-
* ```tsx
|
|
55
|
-
* Taro.startRecord({
|
|
56
|
-
* success: function (res) {
|
|
57
|
-
* const tempFilePath = res.tempFilePath
|
|
58
|
-
* }
|
|
59
|
-
* })
|
|
60
|
-
* setTimeout(function () {
|
|
61
|
-
* Taro.stopRecord() // 结束录音
|
|
62
|
-
* }, 10000)
|
|
63
|
-
* ```
|
|
64
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.startRecord.html
|
|
65
|
-
*/
|
|
66
|
-
function startRecord(option: startRecord.Option): Promise<startRecord.SuccessCallbackResult>
|
|
67
|
-
|
|
68
|
-
/** 获取**全局唯一**的录音管理器 RecorderManager
|
|
69
|
-
* @supported weapp
|
|
70
|
-
* @example
|
|
71
|
-
* ```tsx
|
|
72
|
-
* const recorderManager = Taro.getRecorderManager()
|
|
73
|
-
* recorderManager.onStart(() => {
|
|
74
|
-
* console.log('recorder start')
|
|
75
|
-
* })
|
|
76
|
-
* recorderManager.onPause(() => {
|
|
77
|
-
* console.log('recorder pause')
|
|
78
|
-
* })
|
|
79
|
-
* recorderManager.onStop((res) => {
|
|
80
|
-
* console.log('recorder stop', res)
|
|
81
|
-
* const { tempFilePath } = res
|
|
82
|
-
* })
|
|
83
|
-
* recorderManager.onFrameRecorded((res) => {
|
|
84
|
-
* const { frameBuffer } = res
|
|
85
|
-
* console.log('frameBuffer.byteLength', frameBuffer.byteLength)
|
|
86
|
-
* })
|
|
87
|
-
* const options = {
|
|
88
|
-
* duration: 10000,
|
|
89
|
-
* sampleRate: 44100,
|
|
90
|
-
* numberOfChannels: 1,
|
|
91
|
-
* encodeBitRate: 192000,
|
|
92
|
-
* format: 'aac',
|
|
93
|
-
* frameSize: 50
|
|
94
|
-
* }
|
|
95
|
-
* recorderManager.start(options)
|
|
96
|
-
* ```
|
|
97
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.getRecorderManager.html
|
|
98
|
-
*/
|
|
99
|
-
function getRecorderManager(): RecorderManager
|
|
100
31
|
|
|
101
32
|
namespace RecorderManager {
|
|
102
33
|
/** 录音错误事件的回调函数 */
|
|
103
34
|
type OnErrorCallback = (
|
|
104
35
|
result: OnErrorCallbackResult,
|
|
105
36
|
) => void
|
|
106
|
-
interface OnErrorCallbackResult extends
|
|
37
|
+
interface OnErrorCallbackResult extends TaroGeneral.CallbackResult {
|
|
107
38
|
/** 错误信息 */
|
|
108
39
|
errMsg: string
|
|
109
40
|
}
|
|
@@ -245,7 +176,7 @@ declare namespace Taro {
|
|
|
245
176
|
*/
|
|
246
177
|
onInterruptionBegin(
|
|
247
178
|
/** 录音因为受到系统占用而被中断开始事件的回调函数 */
|
|
248
|
-
callback: (res:
|
|
179
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
249
180
|
): void
|
|
250
181
|
/** 监听录音中断结束事件。在收到 interruptionBegin 事件之后,小程序内所有录音会暂停,收到此事件之后才可再次录音成功。
|
|
251
182
|
* @supported weapp
|
|
@@ -253,7 +184,7 @@ declare namespace Taro {
|
|
|
253
184
|
*/
|
|
254
185
|
onInterruptionEnd(
|
|
255
186
|
/** 录音中断结束事件的回调函数 */
|
|
256
|
-
callback: (res:
|
|
187
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
257
188
|
): void
|
|
258
189
|
/** 监听录音暂停事件
|
|
259
190
|
* @supported weapp
|
|
@@ -261,7 +192,7 @@ declare namespace Taro {
|
|
|
261
192
|
*/
|
|
262
193
|
onPause(
|
|
263
194
|
/** 录音暂停事件的回调函数 */
|
|
264
|
-
callback: (res:
|
|
195
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
265
196
|
): void
|
|
266
197
|
/** 监听录音继续事件
|
|
267
198
|
* @supported weapp
|
|
@@ -269,7 +200,7 @@ declare namespace Taro {
|
|
|
269
200
|
*/
|
|
270
201
|
onResume(
|
|
271
202
|
/** 录音继续事件的回调函数 */
|
|
272
|
-
callback: (res:
|
|
203
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
273
204
|
): void
|
|
274
205
|
/** 监听录音开始事件
|
|
275
206
|
* @supported weapp
|
|
@@ -277,7 +208,7 @@ declare namespace Taro {
|
|
|
277
208
|
*/
|
|
278
209
|
onStart(
|
|
279
210
|
/** 录音开始事件的回调函数 */
|
|
280
|
-
callback: (res:
|
|
211
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
281
212
|
): void
|
|
282
213
|
/** 监听录音结束事件
|
|
283
214
|
* @supported weapp
|
|
@@ -308,4 +239,79 @@ declare namespace Taro {
|
|
|
308
239
|
*/
|
|
309
240
|
stop(): void
|
|
310
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](https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/wx.getRecorderManager.html) 接口**
|
|
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
|
|
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
|
+
}
|
|
311
317
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
/** 创建音视频处理容器,最终可将容器中的轨道合成一个视频
|
|
3
|
-
* @supported weapp
|
|
4
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/wx.createMediaContainer.html
|
|
5
|
-
*/
|
|
6
|
-
function createMediaContainer(): MediaContainer
|
|
1
|
+
import Taro from '../../index'
|
|
7
2
|
|
|
3
|
+
declare module '../../index' {
|
|
8
4
|
/** 创建音视频处理容器,最终可将容器中的轨道合成一个视频
|
|
9
5
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/MediaContainer.html
|
|
10
6
|
*/
|
|
@@ -73,4 +69,12 @@ declare namespace Taro {
|
|
|
73
69
|
video
|
|
74
70
|
}
|
|
75
71
|
}
|
|
72
|
+
|
|
73
|
+
interface TaroStatic {
|
|
74
|
+
/** 创建音视频处理容器,最终可将容器中的轨道合成一个视频
|
|
75
|
+
* @supported weapp
|
|
76
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video-processing/wx.createMediaContainer.html
|
|
77
|
+
*/
|
|
78
|
+
createMediaContainer(): MediaContainer
|
|
79
|
+
}
|
|
76
80
|
}
|
|
@@ -1,78 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace saveVideoToPhotosAlbum {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 视频文件路径,可以是临时文件路径也可以是永久文件路径 */
|
|
5
7
|
filePath: string
|
|
6
8
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
7
|
-
complete?: (res:
|
|
9
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
8
10
|
/** 接口调用失败的回调函数 */
|
|
9
|
-
fail?: (res:
|
|
11
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
10
12
|
/** 接口调用成功的回调函数 */
|
|
11
|
-
success?: (res:
|
|
13
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
|
-
/**
|
|
15
|
-
* 保存视频到系统相册。支持mp4视频格式。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum
|
|
16
|
-
*
|
|
17
|
-
* **Bug & Tip:**
|
|
18
|
-
*
|
|
19
|
-
* 1. `tip`: camera 参数在部分 Android 手机下由于系统 ROM 不支持无法生效
|
|
20
|
-
* @supported weapp, rn
|
|
21
|
-
* @example
|
|
22
|
-
```tsx
|
|
23
|
-
* Taro.saveVideoToPhotosAlbum({
|
|
24
|
-
* filePath: 'wxfile://xxx'
|
|
25
|
-
* success: function (res) {
|
|
26
|
-
* console.log(res.errMsg)
|
|
27
|
-
* }
|
|
28
|
-
* })
|
|
29
|
-
* ```
|
|
30
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.saveVideoToPhotosAlbum.html
|
|
31
|
-
*/
|
|
32
|
-
function saveVideoToPhotosAlbum(option: saveVideoToPhotosAlbum.Option): Promise<General.CallbackResult>
|
|
33
|
-
|
|
34
|
-
/** 创建 video 上下文 VideoContext 对象。
|
|
35
|
-
* @supported weapp, h5
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* videoContext = Taro.createVideoContext('myVideo')
|
|
39
|
-
* ```
|
|
40
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.createVideoContext.html
|
|
41
|
-
*/
|
|
42
|
-
function createVideoContext(
|
|
43
|
-
/** video 组件的 id */
|
|
44
|
-
id: string,
|
|
45
|
-
/** 在自定义组件下,当前组件实例的this,以操作组件内 video 组件 */
|
|
46
|
-
component?: General.IAnyObject,
|
|
47
|
-
): VideoContext
|
|
48
|
-
|
|
49
|
-
/** 拍摄视频或从手机相册中选视频。
|
|
50
|
-
* @supported weapp, rn
|
|
51
|
-
* @example
|
|
52
|
-
* ```tsx
|
|
53
|
-
* Taro.chooseVideo({
|
|
54
|
-
* sourceType: ['album','camera'],
|
|
55
|
-
* maxDuration: 60,
|
|
56
|
-
* camera: 'back',
|
|
57
|
-
* success: function (res) {
|
|
58
|
-
* console.log(res.tempFilePath)
|
|
59
|
-
* }
|
|
60
|
-
* })
|
|
61
|
-
* ```
|
|
62
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseVideo.html
|
|
63
|
-
*/
|
|
64
|
-
function chooseVideo(option: chooseVideo.Option): Promise<void>
|
|
65
16
|
|
|
66
17
|
namespace chooseVideo {
|
|
67
18
|
interface Option {
|
|
68
19
|
/** 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效 */
|
|
69
20
|
camera?: keyof camera
|
|
70
21
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
71
|
-
complete?: (res:
|
|
22
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
72
23
|
/** 是否压缩所选择的视频文件 */
|
|
73
24
|
compressed?: boolean
|
|
74
25
|
/** 接口调用失败的回调函数 */
|
|
75
|
-
fail?: (res:
|
|
26
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
76
27
|
/** 拍摄视频最长拍摄时间,单位秒 */
|
|
77
28
|
maxDuration?: number
|
|
78
29
|
/** 视频选择的来源 */
|
|
@@ -80,7 +31,7 @@ declare namespace Taro {
|
|
|
80
31
|
/** 接口调用成功的回调函数 */
|
|
81
32
|
success?: (result: SuccessCallbackResult) => void
|
|
82
33
|
}
|
|
83
|
-
interface SuccessCallbackResult extends
|
|
34
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
84
35
|
/** 选定视频的时间长度 */
|
|
85
36
|
duration: number
|
|
86
37
|
/** 返回选定视频的高度 */
|
|
@@ -188,4 +139,58 @@ declare namespace Taro {
|
|
|
188
139
|
color?: string
|
|
189
140
|
}
|
|
190
141
|
}
|
|
142
|
+
|
|
143
|
+
interface TaroStatic {
|
|
144
|
+
/**
|
|
145
|
+
* 保存视频到系统相册。支持mp4视频格式。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum
|
|
146
|
+
*
|
|
147
|
+
* **Bug & Tip:**
|
|
148
|
+
*
|
|
149
|
+
* 1. `tip`: camera 参数在部分 Android 手机下由于系统 ROM 不支持无法生效
|
|
150
|
+
* @supported weapp, rn
|
|
151
|
+
* @example
|
|
152
|
+
```tsx
|
|
153
|
+
* Taro.saveVideoToPhotosAlbum({
|
|
154
|
+
* filePath: 'wxfile://xxx'
|
|
155
|
+
* success: function (res) {
|
|
156
|
+
* console.log(res.errMsg)
|
|
157
|
+
* }
|
|
158
|
+
* })
|
|
159
|
+
* ```
|
|
160
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.saveVideoToPhotosAlbum.html
|
|
161
|
+
*/
|
|
162
|
+
saveVideoToPhotosAlbum(option: saveVideoToPhotosAlbum.Option): Promise<TaroGeneral.CallbackResult>
|
|
163
|
+
|
|
164
|
+
/** 创建 video 上下文 VideoContext 对象。
|
|
165
|
+
* @supported weapp, h5
|
|
166
|
+
* @example
|
|
167
|
+
* ```tsx
|
|
168
|
+
* videoContext = Taro.createVideoContext('myVideo')
|
|
169
|
+
* ```
|
|
170
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.createVideoContext.html
|
|
171
|
+
*/
|
|
172
|
+
createVideoContext(
|
|
173
|
+
/** video 组件的 id */
|
|
174
|
+
id: string,
|
|
175
|
+
/** 在自定义组件下,当前组件实例的this,以操作组件内 video 组件 */
|
|
176
|
+
component?: TaroGeneral.IAnyObject,
|
|
177
|
+
): VideoContext
|
|
178
|
+
|
|
179
|
+
/** 拍摄视频或从手机相册中选视频。
|
|
180
|
+
* @supported weapp, rn
|
|
181
|
+
* @example
|
|
182
|
+
* ```tsx
|
|
183
|
+
* Taro.chooseVideo({
|
|
184
|
+
* sourceType: ['album','camera'],
|
|
185
|
+
* maxDuration: 60,
|
|
186
|
+
* camera: 'back',
|
|
187
|
+
* success: function (res) {
|
|
188
|
+
* console.log(res.tempFilePath)
|
|
189
|
+
* }
|
|
190
|
+
* })
|
|
191
|
+
* ```
|
|
192
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseVideo.html
|
|
193
|
+
*/
|
|
194
|
+
chooseVideo(option: chooseVideo.Option): Promise<void>
|
|
195
|
+
}
|
|
191
196
|
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace downloadFile {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 下载资源的 url */
|
|
5
7
|
url: string
|
|
6
8
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
7
|
-
complete?: (res:
|
|
9
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
8
10
|
/** 接口调用失败的回调函数 */
|
|
9
|
-
fail?: (res:
|
|
11
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
10
12
|
/** 指定文件下载后存储的路径 */
|
|
11
13
|
filePath?: string
|
|
12
14
|
/** HTTP 请求的 Header,Header 中不能设置 Referer */
|
|
13
|
-
header?:
|
|
15
|
+
header?: TaroGeneral.IAnyObject
|
|
14
16
|
/** 接口调用成功的回调函数 */
|
|
15
17
|
success?: (result: FileSuccessCallbackResult) => void
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
interface FileSuccessCallbackResult extends
|
|
20
|
+
interface FileSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
19
21
|
/** 用户文件路径。传入 filePath 时会返回,跟传入的 filePath 一致 */
|
|
20
22
|
filePath: string
|
|
21
23
|
/** 开发者服务器返回的 HTTP 状态码 */
|
|
@@ -27,36 +29,14 @@ declare namespace Taro {
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
/** 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径,单次下载允许的最大文件为 50MB。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
|
|
31
|
-
*
|
|
32
|
-
* 注意:请在服务端响应的 header 中指定合理的 `Content-Type` 字段,以保证客户端正确处理文件类型。
|
|
33
|
-
* @supported weapp, h5, alipay, swan
|
|
34
|
-
* @example
|
|
35
|
-
* ```tsx
|
|
36
|
-
* Taro.downloadFile({
|
|
37
|
-
* url: 'https://example.com/audio/123', //仅为示例,并非真实的资源
|
|
38
|
-
* success: function (res) {
|
|
39
|
-
* // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
|
|
40
|
-
* if (res.statusCode === 200) {
|
|
41
|
-
* Taro.playVoice({
|
|
42
|
-
* filePath: res.tempFilePath
|
|
43
|
-
* })
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
* })
|
|
47
|
-
* ```
|
|
48
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/wx.downloadFile.html
|
|
49
|
-
*/
|
|
50
|
-
function downloadFile(option: downloadFile.Option): DownloadTask
|
|
51
|
-
|
|
52
32
|
namespace DownloadTask {
|
|
53
33
|
/** HTTP Response Header 事件的回调函数 */
|
|
54
34
|
type OffHeadersReceivedCallback = (
|
|
55
|
-
res:
|
|
35
|
+
res: TaroGeneral.CallbackResult,
|
|
56
36
|
) => void
|
|
57
37
|
/** 下载进度变化事件的回调函数 */
|
|
58
38
|
type OffProgressUpdateCallback = (
|
|
59
|
-
res:
|
|
39
|
+
res: TaroGeneral.CallbackResult,
|
|
60
40
|
) => void
|
|
61
41
|
/** HTTP Response Header 事件的回调函数 */
|
|
62
42
|
type OnHeadersReceivedCallback = (
|
|
@@ -68,7 +48,7 @@ declare namespace Taro {
|
|
|
68
48
|
) => void
|
|
69
49
|
interface OnHeadersReceivedCallbackResult {
|
|
70
50
|
/** 开发者服务器返回的 HTTP Response Header */
|
|
71
|
-
header:
|
|
51
|
+
header: TaroGeneral.IAnyObject
|
|
72
52
|
}
|
|
73
53
|
interface OnProgressUpdateCallbackResult {
|
|
74
54
|
/** 下载进度百分比 */
|
|
@@ -119,4 +99,28 @@ declare namespace Taro {
|
|
|
119
99
|
callback: DownloadTask.OnProgressUpdateCallback,
|
|
120
100
|
): void
|
|
121
101
|
}
|
|
102
|
+
|
|
103
|
+
interface TaroStatic {
|
|
104
|
+
/** 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径,单次下载允许的最大文件为 50MB。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
|
|
105
|
+
*
|
|
106
|
+
* 注意:请在服务端响应的 header 中指定合理的 `Content-Type` 字段,以保证客户端正确处理文件类型。
|
|
107
|
+
* @supported weapp, h5, alipay, swan
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* Taro.downloadFile({
|
|
111
|
+
* url: 'https://example.com/audio/123', //仅为示例,并非真实的资源
|
|
112
|
+
* success: function (res) {
|
|
113
|
+
* // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
|
|
114
|
+
* if (res.statusCode === 200) {
|
|
115
|
+
* Taro.playVoice({
|
|
116
|
+
* filePath: res.tempFilePath
|
|
117
|
+
* })
|
|
118
|
+
* }
|
|
119
|
+
* }
|
|
120
|
+
* })
|
|
121
|
+
* ```
|
|
122
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/wx.downloadFile.html
|
|
123
|
+
*/
|
|
124
|
+
downloadFile(option: downloadFile.Option): DownloadTask
|
|
125
|
+
}
|
|
122
126
|
}
|