1/* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit CameraKit 19 */ 20 21import type Context from './application/Context'; 22import type camera from './@ohos.multimedia.camera'; 23 24/** 25 * @namespace cameraPicker 26 * @syscap SystemCapability.Multimedia.Camera.Core 27 * @since 11 28 */ 29/** 30 * @namespace cameraPicker 31 * @syscap SystemCapability.Multimedia.Camera.Core 32 * @atomicservice 33 * @since 12 34 */ 35declare namespace cameraPicker { 36 37 /** 38 * Picker profile settings for take photo and record video. 39 * 40 * @syscap SystemCapability.Multimedia.Camera.Core 41 * @since 11 42 */ 43 /** 44 * Picker profile settings for take photo and record video. 45 * 46 * @syscap SystemCapability.Multimedia.Camera.Core 47 * @atomicservice 48 * @since 12 49 */ 50 class PickerProfile { 51 /** 52 * The camera position to be used. 53 * 54 * @type { camera.CameraPosition } 55 * @syscap SystemCapability.Multimedia.Camera.Core 56 * @since 11 57 */ 58 /** 59 * The camera position to be used. 60 * 61 * @type { camera.CameraPosition } 62 * @syscap SystemCapability.Multimedia.Camera.Core 63 * @atomicservice 64 * @since 12 65 */ 66 cameraPosition: camera.CameraPosition; 67 68 /** 69 * The uri of the result to be saved. 70 * 71 * @type { ?string } 72 * @syscap SystemCapability.Multimedia.Camera.Core 73 * @since 11 74 */ 75 /** 76 * The uri of the result to be saved. 77 * 78 * @type { ?string } 79 * @syscap SystemCapability.Multimedia.Camera.Core 80 * @atomicservice 81 * @since 12 82 */ 83 saveUri?: string; 84 85 /** 86 * The max duration of the video. 87 * 88 * @type { ?number } 89 * @syscap SystemCapability.Multimedia.Camera.Core 90 * @since 11 91 */ 92 /** 93 * The max duration of the video. 94 * 95 * @type { ?number } 96 * @syscap SystemCapability.Multimedia.Camera.Core 97 * @atomicservice 98 * @since 12 99 */ 100 videoDuration?: number; 101 } 102 103 /** 104 * Enum for camera picker media type. 105 * 106 * @enum { string } 107 * @syscap SystemCapability.Multimedia.Camera.Core 108 * @since 11 109 */ 110 /** 111 * Enum for camera picker media type. 112 * 113 * @enum { string } 114 * @syscap SystemCapability.Multimedia.Camera.Core 115 * @atomicservice 116 * @since 12 117 */ 118 enum PickerMediaType { 119 /** 120 * Type image, picker provide an ability to take photo. 121 * 122 * @syscap SystemCapability.Multimedia.Camera.Core 123 * @since 11 124 */ 125 /** 126 * Type image, picker provide an ability to take photo. 127 * 128 * @syscap SystemCapability.Multimedia.Camera.Core 129 * @atomicservice 130 * @since 12 131 */ 132 PHOTO = 'photo', 133 134 /** 135 * Type video, picker provide an ability to record video. 136 * 137 * @syscap SystemCapability.Multimedia.Camera.Core 138 * @since 11 139 */ 140 /** 141 * Type video, picker provide an ability to record video. 142 * 143 * @syscap SystemCapability.Multimedia.Camera.Core 144 * @atomicservice 145 * @since 12 146 */ 147 VIDEO = 'video' 148 } 149 150 /** 151 * The picker result info for pick function. 152 * 153 * @syscap SystemCapability.Multimedia.Camera.Core 154 * @since 11 155 */ 156 /** 157 * The picker result info for pick function. 158 * 159 * @syscap SystemCapability.Multimedia.Camera.Core 160 * @atomicservice 161 * @since 12 162 */ 163 class PickerResult { 164 /** 165 * The result code. 166 * 167 * @type { number } 168 * @syscap SystemCapability.Multimedia.Camera.Core 169 * @since 11 170 */ 171 /** 172 * The result code. 173 * 174 * @type { number } 175 * @syscap SystemCapability.Multimedia.Camera.Core 176 * @atomicservice 177 * @since 12 178 */ 179 resultCode: number; 180 181 /** 182 * The result saved uri. 183 * 184 * @type { string } 185 * @syscap SystemCapability.Multimedia.Camera.Core 186 * @since 11 187 */ 188 /** 189 * The result saved uri. 190 * 191 * @type { string } 192 * @syscap SystemCapability.Multimedia.Camera.Core 193 * @atomicservice 194 * @since 12 195 */ 196 resultUri: string; 197 198 /** 199 * The result resource type. 200 * 201 * @type { PickerMediaType } 202 * @syscap SystemCapability.Multimedia.Camera.Core 203 * @since 11 204 */ 205 /** 206 * The result resource type. 207 * 208 * @type { PickerMediaType } 209 * @syscap SystemCapability.Multimedia.Camera.Core 210 * @atomicservice 211 * @since 12 212 */ 213 mediaType: PickerMediaType; 214 } 215 216 /** 217 * Pick function to get a photo or video result. 218 * 219 * @param { Context } context - From UIExtensionAbility. 220 * @param { Array<PickerMediaType> } mediaTypes - Pick media type. 221 * @param { PickerProfile } pickerProfile - Picker input Profile. 222 * @returns { Promise<PickerResult> } pick result. 223 * @syscap SystemCapability.Multimedia.Camera.Core 224 * @since 11 225 */ 226 /** 227 * Pick function to get a photo or video result. 228 * 229 * @param { Context } context - From UIExtensionAbility. 230 * @param { Array<PickerMediaType> } mediaTypes - Pick media type. 231 * @param { PickerProfile } pickerProfile - Picker input Profile. 232 * @returns { Promise<PickerResult> } pick result. 233 * @syscap SystemCapability.Multimedia.Camera.Core 234 * @atomicservice 235 * @since 12 236 */ 237 function pick(context: Context, mediaTypes: Array<PickerMediaType>, pickerProfile: PickerProfile): Promise<PickerResult>; 238} 239 240export default cameraPicker;