chooseMedia(params: Object)
Requires:
BaseKit≥2.5.0@ray-js/ray≥0.5.9
Platforms:
iOSAndroid
Description
Capture or select images or videos from the album
Permissions: [scope.camera, scope.writePhotosAlbum]
Parameters
| Property | Type | Required | Default | Description | BaseKit Since |
|---|---|---|---|---|---|
count | number | No | 9 | Maximum number of files to select. Note: On Android 13 and above, the system image picker is used and this field has no effect | - |
mediaType | string | No | "image" | Selection type, default is image 'image' can only capture or select images 'video' can only capture or select videos | - |
sourceType | string[] | No | ["album", "camera"] | Sources for selecting images/videos, default ['album', 'camera'] 'album' select from album 'camera' capture using the camera | - |
maxDuration | number | No | 10 | Maximum recording duration for captured video in seconds, default 10s Range: 3s to 60s. No limit for videos from the album | - |
isFetchVideoFile | boolean | No | true | iOS only Whether to copy the video: Default true: copy the video and return the copied video path and cover path false: do not copy; return the album video path and cover image path | v3.14.2 |
isClipVideo | boolean | No | false | iOS only Whether to trim videos selected from the album Default false: do not trim | v3.14.2 |
maxClipDuration | number | No | 60 | Maximum trim length in seconds, default 60s Takes effect only when isClipVideo is true Range: 60s to 600s. Videos shorter than 15s are not trimmed | v3.14.2 |
isGetAlbumFileName | boolean | No | false | iOS only Whether to use the exported filename identical to the album filename Default false: use a unique filename each time | v3.14.2 |
isClipVideoAndroid | boolean | No | true | This parameter is only effective on Android. 芯图定制. To be merged into isClipVideo later Whether the video selected from the album needs cropping Default is true: crop the video, consistent with the original behavior | v3.32.13 |
complete | () => void | No | - | Completion callback (executed on both success and failure) | - |
success | (params: Object) => void | No | - | Callback on successful API call | - |
fail | (params: Object) => void | No | - | Failure callback | - |
success callback parameters
| Property | Type | Description | BaseKit Since |
|---|---|---|---|
type | string | File type 'image' image 'video' video | v3.2.6 |
| List of local temporary files | v3.2.6 |
fail callback parameters
| Property | Type | Description |
|---|---|---|
errorMsg | string | Error message |
errorCode | string | number | Error code |
| Error extension |
Return Value
None