1/* 2 * Copyright (c) 2024 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 A component which support applications to show moving photo data 18 * @kit MediaLibraryKit 19 */ 20 21import photoAccessHelper from './@ohos.file.photoAccessHelper'; 22 23/** 24 * Enumerates pixel map formats. 25 * 26 * @enum { number } 27 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 28 * @systemapi 29 * @since 14 30 */ 31export declare enum PixelMapFormat { 32 /** 33 * Indicates an unknown format. 34 * 35 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 36 * @systemapi 37 * @since 14 38 */ 39 UNKNOWN = 0, 40 /** 41 * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits) 42 * and are stored from the higher-order to the lower-order bits. 43 * 44 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 45 * @systemapi 46 * @since 14 47 */ 48 RGBA_8888 = 1, 49 /** 50 * Indicates that the storage order is to store Y first and then V U alternately each occupies 8 bits 51 * and are stored from the higher-order to the lower-order bits. 52 * 53 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 54 * @systemapi 55 * @since 14 56 */ 57 NV21 = 2, 58 /** 59 * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components: 60 * R(10bits), G(10bits), B(10bits), A(2bits) and are stored from the higher-order to the lower-order bits. 61 * 62 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 63 * @since 14 64 */ 65 RGBA_1010102 = 3, 66 67 /** 68 * Indicates that the storage order is to store Y first and then U V alternately each occupies 10 bits 69 * and are stored from the higher-order to the lower-order bits. 70 * 71 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 72 * @since 14 73 */ 74 YCBCR_P010 = 4, 75 76 /** 77 * Indicates that the storage order is to store Y first and then V U alternately each occupies 10 bits 78 * and are stored from the higher-order to the lower-order bits. 79 * 80 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 81 * @since 14 82 */ 83 YCRCB_P010 = 5 84} 85/** 86 * Dynamic range mode of moving photo. 87 * 88 * @enum { number } 89 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 90 * @systemapi 91 * @since 14 92 */ 93export declare enum DynamicRangeMode { 94 /** 95 * Allow image content to use an unrestricted extended range 96 * 97 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 98 * @systemapi 99 * @since 14 100 */ 101 HIGH = 0, 102 /** 103 * Allow image content to use some extended range 104 * 105 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 106 * @systemapi 107 * @since 14 108 */ 109 CONSTRAINT = 1, 110 /** 111 * Restrict the image content to dynamic range to the standard range 112 * 113 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 114 * @systemapi 115 * @since 14 116 */ 117 STANDARD = 2, 118} 119/** 120 * Defines the moving photo view options. 121 * 122 * @interface MovingPhotoViewOptions 123 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 124 * @crossplatform 125 * @atomicservice 126 * @since 12 127 */ 128declare interface MovingPhotoViewOptions { 129 /** 130 * moving photo data. 131 * 132 * @type { photoAccessHelper.MovingPhoto } 133 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 134 * @crossplatform 135 * @atomicservice 136 * @since 12 137 */ 138 movingPhoto: photoAccessHelper.MovingPhoto; 139 /** 140 * controller of MovingPhotoView. 141 * 142 * @type { ?MovingPhotoViewController } 143 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 144 * @crossplatform 145 * @atomicservice 146 * @since 12 147 */ 148 controller?: MovingPhotoViewController; 149 /** 150 * image ai options of MovingPhotoView. 151 * 152 * @type { ?ImageAIOptions } 153 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 154 * @crossplatform 155 * @atomicservice 156 * @since 18 157 */ 158 imageAIOptions?: ImageAIOptions; 159 /** 160 * format of MovingPhotoView. 161 * 162 * @type { ?PixelMapFormat } 163 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 164 * @systemapi 165 * @since 14 166 */ 167 movingPhotoFormat?: PixelMapFormat; 168 /** 169 * range mode of MovingPhotoView. 170 * 171 * @type { ?DynamicRangeMode } 172 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 173 * @systemapi 174 * @since 14 175 */ 176 dynamicRangeMode?: DynamicRangeMode; 177} 178/** 179 * Defines the moving photo view interface. 180 * 181 * @interface MovingPhotoViewInterface 182 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 183 * @crossplatform 184 * @atomicservice 185 * @since 12 186 */ 187interface MovingPhotoViewInterface { 188 /** 189 * Set the options. 190 * 191 * @param { MovingPhotoViewOptions } options 192 * @returns { MovingPhotoViewAttribute } 193 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 194 * @crossplatform 195 * @atomicservice 196 * @since 12 197 */ 198 (options: MovingPhotoViewOptions): MovingPhotoViewAttribute; 199} 200 201/** 202 * function that moving photo view media events callback. 203 * 204 * @typedef { function } MovingPhotoViewEventCallback 205 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 206 * @crossplatform 207 * @atomicservice 208 * @since 12 209 */ 210declare type MovingPhotoViewEventCallback = () => void; 211 212/** 213 * Defines the moving photo view attribute functions. 214 * 215 * @extends CommonMethod<MovingPhotoViewAttribute> 216 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 217 * @crossplatform 218 * @atomicservice 219 * @since 12 220 */ 221declare class MovingPhotoViewAttribute extends CommonMethod<MovingPhotoViewAttribute> { 222 /** 223 * Called when judging whether the video is muted. 224 * 225 * @param { boolean } isMuted 226 * @returns { MovingPhotoViewAttribute } 227 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 228 * @crossplatform 229 * @atomicservice 230 * @since 12 231 */ 232 muted(isMuted: boolean): MovingPhotoViewAttribute; 233 /** 234 * Called when determining the zoom type of the view. 235 * 236 * @param { ImageFit } value 237 * @returns { MovingPhotoViewAttribute } 238 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 239 * @crossplatform 240 * @atomicservice 241 * @since 12 242 */ 243 objectFit(value: ImageFit): MovingPhotoViewAttribute; 244 /** 245 * Called when the image load completed. 246 * 247 * @param { MovingPhotoViewEventCallback } callback 248 * @returns { MovingPhotoViewAttribute } 249 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 250 * @crossplatform 251 * @atomicservice 252 * @since 13 253 */ 254 onComplete(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 255 /** 256 * Called when the video is played. 257 * 258 * @param { MovingPhotoViewEventCallback } callback 259 * @returns { MovingPhotoViewAttribute } 260 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 261 * @crossplatform 262 * @atomicservice 263 * @since 12 264 */ 265 onStart(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 266 /** 267 * Called when the video playback stopped. 268 * 269 * @param { MovingPhotoViewEventCallback } callback 270 * @returns { MovingPhotoViewAttribute } 271 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 272 * @crossplatform 273 * @atomicservice 274 * @since 12 275 */ 276 onStop(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 277 /** 278 * Called when the video playback paused. 279 * 280 * @param { MovingPhotoViewEventCallback } callback 281 * @returns { MovingPhotoViewAttribute } 282 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 283 * @crossplatform 284 * @atomicservice 285 * @since 12 286 */ 287 onPause(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 288 /** 289 * Called when the video playback ends. 290 * 291 * @param { MovingPhotoViewEventCallback } callback 292 * @returns { MovingPhotoViewAttribute } 293 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 294 * @crossplatform 295 * @atomicservice 296 * @since 12 297 */ 298 onFinish(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 299 /** 300 * Called when playback fails. 301 * 302 * @param { MovingPhotoViewEventCallback } callback 303 * @returns { MovingPhotoViewAttribute } 304 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 305 * @crossplatform 306 * @atomicservice 307 * @since 12 308 */ 309 onError(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 310 /** 311 * Sets automatic play period, If not set, the moving photo plays in the full video duration. 312 * If set, the moving photo plays in the automatic play period. 313 * 314 * @param { number } startTime video plays start time 315 * @param { number } endTime video plays end time 316 * @returns { MovingPhotoViewAttribute } 317 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 318 * @crossplatform 319 * @atomicservice 320 * @since 13 321 */ 322 autoPlayPeriod(startTime: number, endTime: number): MovingPhotoViewAttribute; 323 /** 324 * Sets whether to allow automatic play. If the value is true, the moving photo starts 325 * automatic after the resource is loaded. 326 * 327 * @param { boolean } isAutoPlay Whether to automatic play 328 * @returns { MovingPhotoViewAttribute } 329 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 330 * @crossplatform 331 * @atomicservice 332 * @since 13 333 */ 334 autoPlay(isAutoPlay: boolean): MovingPhotoViewAttribute; 335 /** 336 * Sets whether to allow repeat play. If the value is true, the moving photo plays 337 * repeat after the resource is loaded. 338 * 339 * @param { boolean } isRepeatPlay Whether to repeat play 340 * @returns { MovingPhotoViewAttribute } 341 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 342 * @crossplatform 343 * @atomicservice 344 * @since 13 345 */ 346 repeatPlay(isRepeatPlay: boolean): MovingPhotoViewAttribute; 347 348 /** 349 * Sets whether to enable moving photo analyzer. If the value is true, the moving photo can 350 * be analyzed by AI. 351 * 352 * @param { boolean } enabled - whether to enable moving photo analyzer 353 * @returns { MovingPhotoViewAttribute } 354 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 355 * @crossplatform 356 * @atomicservice 357 * @since 18 358 */ 359 enableAnalyzer(enabled: boolean): MovingPhotoViewAttribute; 360} 361/** 362 * Defines the MovingPhotoView controller. 363 * 364 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 365 * @crossplatform 366 * @atomicservice 367 * @since 12 368 */ 369export class MovingPhotoViewController { 370 /** 371 * constructor. 372 * 373 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 374 * @crossplatform 375 * @atomicservice 376 * @since 12 377 */ 378 constructor(); 379 /** 380 * Start play moving photo. 381 * 382 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 383 * @crossplatform 384 * @atomicservice 385 * @since 12 386 */ 387 startPlayback(); 388 /** 389 * Stop play moving photo. 390 * 391 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 392 * @crossplatform 393 * @atomicservice 394 * @since 12 395 */ 396 stopPlayback(); 397 /** 398 * refresh moving photo data 399 * 400 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 401 * @crossplatform 402 * @atomicservice 403 * @since 18 404 */ 405 refreshMovingPhoto(); 406} 407/** 408 * Defines MovingPhotoView Component. 409 * 410 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 411 * @crossplatform 412 * @atomicservice 413 * @uicomponent 414 * @since 12 415 */ 416declare const MovingPhotoView: MovingPhotoViewInterface; 417/** 418 * Defines MovingPhotoView Component instance. 419 * 420 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 421 * @crossplatform 422 * @atomicservice 423 * @since 12 424 */ 425declare const MovingPhotoViewInstance: MovingPhotoViewAttribute; 426