May 18, 2021 WeChat Mini Program Development Document
Shoot a video or select a video from your phone album.
Property | Type | The default | Required | Description | The lowest version |
---|---|---|---|---|---|
sourceType | Array.<string> | ['album', 'camera'] | Whether | The source of the video selection | |
compressed | boolean | true | Whether | Whether to compress the selected video file | 1.6.0 |
maxDuration | number | 60 | Whether | The maximum shooting time, in seconds | |
camera | string | 'back' | Whether | The front or rear camera is pulled up by default. Some Android phones cannot take effect due to system ROM support | |
success | function | Whether | The interface calls a successful callback function | ||
fail | function | Whether | The interface calls the failed callback function | ||
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
The legal value of object.sourceType
Value | Description | The lowest version |
---|---|---|
album | Select a video from the album | |
camera | Use the camera to shoot video |
The legal value of object.camera
Value | Description | The lowest version |
---|---|---|
back | Pull up the rear camera by default | |
front | Pull up the front camera by default |
Property | Type | Description |
---|---|---|
tempFilePath | string | Temporary file path for selected video (local path) |
duration | number | The length of time the video was selected |
size | number | The size of the data for the selected video |
height | number | Returns the height of the selected video |
width | number | Returns the width of the selected video |
wx.chooseVideo({
sourceType: ['album','camera'],
maxDuration: 60,
camera: 'back',
success(res) {
console.log(res.tempFilePath)
}
})