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
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
count | number | 9 | No | The number of media items that can be selected, ranging from 1 to 9. |
mediaType | array | ['image'] | No | File types, ['image', 'video']; currently only supports image. |
sourceType | array | ['album'] | No | The source of images and videos, album: to choose from an album; camera: to take with a camera. |
maxDuration | number | 15 | No | Maximum video recording duration in seconds. The range is between 3s to 60s. Currently only aligned with this field, does not support video recording. |
sizeType | array | ['original'] | No | Whether to compress the selected files, ['original', 'compressed']; currently only supports original. |
camera | string | back | No | Effective only when sourceType is camera; use the front or rear camera, back: use the rear camera, front: use the front camera. |
success | function | No | Callback function for a successful API call. | |
fail | function | No | Callback function for a failed API call. | |
complete | function | No | Callback function that is called when the API call is complete (whether successful or not). |
object.success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
images | json | List of selected media items. |
Example Code
dlt.chooseMedia({
count: 1,
success(res) {
console.log(res.images);
},
});