跳到主要内容

bn.chooseMedia

chooseMedia(options): Promise<ChooseMediaResponse>

description Select images or videos from the local album or takes a photo or video with the camera.

remark supported jssdk >= 4.8.0

example

const res = await bn.ChooseMedia({
count: 9,
mediaType: ['image'],
sizeType: ['original'],
sourceType: ['album', 'camera'],
})
console.log(res.tempFiles)

Parameters

NameType
optionsChooseMediaOptions

Returns

Promise<ChooseMediaResponse>

Interface: ChooseMediaOptions

NameTypeDescription
count?numberThe maximum number of images. For Android < 13, count cannot limit file numbers, count > 1 means multiple. Because of the native limits, users may select more files than expected, but the API will return only count files
sizeType("original" | "compressed")[]Required. Use compressed file or original file, can choose only 1 of them for now. Compressed option not work for videos.; valid options:- 'original';; - 'compressed'
mediaType("video" | "image" | "mix")[]Required. The selectable file type, can choose only 1 of them for now; valid options:- 'image'; - 'video'; - 'mix'
sourceType?("album" | "camera")[]The source of the image, default value is ['album', 'camera']; valid options:- 'album'; - 'camera'
camera?"back" | "front"Use back or front camera

Interface: ChooseMediaResponse

NameTypeDescription
tempFilesMediaTempFile[]The list of local temporary files