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 * format of MovingPhotoView. 151 * 152 * @type { ?PixelMapFormat } 153 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 154 * @systemapi 155 * @since 14 156 */ 157 movingPhotoFormat?: PixelMapFormat; 158 /** 159 * range mode of MovingPhotoView. 160 * 161 * @type { ?DynamicRangeMode } 162 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 163 * @systemapi 164 * @since 14 165 */ 166 dynamicRangeMode?: DynamicRangeMode; 167} 168/** 169 * Defines the moving photo view interface. 170 * 171 * @interface MovingPhotoViewInterface 172 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 173 * @crossplatform 174 * @atomicservice 175 * @since 12 176 */ 177interface MovingPhotoViewInterface { 178 /** 179 * Set the options. 180 * 181 * @param { MovingPhotoViewOptions } options 182 * @returns { MovingPhotoViewAttribute } 183 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 184 * @crossplatform 185 * @atomicservice 186 * @since 12 187 */ 188 (options: MovingPhotoViewOptions): MovingPhotoViewAttribute; 189} 190 191/** 192 * function that moving photo view media events callback. 193 * 194 * @typedef { function } MovingPhotoViewEventCallback 195 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 196 * @crossplatform 197 * @atomicservice 198 * @since 12 199 */ 200declare type MovingPhotoViewEventCallback = () => void; 201 202/** 203 * Defines the moving photo view attribute functions. 204 * 205 * @extends CommonMethod<MovingPhotoViewAttribute> 206 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 207 * @crossplatform 208 * @atomicservice 209 * @since 12 210 */ 211declare class MovingPhotoViewAttribute extends CommonMethod<MovingPhotoViewAttribute> { 212 /** 213 * Called when judging whether the video is muted. 214 * 215 * @param { boolean } isMuted 216 * @returns { MovingPhotoViewAttribute } 217 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 218 * @crossplatform 219 * @atomicservice 220 * @since 12 221 */ 222 muted(isMuted: boolean): MovingPhotoViewAttribute; 223 /** 224 * Called when determining the zoom type of the view. 225 * 226 * @param { ImageFit } value 227 * @returns { MovingPhotoViewAttribute } 228 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 229 * @crossplatform 230 * @atomicservice 231 * @since 12 232 */ 233 objectFit(value: ImageFit): MovingPhotoViewAttribute; 234 /** 235 * Called when the image load completed. 236 * 237 * @param { MovingPhotoViewEventCallback } callback 238 * @returns { MovingPhotoViewAttribute } 239 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 240 * @crossplatform 241 * @atomicservice 242 * @since 13 243 */ 244 onComplete(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 245 /** 246 * Called when the video is played. 247 * 248 * @param { MovingPhotoViewEventCallback } callback 249 * @returns { MovingPhotoViewAttribute } 250 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 251 * @crossplatform 252 * @atomicservice 253 * @since 12 254 */ 255 onStart(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 256 /** 257 * Called when the video playback stopped. 258 * 259 * @param { MovingPhotoViewEventCallback } callback 260 * @returns { MovingPhotoViewAttribute } 261 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 262 * @crossplatform 263 * @atomicservice 264 * @since 12 265 */ 266 onStop(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 267 /** 268 * Called when the video playback paused. 269 * 270 * @param { MovingPhotoViewEventCallback } callback 271 * @returns { MovingPhotoViewAttribute } 272 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 273 * @crossplatform 274 * @atomicservice 275 * @since 12 276 */ 277 onPause(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 278 /** 279 * Called when the video playback ends. 280 * 281 * @param { MovingPhotoViewEventCallback } callback 282 * @returns { MovingPhotoViewAttribute } 283 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 284 * @crossplatform 285 * @atomicservice 286 * @since 12 287 */ 288 onFinish(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 289 /** 290 * Called when playback fails. 291 * 292 * @param { MovingPhotoViewEventCallback } callback 293 * @returns { MovingPhotoViewAttribute } 294 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 295 * @crossplatform 296 * @atomicservice 297 * @since 12 298 */ 299 onError(callback: MovingPhotoViewEventCallback): MovingPhotoViewAttribute; 300 /** 301 * Sets automatic play period, If not set, the moving photo plays in the full video duration. 302 * If set, the moving photo plays in the automatic play period. 303 * 304 * @param { number } startTime video plays start time 305 * @param { number } endTime video plays end time 306 * @returns { MovingPhotoViewAttribute } 307 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 308 * @crossplatform 309 * @atomicservice 310 * @since 13 311 */ 312 autoPlayPeriod(startTime: number, endTime: number): MovingPhotoViewAttribute; 313 /** 314 * Sets whether to allow automatic play. If the value is true, the moving photo starts 315 * automatic after the resource is loaded. 316 * 317 * @param { boolean } isAutoPlay Whether to automatic play 318 * @returns { MovingPhotoViewAttribute } 319 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 320 * @crossplatform 321 * @atomicservice 322 * @since 13 323 */ 324 autoPlay(isAutoPlay: boolean): MovingPhotoViewAttribute; 325 /** 326 * Sets whether to allow repeat play. If the value is true, the moving photo plays 327 * repeat after the resource is loaded. 328 * 329 * @param { boolean } isRepeatPlay Whether to repeat play 330 * @returns { MovingPhotoViewAttribute } 331 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 332 * @crossplatform 333 * @atomicservice 334 * @since 13 335 */ 336 repeatPlay(isRepeatPlay: boolean): MovingPhotoViewAttribute; 337} 338/** 339 * Defines the MovingPhotoView controller. 340 * 341 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 342 * @crossplatform 343 * @atomicservice 344 * @since 12 345 */ 346export class MovingPhotoViewController { 347 /** 348 * constructor. 349 * 350 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 351 * @crossplatform 352 * @atomicservice 353 * @since 12 354 */ 355 constructor(); 356 /** 357 * Start play moving photo. 358 * 359 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 360 * @crossplatform 361 * @atomicservice 362 * @since 12 363 */ 364 startPlayback(); 365 /** 366 * Stop play moving photo. 367 * 368 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 369 * @crossplatform 370 * @atomicservice 371 * @since 12 372 */ 373 stopPlayback(); 374} 375/** 376 * Defines MovingPhotoView Component. 377 * 378 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 379 * @crossplatform 380 * @atomicservice 381 * @since 12 382 */ 383declare const MovingPhotoView: MovingPhotoViewInterface; 384/** 385 * Defines MovingPhotoView Component instance. 386 * 387 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 388 * @crossplatform 389 * @atomicservice 390 * @since 12 391 */ 392declare const MovingPhotoViewInstance: MovingPhotoViewAttribute; 393