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 * Defines the moving photo view options. 25 * 26 * @interface MovingPhotoViewOptions 27 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 28 * @crossplatform 29 * @atomicservice 30 * @since arkts{ '1.1':'12','1.2':'20'} 31 * @arkts 1.1&1.2 32 */ 33declare interface MovingPhotoViewOptions { 34 /** 35 * moving photo data. 36 * 37 * @type { photoAccessHelper.MovingPhoto } 38 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 39 * @crossplatform 40 * @atomicservice 41 * @since arkts{ '1.1':'12','1.2':'20'} 42 * @arkts 1.1&1.2 43 */ 44 movingPhoto: photoAccessHelper.MovingPhoto; 45 /** 46 * controller of MovingPhotoView. 47 * 48 * @type { ?MovingPhotoViewController } 49 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 50 * @crossplatform 51 * @atomicservice 52 * @since arkts{ '1.1':'12','1.2':'20'} 53 * @arkts 1.1&1.2 54 */ 55 controller?: MovingPhotoViewController; 56 /** 57 * image ai options of MovingPhotoView. 58 * 59 * @type { ?ImageAIOptions } 60 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 61 * @crossplatform 62 * @atomicservice 63 * @since arkts{ '1.1':'18','1.2':'20'} 64 * @arkts 1.1&1.2 65 */ 66 imageAIOptions?: ImageAIOptions; 67 68 /** 69 * format of MovingPhotoView. 70 * 71 * @type { ?PixelMapFormat } 72 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 73 * @systemapi 74 * @since arkts{ '1.1':'14','1.2':'20'} 75 * @arkts 1.1&1.2 76 */ 77 movingPhotoFormat?: PixelMapFormat; 78 /** 79 * range mode of MovingPhotoView. 80 * 81 * @type { ?DynamicRangeMode } 82 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 83 * @systemapi 84 * @since arkts{ '1.1':'14','1.2':'20'} 85 * @arkts 1.1&1.2 86 */ 87 dynamicRangeMode?: DynamicRangeMode; 88 /** 89 * the watermask of the cover photo whether to contain during movingphoto playback 90 * 91 * @type { ?boolean } 92 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 93 * @systemapi 94 * @since arkts{ '1.1':'19','1.2':'20'} 95 * @arkts 1.1&1.2 96 */ 97 playWithMask?: boolean; 98} 99/** 100 * Defines the moving photo view interface. 101 * 102 * @interface MovingPhotoViewInterface 103 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 104 * @crossplatform 105 * @atomicservice 106 * @since arkts{ '1.1':'12','1.2':'20'} 107 * @arkts 1.1&1.2 108 */ 109interface MovingPhotoViewInterface { 110 /** 111 * Set the options. 112 * 113 * @param { MovingPhotoViewOptions } options 114 * @returns { MovingPhotoViewAttribute } 115 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 116 * @crossplatform 117 * @atomicservice 118 * @since arkts{ '1.1':'12','1.2':'20'} 119 * @arkts 1.1&1.2 120 */ 121 (options: MovingPhotoViewOptions): MovingPhotoViewAttribute; 122} 123 124/** 125 * function that moving photo view media events callback. 126 * 127 * @typedef { function } MovingPhotoViewEventCallback 128 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 129 * @crossplatform 130 * @atomicservice 131 * @since arkts{ '1.1':'12','1.2':'20'} 132 * @arkts 1.1&1.2 133 */ 134declare type MovingPhotoViewEventCallback = () => void; 135 136/** 137 * Defines the moving photo view attribute functions. 138 * 139 * @extends CommonMethod<MovingPhotoViewAttribute> 140 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 141 * @crossplatform 142 * @atomicservice 143 * @since arkts{ '1.1':'12','1.2':'20'} 144 * @arkts 1.1&1.2 145 */ 146declare class MovingPhotoViewAttribute extends CommonMethod<MovingPhotoViewAttribute> { 147 /** 148 * Called when judging whether the video is muted. 149 * 150 * @param { boolean } isMuted 151 * @returns { MovingPhotoViewAttribute } 152 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 153 * @crossplatform 154 * @atomicservice 155 * @since arkts{ '1.1':'12','1.2':'20'} 156 * @arkts 1.1&1.2 157 */ 158 muted(isMuted: boolean): MovingPhotoViewAttribute; 159 /** 160 * Called when determining the zoom type of the view. 161 * 162 * @param { ImageFit } value 163 * @returns { MovingPhotoViewAttribute } 164 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 165 * @crossplatform 166 * @atomicservice 167 * @since arkts{ '1.1':'12','1.2':'20'} 168 * @arkts 1.1&1.2 169 */ 170 objectFit(value: ImageFit): MovingPhotoViewAttribute; 171 /** 172 * Called when the image load completed. 173 * 174 * @param { MovingPhotoViewEventCallback } callback 175 * @returns { MovingPhotoViewAttribute } 176 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 177 * @crossplatform 178 * @atomicservice 179 * @since arkts{ '1.1':'13','1.2':'20'} 180 * @arkts 1.1&1.2 181 */ 182 onComplete(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 183 /** 184 * Called when the video is played. 185 * 186 * @param { MovingPhotoViewEventCallback } callback 187 * @returns { MovingPhotoViewAttribute } 188 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 189 * @crossplatform 190 * @atomicservice 191 * @since arkts{ '1.1':'12','1.2':'20'} 192 * @arkts 1.1&1.2 193 */ 194 onStart(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 195 /** 196 * Called when the video playback stopped. 197 * 198 * @param { MovingPhotoViewEventCallback } callback 199 * @returns { MovingPhotoViewAttribute } 200 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 201 * @crossplatform 202 * @atomicservice 203 * @since arkts{ '1.1':'12','1.2':'20'} 204 * @arkts 1.1&1.2 205 */ 206 onStop(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 207 /** 208 * Called when the video playback paused. 209 * 210 * @param { MovingPhotoViewEventCallback } callback 211 * @returns { MovingPhotoViewAttribute } 212 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 213 * @crossplatform 214 * @atomicservice 215 * @since arkts{ '1.1':'12','1.2':'20'} 216 * @arkts 1.1&1.2 217 */ 218 onPause(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 219 /** 220 * Called when the video playback ends. 221 * 222 * @param { MovingPhotoViewEventCallback } callback 223 * @returns { MovingPhotoViewAttribute } 224 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 225 * @crossplatform 226 * @atomicservice 227 * @since arkts{ '1.1':'12','1.2':'20'} 228 * @arkts 1.1&1.2 229 */ 230 onFinish(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 231 /** 232 * Called when playback fails. 233 * 234 * @param { MovingPhotoViewEventCallback } callback 235 * @returns { MovingPhotoViewAttribute } 236 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 237 * @crossplatform 238 * @atomicservice 239 * @since arkts{ '1.1':'12','1.2':'20'} 240 * @arkts 1.1&1.2 241 */ 242 onError(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 243 /** 244 * Called when playback prepared. 245 * 246 * @param { MovingPhotoViewEventCallback } callback 247 * @returns { MovingPhotoViewAttribute } 248 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 249 * @crossplatform 250 * @atomicservice 251 * @since 20 252 * @arkts 1.1&1.2 253 */ 254 onPrepared(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 255 /** 256 * Sets automatic play period, If not set, the moving photo plays in the full video duration. 257 * If set, the moving photo plays in the automatic play period. 258 * 259 * @param { number } startTime video plays start time 260 * @param { number } endTime video plays end time 261 * @returns { MovingPhotoViewAttribute } 262 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 263 * @crossplatform 264 * @atomicservice 265 * @since arkts{ '1.1':'13','1.2':'20'} 266 * @arkts 1.1&1.2 267 */ 268 autoPlayPeriod(startTime: number, endTime: number): MovingPhotoViewAttribute; 269 /** 270 * Sets whether to allow automatic play. If the value is true, the moving photo starts 271 * automatic after the resource is loaded. 272 * 273 * @param { boolean } isAutoPlay Whether to automatic play 274 * @returns { MovingPhotoViewAttribute } 275 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 276 * @crossplatform 277 * @atomicservice 278 * @since arkts{ '1.1':'13','1.2':'20'} 279 * @arkts 1.1&1.2 280 */ 281 autoPlay(isAutoPlay: boolean): MovingPhotoViewAttribute; 282 /** 283 * Sets whether to allow repeat play. If the value is true, the moving photo plays 284 * repeat after the resource is loaded. 285 * 286 * @param { boolean } isRepeatPlay Whether to repeat play 287 * @returns { MovingPhotoViewAttribute } 288 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 289 * @crossplatform 290 * @atomicservice 291 * @since arkts{ '1.1':'13','1.2':'20'} 292 * @arkts 1.1&1.2 293 */ 294 repeatPlay(isRepeatPlay: boolean): MovingPhotoViewAttribute; 295 296 /** 297 * Sets whether to enable moving photo analyzer. If the value is true, the moving photo can 298 * be analyzed by AI. 299 * 300 * @param { boolean } enabled - whether to enable moving photo analyzer 301 * @returns { MovingPhotoViewAttribute } 302 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 303 * @crossplatform 304 * @atomicservice 305 * @since arkts{ '1.1':'18','1.2':'20'} 306 * @arkts 1.1&1.2 307 */ 308 enableAnalyzer(enabled: boolean): MovingPhotoViewAttribute; 309} 310/** 311 * Defines the MovingPhotoView controller. 312 * 313 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 314 * @crossplatform 315 * @atomicservice 316 * @since arkts{ '1.1':'12','1.2':'20'} 317 * @arkts 1.1&1.2 318 */ 319export class MovingPhotoViewController { 320 /** 321 * constructor. 322 * 323 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 324 * @crossplatform 325 * @atomicservice 326 * @since arkts{ '1.1':'12','1.2':'20'} 327 * @arkts 1.1&1.2 328 */ 329 constructor(); 330 /** 331 * Start play moving photo. 332 * 333 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 334 * @crossplatform 335 * @atomicservice 336 * @since arkts{ '1.1':'12','1.2':'20'} 337 * @arkts 1.1&1.2 338 */ 339 startPlayback(); 340 /** 341 * Stop play moving photo. 342 * 343 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 344 * @crossplatform 345 * @atomicservice 346 * @since arkts{ '1.1':'12','1.2':'20'} 347 * @arkts 1.1&1.2 348 */ 349 stopPlayback(); 350 /** 351 * refresh moving photo data 352 * 353 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 354 * @crossplatform 355 * @atomicservice 356 * @since arkts{ '1.1':'18','1.2':'20'} 357 * @arkts 1.1&1.2 358 */ 359 refreshMovingPhoto(); 360 /** 361 * Pause moving photo and show current frame, start playing from the current frame when 362 * playing again 363 * 364 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 365 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 366 * @systemapi 367 * @atomicservice 368 * @since 20 369 * @arkts 1.1&1.2 370 */ 371 pausePlayback(); 372 /** 373 * Reset moving photo playback options as default. 374 * 375 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 376 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 377 * @systemapi 378 * @atomicservice 379 * @since 20 380 * @arkts 1.1&1.2 381 */ 382 reset(); 383 /** 384 * Restart to play the video with current options. 385 * 386 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 387 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 388 * @systemapi 389 * @atomicservice 390 * @since 20 391 * @arkts 1.1&1.2 392 */ 393 restart(); 394 /** 395 * Enable or disable the zoom transition effect and can be set during initialization 396 * 397 * @param { boolean } enabled - Whether to enable the transition effect 398 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 399 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 400 * @systemapi 401 * @atomicservice 402 * @since 20 403 * @arkts 1.1&1.2 404 */ 405 enableTransition(enabled: boolean); 406 /** 407 * Set moving photo playback period 408 * 409 * @param { double } startTime - video playback start time 410 * @param { double } endTime - video playback end time 411 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 412 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 413 * @systemapi 414 * @atomicservice 415 * @since 20 416 * @arkts 1.1&1.2 417 */ 418 setPlaybackPeriod(startTime: double, endTime: double); 419 /** 420 * Dynamically refresh the autoplay property, which will force to play after 421 * moving photo is initialized 422 * 423 * @param { boolean } enabled - Whether to auto play 424 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 425 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 426 * @systemapi 427 * @atomicservice 428 * @since 20 429 * @arkts 1.1&1.2 430 */ 431 enableAutoPlay(enabled: boolean); 432} 433/** 434 * Defines MovingPhotoView Component. 435 * 436 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 437 * @crossplatform 438 * @atomicservice 439 * @uicomponent 440 * @since arkts{ '1.1':'12','1.2':'20'} 441 * @arkts 1.1&1.2 442 */ 443declare const MovingPhotoView: MovingPhotoViewInterface; 444/** 445 * Defines MovingPhotoView Component instance. 446 * 447 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 448 * @crossplatform 449 * @atomicservice 450 * @since arkts{ '1.1':'12','1.2':'20'} 451 * @arkts 1.1&1.2 452 */ 453declare const MovingPhotoViewInstance: MovingPhotoViewAttribute; 454 455/** 456 * Dynamic range mode of moving photo. 457 * 458 * @enum { number } 459 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 460 * @systemapi 461 * @since arkts{ '1.1':'14','1.2':'20'} 462 * @arkts 1.1&1.2 463 */ 464export declare enum DynamicRangeMode { 465 /** 466 * Restrict the image content to dynamic range to the standard range 467 * 468 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 469 * @systemapi 470 * @since arkts{ '1.1':'14','1.2':'20'} 471 * @arkts 1.1&1.2 472 */ 473 STANDARD = 2, 474 /** 475 * Allow image content to use some extended range 476 * 477 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 478 * @systemapi 479 * @since arkts{ '1.1':'14','1.2':'20'} 480 * @arkts 1.1&1.2 481 */ 482 CONSTRAINT = 1, 483 /** 484 * Allow image content to use an unrestricted extended range 485 * 486 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 487 * @systemapi 488 * @since arkts{ '1.1':'14','1.2':'20'} 489 * @arkts 1.1&1.2 490 */ 491 HIGH = 0, 492} 493 494/** 495 * Enumerates pixel map formats. 496 * 497 * @enum { number } 498 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 499 * @systemapi 500 * @since arkts{ '1.1':'14','1.2':'20'} 501 * @arkts 1.1&1.2 502 */ 503export declare enum PixelMapFormat { 504 /** 505 * Indicates that the storage order is to store Y first and then V U alternately each occupies 8 bits 506 * and are stored from the higher-order to the lower-order bits. 507 * 508 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 509 * @systemapi 510 * @since arkts{ '1.1':'14','1.2':'20'} 511 * @arkts 1.1&1.2 512 */ 513 NV21 = 2, 514 515 /** 516 * Indicates that the storage order is to store Y first and then U V alternately each occupies 10 bits 517 * and are stored from the higher-order to the lower-order bits. 518 * 519 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 520 * @since arkts{ '1.1':'14','1.2':'20'} 521 * @arkts 1.1&1.2 522 */ 523 YCBCR_P010 = 4, 524 525 /** 526 * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components: 527 * R(10bits), G(10bits), B(10bits), A(2bits) and are stored from the higher-order to the lower-order bits. 528 * 529 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 530 * @since arkts{ '1.1':'14','1.2':'20'} 531 * @arkts 1.1&1.2 532 */ 533 RGBA_1010102 = 3, 534 535 /** 536 * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits) 537 * and are stored from the higher-order to the lower-order bits. 538 * 539 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 540 * @systemapi 541 * @since arkts{ '1.1':'14','1.2':'20'} 542 * @arkts 1.1&1.2 543 */ 544 RGBA_8888 = 1, 545 546 /** 547 * Indicates that the storage order is to store Y first and then V U alternately each occupies 10 bits 548 * and are stored from the higher-order to the lower-order bits. 549 * 550 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 551 * @since arkts{ '1.1':'14','1.2':'20'} 552 * @arkts 1.1&1.2 553 */ 554 YCRCB_P010 = 5, 555 556 /** 557 * Indicates an unknown format. 558 * 559 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 560 * @systemapi 561 * @since arkts{ '1.1':'14','1.2':'20'} 562 * @arkts 1.1&1.2 563 */ 564 UNKNOWN = 0 565}