Skip to main content
Version: 3.x

Taro.chooseVideo(option)

Takes a video or selects a video from the mobile album.

Reference

Type

(option: Option) => Promise<void>

Parameters

Option

PropertyTypeRequiredDescription
camera"back" | "front"NoIndicates the default camera to be enabled. On some Android phones, the setting cannot take effect because it is not supported in ROM.
compressedbooleanNoIndicates whether to compress the selected video file
maxDurationnumberNoThe maximum duration of a recorded video (in sec)
sourceType("album" | "camera")[]NoThe source of the video
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

SuccessCallbackResult

PropertyTypeDescription
durationnumberDuration of the selected video
heightnumberReturns the height of the selected video
sizenumberAmount of data of the selected video
tempFilePathstringTemporary file path of the selected video
widthnumberReturns the width of the selected video
errMsgstringCall result

camera

PropertyDescription
backEnables the rear camera by default
frontEnables the front camera by default

sourceType

PropertyDescription
albumSelects a video from the album
cameraTakes 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

APIWeChat Mini-ProgramH5React Native
Taro.chooseVideo✔️✔️