title: Taro.chooseVideo(option)
sidebar_label: chooseVideo
Takes a video or selects a video from the mobile album.
Reference
Type
(option: Option) => Promise<void>
Parameters
Option
Property |
Type |
Required |
Description |
camera |
"back" | "front" |
No |
Indicates the default camera to be enabled. On some Android phones, the setting cannot take effect because it is not supported in ROM. |
compressed |
boolean |
No |
Indicates whether to compress the selected video file |
maxDuration |
number |
No |
The maximum duration of a recorded video (in sec) |
sourceType |
("album" | "camera")[] |
No |
The source of the video |
complete |
(res: any) => void |
No |
The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail |
(res: any) => void |
No |
The callback function for a failed API call |
success |
(res: Result) => void |
No |
The callback function for a successful API call |
SuccessCallbackResult
Property |
Type |
Description |
duration |
number |
Duration of the selected video |
height |
number |
Returns the height of the selected video |
size |
number |
Amount of data of the selected video |
tempFilePath |
string |
Temporary file path of the selected video |
width |
number |
Returns the width of the selected video |
errMsg |
string |
Call result |
camera
Property |
Description |
back |
Enables the rear camera by default |
front |
Enables the front camera by default |
sourceType
Property |
Description |
album |
Selects a video from the album |
camera |
Takes a video with the camera |
Sample Code
Taro.chooseVideo({
sourceType: ['album','camera'],
maxDuration: 60,
camera: 'back',
success: function (res) {
console.log(res.tempFilePath)
}
})
API Support
API |
WeChat Mini-Program |
H5 |
React Native |
Taro.chooseVideo |
✔️ |
|
✔️ |