2023-12-22 07:54:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2024-01-27 01:27:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @kit CameraKit
|
|
|
|
*/
|
|
|
|
|
2023-12-22 07:54:15 +00:00
|
|
|
import type Context from './application/Context';
|
|
|
|
import type camera from './@ohos.multimedia.camera';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @namespace cameraPicker
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* @namespace cameraPicker
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
declare namespace cameraPicker {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Picker profile settings for take photo and record video.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* Picker profile settings for take photo and record video.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
class PickerProfile {
|
|
|
|
/**
|
|
|
|
* The camera position to be used.
|
|
|
|
*
|
|
|
|
* @type { camera.CameraPosition }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* The camera position to be used.
|
|
|
|
*
|
|
|
|
* @type { camera.CameraPosition }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
cameraPosition: camera.CameraPosition;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The uri of the result to be saved.
|
|
|
|
*
|
|
|
|
* @type { ?string }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* The uri of the result to be saved.
|
|
|
|
*
|
|
|
|
* @type { ?string }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
saveUri?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The max duration of the video.
|
|
|
|
*
|
|
|
|
* @type { ?number }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* The max duration of the video.
|
|
|
|
*
|
|
|
|
* @type { ?number }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
videoDuration?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enum for camera picker media type.
|
|
|
|
*
|
|
|
|
* @enum { string }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* Enum for camera picker media type.
|
|
|
|
*
|
|
|
|
* @enum { string }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
enum PickerMediaType {
|
|
|
|
/**
|
|
|
|
* Type image, picker provide an ability to take photo.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* Type image, picker provide an ability to take photo.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
PHOTO = 'photo',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Type video, picker provide an ability to record video.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* Type video, picker provide an ability to record video.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
VIDEO = 'video'
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The picker result info for pick function.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* The picker result info for pick function.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
class PickerResult {
|
|
|
|
/**
|
|
|
|
* The result code.
|
|
|
|
*
|
|
|
|
* @type { number }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* The result code.
|
|
|
|
*
|
|
|
|
* @type { number }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
resultCode: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The result saved uri.
|
|
|
|
*
|
|
|
|
* @type { string }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* The result saved uri.
|
|
|
|
*
|
|
|
|
* @type { string }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
resultUri: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The result resource type.
|
|
|
|
*
|
|
|
|
* @type { PickerMediaType }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* The result resource type.
|
|
|
|
*
|
|
|
|
* @type { PickerMediaType }
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
mediaType: PickerMediaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pick function to get a photo or video result.
|
|
|
|
*
|
|
|
|
* @param { Context } context - From UIExtensionAbility.
|
|
|
|
* @param { Array<PickerMediaType> } mediaTypes - Pick media type.
|
|
|
|
* @param { PickerProfile } pickerProfile - Picker input Profile.
|
|
|
|
* @returns { Promise<PickerResult> } pick result.
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @since 11
|
|
|
|
*/
|
2024-04-03 01:30:14 +00:00
|
|
|
/**
|
|
|
|
* Pick function to get a photo or video result.
|
|
|
|
*
|
|
|
|
* @param { Context } context - From UIExtensionAbility.
|
|
|
|
* @param { Array<PickerMediaType> } mediaTypes - Pick media type.
|
|
|
|
* @param { PickerProfile } pickerProfile - Picker input Profile.
|
|
|
|
* @returns { Promise<PickerResult> } pick result.
|
|
|
|
* @syscap SystemCapability.Multimedia.Camera.Core
|
|
|
|
* @atomicservice
|
|
|
|
* @since 12
|
|
|
|
*/
|
2023-12-22 07:54:15 +00:00
|
|
|
function pick(context: Context, mediaTypes: Array<PickerMediaType>, pickerProfile: PickerProfile): Promise<PickerResult>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default cameraPicker;
|