HomeDocs
Skip to main content

dlt.chooseMedia

Introduction

The dlt.chooseMedia function is used to select media (photos or videos) from the device's gallery.

Note: This API may raise privacy concerns, so use it with caution.

Parameters

Object object

PropertyTypeDefault ValueRequiredDescription
countnumber9NoThe number of media items that can be selected, ranging from 1 to 9.
mediaTypearray['image']NoFile types, ['image', 'video']; currently only supports image.
sourceTypearray['album']NoThe source of images and videos, album: to choose from an album; camera: to take with a camera.
maxDurationnumber15NoMaximum video recording duration in seconds. The range is between 3s to 60s. Currently only aligned with this field, does not support video recording.
sizeTypearray['original']NoWhether to compress the selected files, ['original', 'compressed']; currently only supports original.
camerastringbackNoEffective only when sourceType is camera; use the front or rear camera, back: use the rear camera, front: use the front camera.
successfunctionNoCallback function for a successful API call.
failfunctionNoCallback function for a failed API call.
completefunctionNoCallback function that is called when the API call is complete (whether successful or not).

object.success Callback Function

Parameters

Object res

PropertyTypeDescription
imagesjsonList of selected media items.

Example Code

dlt.chooseMedia({
count: 1,
success(res) {
console.log(res.images);
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.