|
@@ -3,6 +3,7 @@ import { camera, cameraPicker } from '@kit.CameraKit';
|
|
|
import { common } from '@kit.AbilityKit';
|
|
|
import { BusinessError } from '@kit.BasicServicesKit';
|
|
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
|
+import { photoAccessHelper } from '@kit.MediaLibraryKit';
|
|
|
|
|
|
|
|
|
const DOCUMENT_DEFAULT_SELECT_NUMBER: number = 9; //数量
|
|
@@ -50,19 +51,20 @@ export class PickerHelper {
|
|
|
* @param options
|
|
|
* @returns
|
|
|
*/
|
|
|
- static async selectPhoto(options?: picker.PhotoSelectOptions): Promise<Array<string>> {
|
|
|
+ static async selectPhoto(options?: photoAccessHelper.PhotoSelectOptions): Promise<Array<string>> {
|
|
|
try {
|
|
|
if (!options) {
|
|
|
- options = new picker.PhotoSelectOptions();
|
|
|
+ options = new photoAccessHelper.PhotoSelectOptions();
|
|
|
}
|
|
|
if (!options.MIMEType) { //可选择的媒体文件类型,若无此参数,则默认为图片和视频类型。
|
|
|
- options.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
|
|
|
+ options.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
|
|
|
}
|
|
|
if (!options.maxSelectNumber) { //选择媒体文件数量的最大值,默认9
|
|
|
options.maxSelectNumber = DOCUMENT_DEFAULT_SELECT_NUMBER;
|
|
|
}
|
|
|
- let photoPicker = new picker.PhotoViewPicker();
|
|
|
- let photoSelectResult: picker.PhotoSelectResult = await photoPicker.select(options);
|
|
|
+ let photoPicker = new photoAccessHelper.PhotoViewPicker();
|
|
|
+
|
|
|
+ let photoSelectResult: photoAccessHelper.PhotoSelectResult = await photoPicker.select(options);
|
|
|
if (photoSelectResult && photoSelectResult.photoUris && photoSelectResult.photoUris.length > 0) {
|
|
|
return photoSelectResult.photoUris;
|
|
|
} else {
|