1/* 2* Copyright (C) 2021-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 18 * @kit MediaKit 19 */ 20 21import { ErrorCallback, AsyncCallback, Callback } from './@ohos.base'; 22import audio from "./@ohos.multimedia.audio"; 23import photoAccessHelper from "./@ohos.file.photoAccessHelper"; 24import type image from './@ohos.multimedia.image'; 25import type { SoundPool as _SoundPool } from './multimedia/soundPool'; 26import type { PlayParameters as _PlayParameters } from './multimedia/soundPool'; 27import type drm from './@ohos.multimedia.drm'; 28 29/** 30 * @namespace media 31 * @since 6 32 */ 33/** 34 * @namespace media 35 * @atomicservice 36 * @since 11 37 */ 38/** 39 * @namespace media 40 * @syscap SystemCapability.Multimedia.Media.Core 41 * @crossplatform 42 * @atomicservice 43 * @since 12 44 */ 45declare namespace media { 46 /** 47 * Creates an AVPlayer instance. 48 * @param { AsyncCallback<AVPlayer> } callback - used to return AVPlayer instance if the operation is successful; returns null otherwise. 49 * @throws { BusinessError } 5400101 - No memory. Return by callback. 50 * @syscap SystemCapability.Multimedia.Media.AVPlayer 51 * @since 9 52 */ 53 /** 54 * Creates an AVPlayer instance. 55 * @param { AsyncCallback<AVPlayer> } callback - used to return AVPlayer instance if the operation is successful; returns null otherwise. 56 * @throws { BusinessError } 5400101 - No memory. Return by callback. 57 * @syscap SystemCapability.Multimedia.Media.AVPlayer 58 * @atomicservice 59 * @since 11 60 */ 61 /** 62 * Creates an AVPlayer instance. 63 * @param { AsyncCallback<AVPlayer> } callback - used to return AVPlayer instance if the operation is successful; returns null otherwise. 64 * @throws { BusinessError } 5400101 - No memory. Return by callback. 65 * @syscap SystemCapability.Multimedia.Media.AVPlayer 66 * @crossplatform 67 * @atomicservice 68 * @since 12 69 */ 70 function createAVPlayer(callback: AsyncCallback<AVPlayer>): void; 71 72 /** 73 * Creates an AVPlayer instance. 74 * @returns { Promise<AVPlayer> } A Promise instance used to return AVPlayer instance if the operation is successful; returns null otherwise. 75 * @throws { BusinessError } 5400101 - No memory. Return by promise. 76 * @syscap SystemCapability.Multimedia.Media.AVPlayer 77 * @since 9 78 */ 79 /** 80 * Creates an AVPlayer instance. 81 * @returns { Promise<AVPlayer> } A Promise instance used to return AVPlayer instance if the operation is successful; returns null otherwise. 82 * @throws { BusinessError } 5400101 - No memory. Return by promise. 83 * @syscap SystemCapability.Multimedia.Media.AVPlayer 84 * @atomicservice 85 * @since 11 86 */ 87 /** 88 * Creates an AVPlayer instance. 89 * @returns { Promise<AVPlayer> } A Promise instance used to return AVPlayer instance if the operation is successful; returns null otherwise. 90 * @throws { BusinessError } 5400101 - No memory. Return by promise. 91 * @syscap SystemCapability.Multimedia.Media.AVPlayer 92 * @crossplatform 93 * @atomicservice 94 * @since 12 95 */ 96 function createAVPlayer(): Promise<AVPlayer>; 97 98 /** 99 * Creates an AVRecorder instance. 100 * @param { AsyncCallback<AVRecorder> } callback - used to return AVRecorder instance if the operation is successful; returns null otherwise. 101 * @throws { BusinessError } 5400101 - No memory. Return by callback. 102 * @syscap SystemCapability.Multimedia.Media.AVRecorder 103 * @since 9 104 */ 105 /** 106 * Creates an AVRecorder instance. 107 * @param { AsyncCallback<AVRecorder> } callback - used to return AVRecorder instance if the operation is successful; returns null otherwise. 108 * @throws { BusinessError } 5400101 - No memory. Return by callback. 109 * @syscap SystemCapability.Multimedia.Media.AVRecorder 110 * @crossplatform 111 * @since 12 112 */ 113 function createAVRecorder(callback: AsyncCallback<AVRecorder>): void; 114 115 /** 116 * Creates an AVRecorder instance. 117 * @returns { Promise<AVRecorder> } A Promise instance used to return AVRecorder instance if the operation is successful; returns null otherwise. 118 * @throws { BusinessError } 5400101 - No memory. Return by promise. 119 * @syscap SystemCapability.Multimedia.Media.AVRecorder 120 * @since 9 121 */ 122 /** 123 * Creates an AVRecorder instance. 124 * @returns { Promise<AVRecorder> } A Promise instance used to return AVRecorder instance if the operation is successful; returns null otherwise. 125 * @throws { BusinessError } 5400101 - No memory. Return by promise. 126 * @syscap SystemCapability.Multimedia.Media.AVRecorder 127 * @crossplatform 128 * @atomicservice 129 * @since 12 130 */ 131 function createAVRecorder(): Promise<AVRecorder>; 132 133 /** 134 * Creates an AudioPlayer instance. 135 * @returns { AudioPlayer } Returns an AudioPlayer instance if the operation is successful; returns null otherwise. 136 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 137 * @since 6 138 * @deprecated since 9 139 * @useinstead ohos.multimedia.media/media#createAVPlayer 140 */ 141 function createAudioPlayer(): AudioPlayer; 142 143 /** 144 * Creates an AudioRecorder instance. 145 * @returns { AudioRecorder } Returns an AudioRecorder instance if the operation is successful; returns null otherwise. 146 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 147 * @since 6 148 * @deprecated since 9 149 * @useinstead ohos.multimedia.media/media#createAVRecorder 150 */ 151 function createAudioRecorder(): AudioRecorder; 152 153 /** 154 * Create MediaSource from url. 155 * @param { string } url : The location for the media source. 156 * @param { Record<string, string> } headers : Headers attached to network request while player request data. 157 * @returns { MediaSource } MediaSource instance if the operation is successful; returns null otherwise. 158 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 159 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 160 * @throws { BusinessError } 5400101 - No memory. 161 * @syscap SystemCapability.Multimedia.Media.Core 162 * @since 12 163 */ 164 /** 165 * Create MediaSource from url. 166 * @param { string } url : The location for the media source. 167 * @param { Record<string, string> } headers : Headers attached to network request while player request data. 168 * @returns { MediaSource } MediaSource instance if the operation is successful; returns null otherwise. 169 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 170 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 171 * @throws { BusinessError } 5400101 - No memory. 172 * @syscap SystemCapability.Multimedia.Media.Core 173 * @atomicservice 174 * @since 13 175 */ 176 function createMediaSourceWithUrl(url: string, headers?: Record<string, string>): MediaSource; 177 178 /** 179 * Creates an VideoPlayer instance. 180 * @param { AsyncCallback<VideoPlayer> } callback - used to return AudioPlayer instance if the operation is successful; returns null otherwise. 181 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 182 * @since 8 183 * @deprecated since 9 184 * @useinstead ohos.multimedia.media/media#createAVPlayer 185 */ 186 function createVideoPlayer(callback: AsyncCallback<VideoPlayer>): void; 187 188 /** 189 * Creates an VideoPlayer instance. 190 * @returns { Promise<VideoPlayer> } A Promise instance used to return VideoPlayer instance if the operation is successful; returns null otherwise. 191 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 192 * @since 8 193 * @deprecated since 9 194 * @useinstead ohos.multimedia.media/media#createAVPlayer 195 */ 196 function createVideoPlayer(): Promise<VideoPlayer>; 197 198 /** 199 * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder 200 * Creates an VideoRecorder instance. 201 * @param { AsyncCallback<VideoRecorder> } callback - used to return AudioPlayer instance if the operation is successful; returns null otherwise. 202 * @throws { BusinessError } 5400101 - No memory. Return by callback. 203 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 204 * @systemapi 205 * @since 9 206 */ 207 /** 208 * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder 209 * Creates an VideoRecorder instance. 210 * @param { AsyncCallback<VideoRecorder> } callback - used to return AudioPlayer instance if the operation is successful; returns null otherwise. 211 * @throws { BusinessError } 202 - Not System App. 212 * @throws { BusinessError } 5400101 - No memory. Return by callback. 213 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 214 * @systemapi 215 * @since 12 216 */ 217 function createVideoRecorder(callback: AsyncCallback<VideoRecorder>): void; 218 219 /** 220 * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder 221 * Creates an VideoRecorder instance. 222 * @returns { Promise<VideoRecorder> } A Promise instance used to return VideoRecorder instance if the operation is successful; returns null otherwise. 223 * @throws { BusinessError } 5400101 - No memory. Return by promise. 224 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 225 * @systemapi 226 * @since 9 227 */ 228 /** 229 * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder 230 * Creates an VideoRecorder instance. 231 * @returns { Promise<VideoRecorder> } A Promise instance used to return VideoRecorder instance if the operation is successful; returns null otherwise. 232 * @throws { BusinessError } 202 - Not System App. 233 * @throws { BusinessError } 5400101 - No memory. Return by promise. 234 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 235 * @systemapi 236 * @since 12 237 */ 238 function createVideoRecorder(): Promise<VideoRecorder>; 239 240 /** 241 * Creates a soundPool instance. 242 * 243 * @param {number} maxStreams The maximum number of simultaneous streams for this soundPool instance 244 * @param {audio.AudioRendererInfo} audioRenderInfo Audio renderer information 245 * @param {AsyncCallback<SoundPool>} callback Callback used to return soundPool instance if the operation is successful; returns null otherwise. 246 * @throws { BusinessError } 5400101 - No memory. Return by callback. 247 * @syscap SystemCapability.Multimedia.Media.SoundPool 248 * @since 10 249 */ 250 function createSoundPool( 251 maxStreams: number, 252 audioRenderInfo: audio.AudioRendererInfo, 253 callback: AsyncCallback<SoundPool> 254 ): void; 255 256 /** 257 * Creates a soundPool instance. 258 * 259 * @param {number} maxStreams The maximum number of simultaneous streams for this soundPool instance 260 * @param {audio.AudioRendererInfo} audioRenderInfo Audio renderer information 261 * @returns {Promise<SoundPool>} A Promise instance used to return SoundPool instance if the operation is successful; returns null otherwise. 262 * @throws { BusinessError } 5400101 - No memory. Return by promise. 263 * @syscap SystemCapability.Multimedia.Media.SoundPool 264 * @since 10 265 */ 266 function createSoundPool(maxStreams: number, audioRenderInfo: audio.AudioRendererInfo): Promise<SoundPool>; 267 268 /** 269 * Creates an AVScreenCaptureRecorder instance. 270 * @returns { Promise<AVScreenCaptureRecorder> } A Promise instance used to return AVScreenCaptureRecorder instance if the operation is successful; 271 * returns null otherwise. 272 * @throws { BusinessError } 5400101 - No memory. Return by promise. 273 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 274 * @since 12 275 */ 276 function createAVScreenCaptureRecorder(): Promise<AVScreenCaptureRecorder>; 277 278 /** 279 * Report user choice back to AVScreenCapture server 280 * 281 * @param {number} sessionId The AVScreenCapture server session ID. 282 * @param {string} choice Content chosen by user. 283 * @returns { Promise<void> } Promise used to return the result. 284 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 285 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 286 * @throws { BusinessError } 5400101 - No memory. Return by promise. 287 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 288 * @systemapi 289 * @since 12 290 */ 291 function reportAVScreenCaptureUserChoice(sessionId: number, choice: string): Promise<void>; 292 293 /** 294 * Creates a AVTranscoder instance. 295 * 296 * @returns {Promise<AVTranscoder>} A Promise instance used to return AVTranscoder instance if the operation is successful; returns null otherwise. 297 * @throws { BusinessError } 5400101 - No memory. Return by promise. 298 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 299 * @since 12 300 */ 301 function createAVTranscoder(): Promise<AVTranscoder>; 302 303 /** 304 * Manages and plays sound. Before calling an SoundPool method, you must use createSoundPool() 305 * to create an SoundPool instance. 306 * 307 * @typedef { _SoundPool } 308 * @syscap SystemCapability.Multimedia.Media.SoundPool 309 * @since 10 310 */ 311 type SoundPool = _SoundPool; 312 313 /** 314 * Describes play parameters. 315 * 316 * @typedef { _PlayParameters } 317 * @syscap SystemCapability.Multimedia.Media.SoundPool 318 * @since 10 319 */ 320 type PlayParameters = _PlayParameters; 321 322 /** 323 * Enumerates state change reason. 324 * 325 * @enum { number } 326 * @syscap SystemCapability.Multimedia.Media.Core 327 * @since 9 328 */ 329 /** 330 * Enumerates state change reason. 331 * 332 * @enum { number } 333 * @syscap SystemCapability.Multimedia.Media.Core 334 * @atomicservice 335 * @since 11 336 */ 337 /** 338 * Enumerates state change reason. 339 * 340 * @enum { number } 341 * @syscap SystemCapability.Multimedia.Media.Core 342 * @crossplatform 343 * @atomicservice 344 * @since 12 345 */ 346 enum StateChangeReason { 347 /** 348 * State changed by user operation. 349 * @syscap SystemCapability.Multimedia.Media.Core 350 * @since 9 351 */ 352 /** 353 * State changed by user operation. 354 * @syscap SystemCapability.Multimedia.Media.Core 355 * @atomicservice 356 * @since 11 357 */ 358 /** 359 * State changed by user operation. 360 * @syscap SystemCapability.Multimedia.Media.Core 361 * @crossplatform 362 * @atomicservice 363 * @since 12 364 */ 365 USER = 1, 366 367 /** 368 * State changed by background action. 369 * @syscap SystemCapability.Multimedia.Media.Core 370 * @since 9 371 */ 372 /** 373 * State changed by background action. 374 * @syscap SystemCapability.Multimedia.Media.Core 375 * @atomicservice 376 * @since 11 377 */ 378 /** 379 * State changed by background action. 380 * @syscap SystemCapability.Multimedia.Media.Core 381 * @crossplatform 382 * @atomicservice 383 * @since 12 384 */ 385 BACKGROUND = 2, 386 } 387 388 /** 389 * Creates an AVMetadataExtractor instance. 390 * @returns { Promise<AVMetadataExtractor> } A Promise instance used to return AVMetadataExtractor instance 391 * if the operation is successful; returns null otherwise. 392 * @throws { BusinessError } 5400101 - No memory. Returned by promise. 393 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 394 * @since 11 395 */ 396 /** 397 * Creates an AVMetadataExtractor instance. 398 * @returns { Promise<AVMetadataExtractor> } A Promise instance used to return AVMetadataExtractor instance 399 * if the operation is successful; returns null otherwise. 400 * @throws { BusinessError } 5400101 - No memory. Returned by promise. 401 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 402 * @crossplatform 403 * @since 12 404 */ 405 function createAVMetadataExtractor(): Promise<AVMetadataExtractor>; 406 407 /** 408 * Creates an AVMetadataExtractor instance. 409 * @param { AsyncCallback<AVMetadataExtractor> } callback - Callback used to return AVMetadataExtractor instance 410 * if the operation is successful; returns null otherwise. 411 * @throws { BusinessError } 5400101 - No memory. Returned by callback. 412 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 413 * @since 11 414 */ 415 /** 416 * Creates an AVMetadataExtractor instance. 417 * @param { AsyncCallback<AVMetadataExtractor> } callback - Callback used to return AVMetadataExtractor instance 418 * if the operation is successful; returns null otherwise. 419 * @throws { BusinessError } 5400101 - No memory. Returned by callback. 420 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 421 * @crossplatform 422 * @since 12 423 */ 424 function createAVMetadataExtractor(callback: AsyncCallback<AVMetadataExtractor>): void; 425 426 /** 427 * Creates an AVImageGenerator instance. 428 * @returns { Promise<AVImageGenerator> } A Promise instance used to return AVImageGenerator instance 429 * if the operation is successful; returns null otherwise. 430 * @throws { BusinessError } 5400101 - No memory. Returned by promise. 431 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 432 * @since 12 433 */ 434 function createAVImageGenerator(): Promise<AVImageGenerator>; 435 436 /** 437 * Creates an AVImageGenerator instance. 438 * @param { AsyncCallback<AVImageGenerator> } callback - Callback used to return AVImageGenerator instance 439 * if the operation is successful; returns null otherwise. 440 * @throws { BusinessError } 5400101 - No memory. Returned by callback. 441 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 442 * @since 12 443 */ 444 function createAVImageGenerator(callback: AsyncCallback<AVImageGenerator>): void; 445 446 /** 447 * Fetch media meta data or audio art picture from source. Before calling an AVMetadataExtractor method, 448 * you must use createAVMetadataExtractor() to create an AVMetadataExtractor instance. 449 * @typedef AVMetadataExtractor 450 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 451 * @since 11 452 */ 453 /** 454 * Fetch media meta data or audio art picture from source. Before calling an AVMetadataExtractor method, 455 * you must use createAVMetadataExtractor() to create an AVMetadataExtractor instance. 456 * @typedef AVMetadataExtractor 457 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 458 * @crossplatform 459 * @since 12 460 */ 461 interface AVMetadataExtractor { 462 /** 463 * Media file descriptor. 464 * @type { ?AVFileDescriptor } 465 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 466 * @since 11 467 */ 468 /** 469 * Media file descriptor. 470 * @type { ?AVFileDescriptor } 471 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 472 * @crossplatform 473 * @since 12 474 */ 475 fdSrc ?: AVFileDescriptor; 476 477 /** 478 * DataSource descriptor. 479 * @type { ?AVDataSrcDescriptor } 480 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 481 * @since 11 482 */ 483 /** 484 * DataSource descriptor. 485 * @type { ?AVDataSrcDescriptor } 486 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 487 * @crossplatform 488 * @since 12 489 */ 490 dataSrc ?: AVDataSrcDescriptor; 491 492 /** 493 * It will extract the resource to fetch media meta data info. 494 * @param { AsyncCallback<AVMetadata> } callback - A callback instance used to return when fetchMetadata completed. 495 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. 496 * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. 497 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 498 * @since 11 499 */ 500 /** 501 * It will extract the resource to fetch media meta data info. 502 * @param { AsyncCallback<AVMetadata> } callback - A callback instance used to return when fetchMetadata completed. 503 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. 504 * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. 505 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 506 * @crossplatform 507 * @since 12 508 */ 509 fetchMetadata(callback: AsyncCallback<AVMetadata>): void; 510 511 /** 512 * It will extract the resource to fetch media meta data info. 513 * @returns { Promise<AVMetadata> } A Promise instance used to return when fetchMetadata completed. 514 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 515 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 516 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 517 * @since 11 518 */ 519 /** 520 * It will extract the resource to fetch media meta data info. 521 * @returns { Promise<AVMetadata> } A Promise instance used to return when fetchMetadata completed. 522 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 523 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 524 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 525 * @crossplatform 526 * @since 12 527 */ 528 fetchMetadata(): Promise<AVMetadata>; 529 530 /** 531 * It will extract the audio resource to fetch an album cover. 532 * @param { AsyncCallback<image.PixelMap> } callback - A callback instance used 533 * to return when fetchAlbumCover completed. 534 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 535 * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. 536 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 537 * @since 11 538 */ 539 /** 540 * It will extract the audio resource to fetch an album cover. 541 * @param { AsyncCallback<image.PixelMap> } callback - A callback instance used 542 * to return when fetchAlbumCover completed. 543 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 544 * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. 545 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 546 * @crossplatform 547 * @since 12 548 */ 549 fetchAlbumCover(callback: AsyncCallback<image.PixelMap>): void; 550 551 /** 552 * It will extract the audio resource to fetch an album cover. 553 * @returns { Promise<image.PixelMap> } A Promise instance used to return when fetchAlbumCover completed. 554 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 555 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 556 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 557 * @since 11 558 */ 559 /** 560 * It will extract the audio resource to fetch an album cover. 561 * @returns { Promise<image.PixelMap> } A Promise instance used to return when fetchAlbumCover completed. 562 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 563 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 564 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 565 * @crossplatform 566 * @since 12 567 */ 568 fetchAlbumCover(): Promise<image.PixelMap>; 569 570 /** 571 * Get timestamp according to frame index. 572 * @param { number } index - Index of the frame. 573 * @returns { Promise<number> } A Promise instance used to return frame timestamp, in microseconds. 574 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 575 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 576 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 577 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 578 * @systemapi 579 * @since 12 580 */ 581 getTimeByFrameIndex(index: number): Promise<number>; 582 583 /** 584 * Get frame index according to the given timestamp. 585 * @param { number } timeUs - Timestamp of the frame, in microseconds. 586 * @returns { Promise<number> } A Promise instance used to return frame index. 587 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 588 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 589 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 590 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 591 * @systemapi 592 * @since 12 593 */ 594 getFrameIndexByTime(timeUs: number): Promise<number>; 595 596 /** 597 * Release resources used for AVMetadataExtractor. 598 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 599 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. 600 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 601 * @since 11 602 */ 603 /** 604 * Release resources used for AVMetadataExtractor. 605 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 606 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. 607 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 608 * @crossplatform 609 * @since 12 610 */ 611 release(callback: AsyncCallback<void>): void; 612 613 /** 614 * Release resources used for AVMetadataExtractor. 615 * @returns { Promise<void> } A Promise instance used to return when release completed. 616 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 617 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 618 * @since 11 619 */ 620 /** 621 * Release resources used for AVMetadataExtractor. 622 * @returns { Promise<void> } A Promise instance used to return when release completed. 623 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 624 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 625 * @crossplatform 626 * @since 12 627 */ 628 release(): Promise<void>; 629 } 630 631 /** 632 * Provides the container definition for media meta data. 633 * @typedef AVMetadata 634 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 635 * @since 11 636 */ 637 /** 638 * Provides the container definition for media meta data. 639 * @typedef AVMetadata 640 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 641 * @crossplatform 642 * @since 12 643 */ 644 interface AVMetadata { 645 /** 646 * The metadata to retrieve the information about the album title 647 * of the media source. 648 * @type { ?string } 649 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 650 * @since 11 651 */ 652 /** 653 * The metadata to retrieve the information about the album title 654 * of the media source. This field is readonly in current version. 655 * @type { ?string } 656 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 657 * @crossplatform 658 * @since 12 659 */ 660 album?: string; 661 662 /** 663 * The metadata to retrieve the information about the performer or 664 * artist associated with the media source. 665 * @type { ?string } 666 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 667 * @since 11 668 */ 669 /** 670 * The metadata to retrieve the information about the performer or 671 * artist associated with the media source. This field is readonly in current version. 672 * @type { ?string } 673 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 674 * @crossplatform 675 * @since 12 676 */ 677 albumArtist?: string; 678 679 /** 680 * The metadata to retrieve the information about the artist of 681 * the media source. 682 * @type { ?string } 683 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 684 * @since 11 685 */ 686 /** 687 * The metadata to retrieve the information about the artist of 688 * the media source. This field is readonly in current version. 689 * @type { ?string } 690 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 691 * @crossplatform 692 * @since 12 693 */ 694 artist?: string; 695 696 /** 697 * The metadata to retrieve the information about the author of 698 * the media source. 699 * @type { ?string } 700 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 701 * @since 11 702 */ 703 /** 704 * The metadata to retrieve the information about the author of 705 * the media source. This field is readonly in current version. 706 * @type { ?string } 707 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 708 * @crossplatform 709 * @since 12 710 */ 711 author?: string; 712 713 /** 714 * The metadata to retrieve the information about the created time of 715 * the media source. 716 * @type { ?string } 717 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 718 * @since 11 719 */ 720 /** 721 * The metadata to retrieve the information about the created time of 722 * the media source. This field is readonly in current version. 723 * @type { ?string } 724 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 725 * @crossplatform 726 * @since 12 727 */ 728 dateTime?: string; 729 730 /** 731 * The metadata to retrieve the information about the created or modified time 732 * with the specific date format of the media source. 733 * @type { ?string } 734 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 735 * @since 11 736 */ 737 /** 738 * The metadata to retrieve the information about the created or modified time 739 * with the specific date format of the media source. This field is readonly in current version. 740 * @type { ?string } 741 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 742 * @crossplatform 743 * @since 12 744 */ 745 dateTimeFormat?: string; 746 747 /** 748 * The metadata to retrieve the information about the composer of 749 * the media source. 750 * @type { ?string } 751 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 752 * @since 11 753 */ 754 /** 755 * The metadata to retrieve the information about the composer of 756 * the media source. This field is readonly in current version. 757 * @type { ?string } 758 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 759 * @crossplatform 760 * @since 12 761 */ 762 composer?: string; 763 764 /** 765 * The metadata to retrieve the playback duration of the media source. 766 * @type { ?string } 767 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 768 * @since 11 769 */ 770 /** 771 * The metadata to retrieve the playback duration of the media source. This field is readonly in current version. 772 * @type { ?string } 773 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 774 * @crossplatform 775 * @since 12 776 */ 777 duration?: string; 778 779 /** 780 * The metadata to retrieve the content type or genre of the data 781 * source. 782 * @type { ?string } 783 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 784 * @since 11 785 */ 786 /** 787 * The metadata to retrieve the content type or genre of the data 788 * source. 789 * @type { ?string } 790 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 791 * @crossplatform 792 * @since 12 793 */ 794 genre?: string; 795 796 /** 797 * If this value exists the media contains audio content. 798 * @type { ?string } 799 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 800 * @since 11 801 */ 802 /** 803 * If this value exists the media contains audio content. This field is readonly in current version. 804 * @type { ?string } 805 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 806 * @crossplatform 807 * @since 12 808 */ 809 hasAudio?: string; 810 811 /** 812 * If this value exists the media contains video content. 813 * @type { ?string } 814 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 815 * @since 11 816 */ 817 /** 818 * If this value exists the media contains video content. This field is readonly in current version. 819 * @type { ?string } 820 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 821 * @crossplatform 822 * @since 12 823 */ 824 hasVideo?: string; 825 826 /** 827 * The metadata to retrieve the mime type of the media source. Some 828 * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb", 829 * @type { ?string } 830 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 831 * @since 11 832 */ 833 /** 834 * The metadata to retrieve the mime type of the media source. Some 835 * example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb". This field is readonly in current version. 836 * @type { ?string } 837 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 838 * @crossplatform 839 * @since 12 840 */ 841 mimeType?: string; 842 843 /** 844 * The metadata to retrieve the number of tracks, such as audio, video, 845 * text, in the media source, such as a mp4 or 3gpp file. 846 * @type { ?string } 847 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 848 * @since 11 849 */ 850 /** 851 * The metadata to retrieve the number of tracks, such as audio, video, 852 * text, in the media source, such as a mp4 or 3gpp file. This field is readonly in current version. 853 * @type { ?string } 854 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 855 * @crossplatform 856 * @since 12 857 */ 858 trackCount?: string; 859 860 /** 861 * It is the audio sample rate, if available. 862 * @type { ?string } 863 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 864 * @since 11 865 */ 866 /** 867 * It is the audio sample rate, if available. This field is readonly in current version. 868 * @type { ?string } 869 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 870 * @crossplatform 871 * @since 12 872 */ 873 sampleRate?: string; 874 875 /** 876 * The metadata to retrieve the media source title. 877 * @type { ?string } 878 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 879 * @since 11 880 */ 881 /** 882 * The metadata to retrieve the media source title. This field is readonly in current version. 883 * @type { ?string } 884 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 885 * @crossplatform 886 * @since 12 887 */ 888 title?: string; 889 890 /** 891 * If the media contains video, this key retrieves its height. 892 * @type { ?string } 893 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 894 * @since 11 895 */ 896 /** 897 * If the media contains video, this key retrieves its height. This field is readonly in current version. 898 * @type { ?string } 899 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 900 * @crossplatform 901 * @since 12 902 */ 903 videoHeight?: string; 904 905 /** 906 * If the media contains video, this key retrieves its width. 907 * @type { ?string } 908 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 909 * @since 11 910 */ 911 /** 912 * If the media contains video, this key retrieves its width. This field is readonly in current version. 913 * @type { ?string } 914 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 915 * @crossplatform 916 * @since 12 917 */ 918 videoWidth?: string; 919 920 /** 921 * The metadata to retrieve the information about the video 922 * orientation. 923 * @type { ?string } 924 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 925 * @since 11 926 */ 927 /** 928 * The metadata to retrieve the information about the video 929 * orientation. 930 * @type { ?string } 931 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 932 * @crossplatform 933 * @since 12 934 */ 935 videoOrientation?: string; 936 937 /** 938 * This value exists if the video is HDR video.This field is readonly in current version. 939 * @type { ?HdrType } 940 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 941 * @crossplatform 942 * @since 12 943 */ 944 hdrType?: HdrType; 945 946 /** 947 * The geographical location info of the video. 948 * @type { ?Location } 949 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 950 * @since 12 951 */ 952 location?: Location; 953 954 /** 955 * Custom parameter key-value map read from moov.meta.list. 956 * @type { ?Record<string, string> } 957 * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor 958 * @since 12 959 */ 960 customInfo?: Record<string, string>; 961 } 962 963 /** 964 * Enumerates options about the HDR Type of the video. 965 * @enum { number } 966 * @syscap SystemCapability.Multimedia.Media.Core 967 * @crossplatform 968 * @since 12 969 */ 970 enum HdrType { 971 /** 972 * This option is used to mark none HDR type. 973 * @syscap SystemCapability.Multimedia.Media.Core 974 * @crossplatform 975 * @since 12 976 */ 977 AV_HDR_TYPE_NONE = 0, 978 979 /** 980 * This option is used to mark HDR Vivid type. 981 * @syscap SystemCapability.Multimedia.Media.Core 982 * @crossplatform 983 * @since 12 984 */ 985 AV_HDR_TYPE_VIVID = 1, 986 } 987 988 /** 989 * Generate an image from a video resource with the specific time. Before calling an AVImageGenerator method, 990 * you must use createAVImageGenerator() to create an AVImageGenerator instance. 991 * @typedef AVImageGenerator 992 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 993 * @since 12 994 */ 995 interface AVImageGenerator { 996 /** 997 * Media file descriptor. 998 * @type { ?AVFileDescriptor } 999 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1000 * @since 12 1001 */ 1002 fdSrc ?: AVFileDescriptor; 1003 1004 /** 1005 * It will fetch a picture at @timeUs from the given video resource. 1006 * @param { number } timeUs - The time expected to fetch picture from the video resource. 1007 * The unit is microsecond(us). 1008 * @param { AVImageQueryOptions } options - The time options about the relationship 1009 * between the given timeUs and a key frame, see @AVImageQueryOptions . 1010 * @param { PixelMapParams } param - The output pixel map format params, see @PixelMapParams . 1011 * @param { AsyncCallback<image.PixelMap> } callback - A callback instance used 1012 * to return when fetchFrameByTime completed. 1013 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. 1014 * @throws { BusinessError } 5400106 - Unsupported format. Returned by callback. 1015 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1016 * @since 12 1017 */ 1018 fetchFrameByTime(timeUs: number, options: AVImageQueryOptions, param: PixelMapParams, 1019 callback: AsyncCallback<image.PixelMap>): void; 1020 1021 /** 1022 * It will decode the given video resource. Then fetch a picture 1023 * at @timeUs according the given @options and @param . 1024 * @param { number } timeUs - The time expected to fetch picture from the video resource. 1025 * The unit is microsecond(us). 1026 * @param { AVImageQueryOptions } options - The time options about the relationship 1027 * between the given timeUs and a key frame, see @AVImageQueryOptions . 1028 * @param { PixelMapParams } param - The output pixel map format params, see @PixelMapParams . 1029 * @returns { Promise<image.PixelMap> } A Promise instance used to return the pixel map 1030 * when fetchFrameByTime completed. 1031 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 1032 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 1033 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1034 * @since 12 1035 */ 1036 fetchFrameByTime(timeUs: number, options: AVImageQueryOptions, param: PixelMapParams): Promise<image.PixelMap>; 1037 1038 /** 1039 * Release resources used for AVImageGenerator. 1040 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 1041 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by callback. 1042 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1043 * @since 12 1044 */ 1045 release(callback: AsyncCallback<void>): void; 1046 1047 /** 1048 * Release resources used for AVImageGenerator. 1049 * @returns { Promise<void> } A Promise instance used to return when release completed. 1050 * @throws { BusinessError } 5400102 - Operation not allowed. Returned by promise. 1051 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1052 * @since 12 1053 */ 1054 release(): Promise<void>; 1055 } 1056 1057 /** 1058 * Enumerates options about the relationship between the given timeUs and a key frame. 1059 * @enum { number } 1060 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1061 * @since 12 1062 */ 1063 enum AVImageQueryOptions { 1064 /** 1065 * This option is used to fetch a key frame from the given media 1066 * resource that is located right after or at the given time. 1067 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1068 * @since 12 1069 */ 1070 AV_IMAGE_QUERY_NEXT_SYNC, 1071 1072 /** 1073 * This option is used to fetch a key frame from the given media 1074 * resource that is located right before or at the given time. 1075 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1076 * @since 12 1077 */ 1078 AV_IMAGE_QUERY_PREVIOUS_SYNC, 1079 1080 /** 1081 * This option is used to fetch a key frame from the given media 1082 * resource that is located closest to or at the given time. 1083 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1084 * @since 12 1085 */ 1086 AV_IMAGE_QUERY_CLOSEST_SYNC, 1087 1088 /** 1089 * This option is used to fetch a frame (maybe not keyframe) from 1090 * the given media resource that is located closest to or at the given time. 1091 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1092 * @since 12 1093 */ 1094 AV_IMAGE_QUERY_CLOSEST, 1095 } 1096 1097 /** 1098 * Expected pixel map format for the fetched image from video resource. 1099 * @typedef PixelMapParams 1100 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1101 * @since 12 1102 */ 1103 interface PixelMapParams { 1104 /** 1105 * Expected pixelmap's width, -1 means to keep consistent with the 1106 * original dimensions of the given video resource. 1107 * @type { ?number } 1108 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1109 * @since 12 1110 */ 1111 width?: number; 1112 1113 /** 1114 * Expected pixelmap's width, -1 means to keep consistent with the 1115 * original dimensions of the given video resource. 1116 * @type { ?number } 1117 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1118 * @since 12 1119 */ 1120 height?: number; 1121 1122 /** 1123 * Expected pixelmap's color format, see {@link PixelFormat}. 1124 * @type { ?PixelFormat } 1125 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1126 * @systemapi 1127 * @since 11 1128 */ 1129 colorFormat?: PixelFormat; 1130 } 1131 1132 /** 1133 * Enumerates options about the expected color options for the fetched image. 1134 * @enum { number } 1135 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1136 * @systemapi 1137 * @since 11 1138 */ 1139 enum PixelFormat { 1140 /** 1141 * RGB_565 options. 1142 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1143 * @systemapi 1144 * @since 11 1145 */ 1146 RGB_565 = 2, 1147 1148 /** 1149 * RGBA_8888 options. 1150 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1151 * @systemapi 1152 * @since 11 1153 */ 1154 RGBA_8888 = 3, 1155 1156 /** 1157 * RGB_888 options. 1158 * @syscap SystemCapability.Multimedia.Media.AVImageGenerator 1159 * @systemapi 1160 * @since 11 1161 */ 1162 RGB_888 = 5, 1163 } 1164 1165 /** 1166 * Enumerates ErrorCode types, return in BusinessError::code. 1167 * 1168 * @enum { number } 1169 * @syscap SystemCapability.Multimedia.Media.Core 1170 * @since 9 1171 */ 1172 /** 1173 * Enumerates ErrorCode types, return in BusinessError::code. 1174 * 1175 * @enum { number } 1176 * @syscap SystemCapability.Multimedia.Media.Core 1177 * @atomicservice 1178 * @since 11 1179 */ 1180 /** 1181 * Enumerates ErrorCode types, return in BusinessError::code. 1182 * 1183 * @enum { number } 1184 * @syscap SystemCapability.Multimedia.Media.Core 1185 * @crossplatform 1186 * @atomicservice 1187 * @since 12 1188 */ 1189 enum AVErrorCode { 1190 /** 1191 * Operation success. 1192 * @syscap SystemCapability.Multimedia.Media.Core 1193 * @since 9 1194 */ 1195 /** 1196 * Operation success. 1197 * @syscap SystemCapability.Multimedia.Media.Core 1198 * @atomicservice 1199 * @since 11 1200 */ 1201 /** 1202 * Operation success. 1203 * @syscap SystemCapability.Multimedia.Media.Core 1204 * @crossplatform 1205 * @atomicservice 1206 * @since 12 1207 */ 1208 AVERR_OK = 0, 1209 1210 /** 1211 * Permission denied. 1212 * @syscap SystemCapability.Multimedia.Media.Core 1213 * @since 9 1214 */ 1215 /** 1216 * Permission denied. 1217 * @syscap SystemCapability.Multimedia.Media.Core 1218 * @atomicservice 1219 * @since 11 1220 */ 1221 /** 1222 * Permission denied. 1223 * @syscap SystemCapability.Multimedia.Media.Core 1224 * @crossplatform 1225 * @atomicservice 1226 * @since 12 1227 */ 1228 AVERR_NO_PERMISSION = 201, 1229 1230 /** 1231 * Invalid parameter. 1232 * @syscap SystemCapability.Multimedia.Media.Core 1233 * @since 9 1234 */ 1235 /** 1236 * Invalid parameter. 1237 * @syscap SystemCapability.Multimedia.Media.Core 1238 * @atomicservice 1239 * @since 11 1240 */ 1241 /** 1242 * Invalid parameter. 1243 * @syscap SystemCapability.Multimedia.Media.Core 1244 * @crossplatform 1245 * @atomicservice 1246 * @since 12 1247 */ 1248 AVERR_INVALID_PARAMETER = 401, 1249 1250 /** 1251 * The api is not supported in the current version. 1252 * @syscap SystemCapability.Multimedia.Media.Core 1253 * @since 9 1254 */ 1255 /** 1256 * The api is not supported in the current version. 1257 * @syscap SystemCapability.Multimedia.Media.Core 1258 * @atomicservice 1259 * @since 11 1260 */ 1261 /** 1262 * The api is not supported in the current version. 1263 * @syscap SystemCapability.Multimedia.Media.Core 1264 * @crossplatform 1265 * @atomicservice 1266 * @since 12 1267 */ 1268 AVERR_UNSUPPORT_CAPABILITY = 801, 1269 1270 /** 1271 * The system memory is insufficient or the number of services reaches the upper limit. 1272 * @syscap SystemCapability.Multimedia.Media.Core 1273 * @since 9 1274 */ 1275 /** 1276 * The system memory is insufficient or the number of services reaches the upper limit. 1277 * @syscap SystemCapability.Multimedia.Media.Core 1278 * @atomicservice 1279 * @since 11 1280 */ 1281 /** 1282 * The system memory is insufficient or the number of services reaches the upper limit. 1283 * @syscap SystemCapability.Multimedia.Media.Core 1284 * @crossplatform 1285 * @atomicservice 1286 * @since 12 1287 */ 1288 AVERR_NO_MEMORY = 5400101, 1289 1290 /** 1291 * Current status does not allow or do not have permission to perform this operation. 1292 * @syscap SystemCapability.Multimedia.Media.Core 1293 * @since 9 1294 */ 1295 /** 1296 * Current status does not allow or do not have permission to perform this operation. 1297 * @syscap SystemCapability.Multimedia.Media.Core 1298 * @atomicservice 1299 * @since 11 1300 */ 1301 /** 1302 * Current status does not allow or do not have permission to perform this operation. 1303 * @syscap SystemCapability.Multimedia.Media.Core 1304 * @crossplatform 1305 * @atomicservice 1306 * @since 12 1307 */ 1308 AVERR_OPERATE_NOT_PERMIT = 5400102, 1309 1310 /** 1311 * Data flow exception information. 1312 * @syscap SystemCapability.Multimedia.Media.Core 1313 * @since 9 1314 */ 1315 /** 1316 * Data flow exception information. 1317 * @syscap SystemCapability.Multimedia.Media.Core 1318 * @atomicservice 1319 * @since 11 1320 */ 1321 /** 1322 * Data flow exception information. 1323 * @syscap SystemCapability.Multimedia.Media.Core 1324 * @crossplatform 1325 * @atomicservice 1326 * @since 12 1327 */ 1328 AVERR_IO = 5400103, 1329 1330 /** 1331 * System or network response timeout. 1332 * @syscap SystemCapability.Multimedia.Media.Core 1333 * @since 9 1334 */ 1335 /** 1336 * System or network response timeout. 1337 * @syscap SystemCapability.Multimedia.Media.Core 1338 * @atomicservice 1339 * @since 11 1340 */ 1341 /** 1342 * System or network response timeout. 1343 * @syscap SystemCapability.Multimedia.Media.Core 1344 * @crossplatform 1345 * @atomicservice 1346 * @since 12 1347 */ 1348 AVERR_TIMEOUT = 5400104, 1349 1350 /** 1351 * Service process died. 1352 * @syscap SystemCapability.Multimedia.Media.Core 1353 * @since 9 1354 */ 1355 /** 1356 * Service process died. 1357 * @syscap SystemCapability.Multimedia.Media.Core 1358 * @atomicservice 1359 * @since 11 1360 */ 1361 /** 1362 * Service process died. 1363 * @syscap SystemCapability.Multimedia.Media.Core 1364 * @crossplatform 1365 * @atomicservice 1366 * @since 12 1367 */ 1368 AVERR_SERVICE_DIED = 5400105, 1369 1370 /** 1371 * Unsupported media format. 1372 * @syscap SystemCapability.Multimedia.Media.Core 1373 * @since 9 1374 */ 1375 /** 1376 * Unsupported media format. 1377 * @syscap SystemCapability.Multimedia.Media.Core 1378 * @atomicservice 1379 * @since 11 1380 */ 1381 /** 1382 * Unsupported media format. 1383 * @syscap SystemCapability.Multimedia.Media.Core 1384 * @crossplatform 1385 * @atomicservice 1386 * @since 12 1387 */ 1388 AVERR_UNSUPPORT_FORMAT = 5400106, 1389 1390 /** 1391 * Audio interrupted. 1392 * @syscap SystemCapability.Multimedia.Media.Core 1393 * @atomicservice 1394 * @since 11 1395 */ 1396 /** 1397 * Audio interrupted. 1398 * @syscap SystemCapability.Multimedia.Media.Core 1399 * @crossplatform 1400 * @atomicservice 1401 * @since 12 1402 */ 1403 AVERR_AUDIO_INTERRUPTED = 5400107, 1404 /** 1405 * The address of server is incorrect, and IO can not find host. 1406 * @syscap SystemCapability.Multimedia.Media.Core 1407 * @crossplatform 1408 * @atomicservice 1409 * @since 14 1410 */ 1411 AVERR_IO_HOST_NOT_FOUND = 5411001, 1412 /** 1413 * Network connection timeout. 1414 * @syscap SystemCapability.Multimedia.Media.Core 1415 * @crossplatform 1416 * @atomicservice 1417 * @since 14 1418 */ 1419 AVERR_IO_CONNECTION_TIMEOUT = 5411002, 1420 /** 1421 * Failed link due to abnormal network. 1422 * @syscap SystemCapability.Multimedia.Media.Core 1423 * @crossplatform 1424 * @atomicservice 1425 * @since 14 1426 */ 1427 AVERR_IO_NETWORK_ABNORMAL = 5411003, 1428 /** 1429 * Failed link due to unavailable network. 1430 * @syscap SystemCapability.Multimedia.Media.Core 1431 * @crossplatform 1432 * @atomicservice 1433 * @since 14 1434 */ 1435 AVERR_IO_NETWORK_UNAVAILABLE = 5411004, 1436 /** 1437 * Network permission dennied. 1438 * @syscap SystemCapability.Multimedia.Media.Core 1439 * @crossplatform 1440 * @atomicservice 1441 * @since 14 1442 */ 1443 AVERR_IO_NO_PERMISSION = 5411005, 1444 /** 1445 * The client request parameters are incorrect or exceed the processing capacity. 1446 * @syscap SystemCapability.Multimedia.Media.Core 1447 * @crossplatform 1448 * @atomicservice 1449 * @since 14 1450 */ 1451 AVERR_IO_REQUEST_DENIED = 5411006, 1452 /** 1453 * Cannot find available network resources. 1454 * @syscap SystemCapability.Multimedia.Media.Core 1455 * @crossplatform 1456 * @atomicservice 1457 * @since 14 1458 */ 1459 AVERR_IO_RESOURCE_NOT_FOUND = 5411007, 1460 /** 1461 * The server failS to verify the client certificate because the certificate is not carried, 1462 * the certificate is invalid, or the certificate is expired. 1463 * @syscap SystemCapability.Multimedia.Media.Core 1464 * @crossplatform 1465 * @atomicservice 1466 * @since 14 1467 */ 1468 AVERR_IO_SSL_CLIENT_CERT_NEEDED = 5411008, 1469 /** 1470 * The client fails to verify the server certificate because the certificate is not carried, 1471 * the certificate is invalid, or the certificate is expired. 1472 * @syscap SystemCapability.Multimedia.Media.Core 1473 * @crossplatform 1474 * @atomicservice 1475 * @since 14 1476 */ 1477 AVERR_IO_SSL_CONNECTION_FAILED = 5411009, 1478 /** 1479 * IO SSL server cert untrusted. 1480 * @syscap SystemCapability.Multimedia.Media.Core 1481 * @crossplatform 1482 * @atomicservice 1483 * @since 14 1484 */ 1485 AVERR_IO_SSL_SERVER_CERT_UNTRUSTED = 5411010, 1486 /** 1487 * Unsupported request due to network protocols. 1488 * @syscap SystemCapability.Multimedia.Media.Core 1489 * @crossplatform 1490 * @atomicservice 1491 * @since 14 1492 */ 1493 AVERR_IO_UNSUPPORTED_REQUEST = 5411011, 1494 /** 1495 * The file data is incorrect, and no specific data can be provided. 1496 * @syscap SystemCapability.Multimedia.Media.Core 1497 * @crossplatform 1498 * @atomicservice 1499 * @since 14 1500 */ 1501 AVERR_IO_DATA_ABNORMAL = 5411012, 1502 /** 1503 * The file is occupied by other processes and cannot be accessed. 1504 * @syscap SystemCapability.Multimedia.Media.Core 1505 * @crossplatform 1506 * @atomicservice 1507 * @since 14 1508 */ 1509 AVERR_IO_FILE_ACCESS_DENIED = 5411013, 1510 /** 1511 * The file handle is incorrect. 1512 * @syscap SystemCapability.Multimedia.Media.Core 1513 * @crossplatform 1514 * @atomicservice 1515 * @since 14 1516 */ 1517 AVERR_IO_FILE_BAD_HANDLE = 5411014, 1518 /** 1519 * IO file not found. 1520 * @syscap SystemCapability.Multimedia.Media.Core 1521 * @crossplatform 1522 * @atomicservice 1523 * @since 14 1524 */ 1525 AVERR_IO_FILE_NOT_FOUND = 5411015, 1526 /** 1527 * IO file permission denied because API does not have permissions. 1528 * @syscap SystemCapability.Multimedia.Media.Core 1529 * @crossplatform 1530 * @atomicservice 1531 * @since 14 1532 */ 1533 AVERR_IO_FILE_PERMISSION_DENIED = 5411016, 1534 /** 1535 * Failed to decode the audio data. 1536 * @syscap SystemCapability.Multimedia.Media.Core 1537 * @crossplatform 1538 * @atomicservice 1539 * @since 14 1540 */ 1541 AVERR_IO_AUDIO_DEC_FAILED = 5411017, 1542 /** 1543 * Fail to init the audio decoder. 1544 * @syscap SystemCapability.Multimedia.Media.Core 1545 * @crossplatform 1546 * @atomicservice 1547 * @since 14 1548 */ 1549 AVERR_IO_AUDIO_DEC_INIT_FAILED = 5411018, 1550 /** 1551 * The audio decoder is unavailable for handler incurrupt, or audio decoder subsystem abnormal. 1552 * @syscap SystemCapability.Multimedia.Media.Core 1553 * @crossplatform 1554 * @atomicservice 1555 * @since 14 1556 */ 1557 AVERR_IO_AUDIO_DEC_UNAVAILABLE = 5411019, 1558 /** 1559 * Audio device error. 1560 * @syscap SystemCapability.Multimedia.Media.Core 1561 * @crossplatform 1562 * @atomicservice 1563 * @since 14 1564 */ 1565 AVERR_IO_AUDIO_DEVICE_ERROR = 5411020, 1566 /** 1567 * The audio device state does not support the current operation. 1568 * @syscap SystemCapability.Multimedia.Media.Core 1569 * @crossplatform 1570 * @atomicservice 1571 * @since 14 1572 */ 1573 AVERR_IO_AUDIO_DEVICE_INVALID_STATE = 5411021, 1574 /** 1575 * Audio device timeout when calling audio render interface. 1576 * @syscap SystemCapability.Multimedia.Media.Core 1577 * @crossplatform 1578 * @atomicservice 1579 * @since 14 1580 */ 1581 AVERR_IO_AUDIO_DEVICE_TIMEOUT = 5411022, 1582 /** 1583 * Audio device unavailable, unable to create an audio device. 1584 * @syscap SystemCapability.Multimedia.Media.Core 1585 * @crossplatform 1586 * @atomicservice 1587 * @since 14 1588 */ 1589 AVERR_IO_AUDIO_DEVICE_UNAVAILABLE = 5411023, 1590 /** 1591 * Failed to encode the audio data. 1592 * @syscap SystemCapability.Multimedia.Media.Core 1593 * @crossplatform 1594 * @atomicservice 1595 * @since 14 1596 */ 1597 AVERR_IO_AUDIO_ENC_FAILED = 5411024, 1598 /** 1599 * Fail to init the audio encoder. 1600 * @syscap SystemCapability.Multimedia.Media.Core 1601 * @crossplatform 1602 * @atomicservice 1603 * @since 14 1604 */ 1605 AVERR_IO_AUDIO_ENC_INIT_FAILED = 5411025, 1606 /** 1607 * The audio encoder is unavailable for handler incurrupt, or audio encoder subsystem abnormal. 1608 * @syscap SystemCapability.Multimedia.Media.Core 1609 * @crossplatform 1610 * @atomicservice 1611 * @since 14 1612 */ 1613 AVERR_IO_AUDIO_ENC_UNAVAILABLE = 5411026, 1614 /** 1615 * Failed to decode the video data. 1616 * @syscap SystemCapability.Multimedia.Media.Core 1617 * @crossplatform 1618 * @atomicservice 1619 * @since 14 1620 */ 1621 AVERR_IO_VIDEO_DEC_FAILED = 5411027, 1622 /** 1623 * Fail to init the video decoder. 1624 * @syscap SystemCapability.Multimedia.Media.Core 1625 * @crossplatform 1626 * @atomicservice 1627 * @since 14 1628 */ 1629 AVERR_IO_VIDEO_DEC_INIT_FAILED = 5411028, 1630 /** 1631 * The video decoder is unavailable for handler incurrupt, or video decoder subsystem abnormal. 1632 * @syscap SystemCapability.Multimedia.Media.Core 1633 * @crossplatform 1634 * @atomicservice 1635 * @since 14 1636 */ 1637 AVERR_IO_VIDEO_DEC_UNAVAILABLE = 5411029, 1638 /** 1639 * Video device error. 1640 * @syscap SystemCapability.Multimedia.Media.Core 1641 * @crossplatform 1642 * @atomicservice 1643 * @since 14 1644 */ 1645 AVERR_IO_VIDEO_DEVICE_ERROR = 5411030, 1646 /** 1647 * Failed to encode the video data. 1648 * @syscap SystemCapability.Multimedia.Media.Core 1649 * @crossplatform 1650 * @atomicservice 1651 * @since 14 1652 */ 1653 AVERR_IO_VIDEO_ENC_FAILED = 5411031, 1654 /** 1655 * Failed to init the video encoder. 1656 * @syscap SystemCapability.Multimedia.Media.Core 1657 * @crossplatform 1658 * @atomicservice 1659 * @since 14 1660 */ 1661 AVERR_IO_VIDEO_ENC_INIT_FAILED = 5411032, 1662 /** 1663 * The video encoder is unavailable for handler incurrupt, or video encoder subsystem abnormal. 1664 * @syscap SystemCapability.Multimedia.Media.Core 1665 * @crossplatform 1666 * @atomicservice 1667 * @since 14 1668 */ 1669 AVERR_IO_VIDEO_ENC_UNAVAILABLE = 5411033, 1670 } 1671 1672 /** 1673 * Describes AVPlayer states. 1674 * @typedef {'idle' | 'initialized' | 'prepared' | 'playing' | 'paused' | 'completed' | 'stopped' | 'released' | 'error'} 1675 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1676 * @since 9 1677 1678 */ 1679 /** 1680 * Describes AVPlayer states. 1681 * @typedef {'idle' | 'initialized' | 'prepared' | 'playing' | 'paused' | 'completed' | 'stopped' | 'released' | 'error'} 1682 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1683 * @atomicservice 1684 * @since 11 1685 1686 */ 1687 /** 1688 * Describes AVPlayer states. 1689 * @typedef {'idle' | 'initialized' | 'prepared' | 'playing' | 'paused' | 'completed' | 'stopped' | 'released' | 'error'} 1690 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1691 * @crossplatform 1692 * @atomicservice 1693 * @since 12 1694 */ 1695 type AVPlayerState = 'idle' | 'initialized' | 'prepared' | 'playing' | 'paused' | 'completed' | 'stopped' | 'released' | 'error'; 1696 1697 /** 1698 * Define the TrackChange Event callback. 1699 * @typedef { function } OnTrackChangeHandler 1700 * @param { number } index - index number for change Track. 1701 * @param { boolean } isSelected - Target index number for moving elements. 1702 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1703 * @atomicservice 1704 * @since 12 1705 */ 1706 type OnTrackChangeHandler = (index: number, isSelected: boolean) => void; 1707 1708 /** 1709 * Defines the OnStateChange callback. 1710 * 1711 * @typedef { function } OnAVPlayerStateChangeHandle 1712 * @param { AVPlayerState } state - state for AVPlayer. 1713 * @param { StateChangeReason } reason - reason for state change. 1714 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1715 * @crossplatform 1716 * @atomicservice 1717 * @since 12 1718 */ 1719 type OnAVPlayerStateChangeHandle = (state: AVPlayerState, reason: StateChangeReason) => void; 1720 1721 /** 1722 * Defines the OnBufferingUpdateHandler callback. 1723 * 1724 * @typedef { function } OnBufferingUpdateHandler 1725 * @param { BufferingInfoType } infoType - define the Buffering info Type. 1726 * @param { number } value - define the value of buffering info type if exist. 1727 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1728 * @crossplatform 1729 * @atomicservice 1730 * @since 12 1731 */ 1732 type OnBufferingUpdateHandler = (infoType: BufferingInfoType, value: number) => void; 1733 1734 /** 1735 * Defines the OnVideoSizeChangeHandler callback. 1736 * 1737 * @typedef { function } OnVideoSizeChangeHandler 1738 * @param { number } width - Value of video Width. 1739 * @param { number } height - Value of video Height. 1740 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1741 * @crossplatform 1742 * @atomicservice 1743 * @since 12 1744 */ 1745 type OnVideoSizeChangeHandler = (width: number, height: number) => void; 1746 1747 /** 1748 * Manages and plays media. Before calling an AVPlayer method, you must use createAVPlayer() 1749 * to create an AVPlayer instance. 1750 * 1751 * @typedef AVPlayer 1752 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1753 * @since 9 1754 */ 1755 /** 1756 * Manages and plays media. Before calling an AVPlayer method, you must use createAVPlayer() 1757 * to create an AVPlayer instance. 1758 * 1759 * @typedef AVPlayer 1760 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1761 * @atomicservice 1762 * @since 11 1763 */ 1764 /** 1765 * Manages and plays media. Before calling an AVPlayer method, you must use createAVPlayer() 1766 * to create an AVPlayer instance. 1767 * 1768 * @typedef AVPlayer 1769 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1770 * @crossplatform 1771 * @atomicservice 1772 * @since 12 1773 */ 1774 interface AVPlayer { 1775 /** 1776 * Prepare audio/video playback, it will request resource for playing. 1777 * @param { AsyncCallback<void> } callback - instance used to return when prepare completed. 1778 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1779 * @throws { BusinessError } 5400106 - Unsupported format. Return by callback. 1780 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1781 * @since 9 1782 */ 1783 /** 1784 * Prepare audio/video playback, it will request resource for playing. 1785 * @param { AsyncCallback<void> } callback - instance used to return when prepare completed. 1786 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1787 * @throws { BusinessError } 5400106 - Unsupported format. Return by callback. 1788 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1789 * @atomicservice 1790 * @since 11 1791 */ 1792 /** 1793 * Prepare audio/video playback, it will request resource for playing. 1794 * @param { AsyncCallback<void> } callback - instance used to return when prepare completed. 1795 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1796 * @throws { BusinessError } 5400106 - Unsupport format. Return by callback. 1797 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1798 * @crossplatform 1799 * @atomicservice 1800 * @since 12 1801 */ 1802 prepare(callback: AsyncCallback<void>): void; 1803 1804 /** 1805 * Prepare audio/video playback, it will request resource for playing. 1806 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 1807 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1808 * @throws { BusinessError } 5400106 - Unsupported format. Return by promise. 1809 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1810 * @since 9 1811 */ 1812 /** 1813 * Prepare audio/video playback, it will request resource for playing. 1814 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 1815 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1816 * @throws { BusinessError } 5400106 - Unsupported format. Return by promise. 1817 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1818 * @atomicservice 1819 * @since 11 1820 */ 1821 /** 1822 * Prepare audio/video playback, it will request resource for playing. 1823 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 1824 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1825 * @throws { BusinessError } 5400106 - Unsupport format. Return by promise. 1826 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1827 * @crossplatform 1828 * @atomicservice 1829 * @since 12 1830 */ 1831 prepare(): Promise<void>; 1832 1833 /** 1834 * Play audio/video playback. 1835 * @param { AsyncCallback<void> } callback - instance used to return when play completed. 1836 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1837 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1838 * @since 9 1839 */ 1840 /** 1841 * Play audio/video playback. 1842 * @param { AsyncCallback<void> } callback - instance used to return when play completed. 1843 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1844 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1845 * @atomicservice 1846 * @since 11 1847 */ 1848 /** 1849 * Play audio/video playback. 1850 * @param { AsyncCallback<void> } callback - instance used to return when play completed. 1851 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1852 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1853 * @crossplatform 1854 * @atomicservice 1855 * @since 12 1856 */ 1857 play(callback: AsyncCallback<void>): void; 1858 1859 /** 1860 * Play audio/video playback. 1861 * @returns { Promise<void> } A Promise instance used to return when play completed. 1862 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1863 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1864 * @since 9 1865 */ 1866 /** 1867 * Play audio/video playback. 1868 * @returns { Promise<void> } A Promise instance used to return when play completed. 1869 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1870 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1871 * @atomicservice 1872 * @since 11 1873 */ 1874 /** 1875 * Play audio/video playback. 1876 * @returns { Promise<void> } A Promise instance used to return when play completed. 1877 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1878 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1879 * @crossplatform 1880 * @atomicservice 1881 * @since 12 1882 */ 1883 play(): Promise<void>; 1884 1885 /** 1886 * Pause audio/video playback. 1887 * @param { AsyncCallback<void> } callback - instance used to return when pause completed. 1888 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1889 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1890 * @since 9 1891 */ 1892 /** 1893 * Pause audio/video playback. 1894 * @param { AsyncCallback<void> } callback - instance used to return when pause completed. 1895 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1896 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1897 * @atomicservice 1898 * @since 11 1899 */ 1900 /** 1901 * Pause audio/video playback. 1902 * @param { AsyncCallback<void> } callback - instance used to return when pause completed. 1903 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1904 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1905 * @crossplatform 1906 * @atomicservice 1907 * @since 12 1908 */ 1909 pause(callback: AsyncCallback<void>): void; 1910 1911 /** 1912 * Pause audio/video playback. 1913 * @returns { Promise<void> } A Promise instance used to return when pause completed. 1914 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1915 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1916 * @since 9 1917 */ 1918 /** 1919 * Pause audio/video playback. 1920 * @returns { Promise<void> } A Promise instance used to return when pause completed. 1921 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1922 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1923 * @atomicservice 1924 * @since 11 1925 */ 1926 /** 1927 * Pause audio/video playback. 1928 * @returns { Promise<void> } A Promise instance used to return when pause completed. 1929 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1930 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1931 * @crossplatform 1932 * @atomicservice 1933 * @since 12 1934 */ 1935 pause(): Promise<void>; 1936 1937 /** 1938 * Stop audio/video playback. 1939 * @param { AsyncCallback<void> } callback - instance used to return when stop completed. 1940 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1941 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1942 * @since 9 1943 */ 1944 /** 1945 * Stop audio/video playback. 1946 * @param { AsyncCallback<void> } callback - instance used to return when stop completed. 1947 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1948 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1949 * @atomicservice 1950 * @since 11 1951 */ 1952 /** 1953 * Stop audio/video playback. 1954 * @param { AsyncCallback<void> } callback - instance used to return when stop completed. 1955 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1956 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1957 * @crossplatform 1958 * @atomicservice 1959 * @since 12 1960 */ 1961 stop(callback: AsyncCallback<void>): void; 1962 1963 /** 1964 * Stop audio/video playback. 1965 * @returns { Promise<void> } A Promise instance used to return when stop completed. 1966 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1967 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1968 * @since 9 1969 */ 1970 /** 1971 * Stop audio/video playback. 1972 * @returns { Promise<void> } A Promise instance used to return when stop completed. 1973 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1974 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1975 * @atomicservice 1976 * @since 11 1977 */ 1978 /** 1979 * Stop audio/video playback. 1980 * @returns { Promise<void> } A Promise instance used to return when stop completed. 1981 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 1982 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1983 * @crossplatform 1984 * @atomicservice 1985 * @since 12 1986 */ 1987 stop(): Promise<void>; 1988 1989 /** 1990 * Reset AVPlayer, it will to idle state and can set src again. 1991 * @param { AsyncCallback<void> } callback - instance used to return when reset completed. 1992 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 1993 * @syscap SystemCapability.Multimedia.Media.AVPlayer 1994 * @since 9 1995 */ 1996 /** 1997 * Reset AVPlayer, it will to idle state and can set src again. 1998 * @param { AsyncCallback<void> } callback - instance used to return when reset completed. 1999 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2000 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2001 * @atomicservice 2002 * @since 11 2003 */ 2004 /** 2005 * Reset AVPlayer, it will to idle state and can set src again. 2006 * @param { AsyncCallback<void> } callback - instance used to return when reset completed. 2007 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2008 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2009 * @crossplatform 2010 * @atomicservice 2011 * @since 12 2012 */ 2013 reset(callback: AsyncCallback<void>): void; 2014 2015 /** 2016 * Reset AVPlayer, it will to idle state and can set src again. 2017 * @returns { Promise<void> } A Promise instance used to return when reset completed. 2018 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2019 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2020 * @since 9 2021 */ 2022 /** 2023 * Reset AVPlayer, it will to idle state and can set src again. 2024 * @returns { Promise<void> } A Promise instance used to return when reset completed. 2025 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2026 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2027 * @atomicservice 2028 * @since 11 2029 */ 2030 /** 2031 * Reset AVPlayer, it will to idle state and can set src again. 2032 * @returns { Promise<void> } A Promise instance used to return when reset completed. 2033 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2034 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2035 * @crossplatform 2036 * @atomicservice 2037 * @since 12 2038 */ 2039 reset(): Promise<void>; 2040 2041 /** 2042 * Releases resources used for AVPlayer. 2043 * @param { AsyncCallback<void> } callback - instance used to return when release completed. 2044 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2045 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2046 * @since 9 2047 */ 2048 /** 2049 * Releases resources used for AVPlayer. 2050 * @param { AsyncCallback<void> } callback - instance used to return when release completed. 2051 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2052 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2053 * @atomicservice 2054 * @since 11 2055 */ 2056 /** 2057 * Releases resources used for AVPlayer. 2058 * @param { AsyncCallback<void> } callback - instance used to return when release completed. 2059 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2060 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2061 * @crossplatform 2062 * @atomicservice 2063 * @since 12 2064 */ 2065 release(callback: AsyncCallback<void>): void; 2066 2067 /** 2068 * Releases resources used for AVPlayer. 2069 * @returns { Promise<void> } A Promise instance used to return when release completed. 2070 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2071 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2072 * @since 9 2073 */ 2074 /** 2075 * Releases resources used for AVPlayer. 2076 * @returns { Promise<void> } A Promise instance used to return when release completed. 2077 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2078 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2079 * @atomicservice 2080 * @since 11 2081 */ 2082 /** 2083 * Releases resources used for AVPlayer. 2084 * @returns { Promise<void> } A Promise instance used to return when release completed. 2085 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2086 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2087 * @crossplatform 2088 * @atomicservice 2089 * @since 12 2090 */ 2091 release(): Promise<void>; 2092 2093 /** 2094 * Jumps to the specified playback position. 2095 * @param { number } timeMs - Playback position to jump, should be in [0, duration]. 2096 * @param { SeekMode } mode - See @SeekMode . 2097 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2098 * @since 9 2099 */ 2100 /** 2101 * Jumps to the specified playback position. 2102 * @param { number } timeMs - Playback position to jump, should be in [0, duration]. 2103 * @param { SeekMode } mode - See @SeekMode . 2104 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2105 * @atomicservice 2106 * @since 11 2107 */ 2108 /** 2109 * Jumps to the specified playback position. 2110 * @param { number } timeMs - Playback position to jump, should be in [0, duration]. 2111 * @param { SeekMode } mode - See @SeekMode . 2112 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2113 * @crossplatform 2114 * @atomicservice 2115 * @since 12 2116 */ 2117 seek(timeMs: number, mode?: SeekMode): void; 2118 2119 /** 2120 * Sets the volume. 2121 * @param { number } volume - Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). 2122 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2123 * @since 9 2124 */ 2125 /** 2126 * Sets the volume. 2127 * @param { number } volume - Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). 2128 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2129 * @crossplatform 2130 * @atomicservice 2131 * @since 12 2132 */ 2133 setVolume(volume: number): void; 2134 2135 /** 2136 * Get all track infos in MediaDescription, should be called after data loaded callback. 2137 * @param { AsyncCallback<Array<MediaDescription>> } callback - Async callback return track info in MediaDescription. 2138 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2139 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2140 * @since 9 2141 */ 2142 /** 2143 * Get all track infos in MediaDescription, should be called after data loaded callback. 2144 * @param { AsyncCallback<Array<MediaDescription>> } callback - Async callback return track info in MediaDescription. 2145 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2146 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2147 * @atomicservice 2148 * @since 11 2149 */ 2150 /** 2151 * Get all track infos in MediaDescription, should be called after data loaded callback. 2152 * @param { AsyncCallback<Array<MediaDescription>> } callback - Async callback return track info in MediaDescription. 2153 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 2154 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2155 * @crossplatform 2156 * @atomicservice 2157 * @since 12 2158 */ 2159 getTrackDescription(callback: AsyncCallback<Array<MediaDescription>>): void; 2160 2161 /** 2162 * Get all track infos in MediaDescription, should be called after data loaded callback. 2163 * @returns { Promise<Array<MediaDescription>> } A Promise instance used to return the track info in MediaDescription. 2164 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2165 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2166 * @since 9 2167 */ 2168 /** 2169 * Get all track infos in MediaDescription, should be called after data loaded callback. 2170 * @returns { Promise<Array<MediaDescription>> } A Promise instance used to return the track info in MediaDescription. 2171 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2172 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2173 * @atomicservice 2174 * @since 11 2175 */ 2176 /** 2177 * Get all track infos in MediaDescription, should be called after data loaded callback. 2178 * @returns { Promise<Array<MediaDescription>> } A Promise instance used to return the track info in MediaDescription. 2179 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2180 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2181 * @crossplatform 2182 * @atomicservice 2183 * @since 12 2184 */ 2185 getTrackDescription(): Promise<Array<MediaDescription>>; 2186 2187 /** 2188 * Get selected tracks, should be called after prepared state. 2189 * @returns { Promise<Array<number>> } A Promise instance used to return selected track index. 2190 * @throws { BusinessError } 5400102 - Operation not allowed. 2191 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2192 * @atomicservice 2193 * @since 12 2194 */ 2195 getSelectedTracks(): Promise<Array<number>>; 2196 2197 /** 2198 * Select specific track to play. 2199 * @param { number } index - Track index returned by getTrackDescription#MD_KEY_TRACK_INDEX 2200 * @param { SwitchMode } mode - set switchmode for track select behavior. 2201 * @returns { Promise<void> } A Promise instance used to return when select track completed. 2202 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 2203 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2204 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2205 * @atomicservice 2206 * @since 12 2207 */ 2208 selectTrack(index: number, mode?: SwitchMode): Promise<void>; 2209 2210 /** 2211 * Deselect specific track to play. 2212 * @param { number } index : Track index returned by getTrackDescription#MD_KEY_TRACK_INDEX 2213 * @returns { Promise<void> } A Promise instance used to return when deselect track completed. 2214 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 2215 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2216 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2217 * @atomicservice 2218 * @since 12 2219 */ 2220 deselectTrack(index: number): Promise<void>; 2221 2222 /** 2223 * Set MediaSource to AVPlayer, this interface is exclusive with fd/url/dataSrc assign. 2224 * @param { MediaSource } src : MediaSource instance to be set to the avplayer instance. 2225 * @param { PlaybackStrategy } strategy : Play strategy of the media source. 2226 * @returns { Promise<void> } A Promise instance used to return when setMediaSource completed. 2227 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2228 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2229 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2230 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2231 * @atomicservice 2232 * @since 12 2233 */ 2234 setMediaSource(src: MediaSource, strategy?: PlaybackStrategy): Promise<void>; 2235 2236 /** 2237 * Add subtitle resource represented by FD to the player. 2238 * @param { number } fd : The file descriptor of subtitle source from file system. 2239 * The caller is responsible to close the file descriptor. 2240 * @param { number } offset : The offset into the file where the data to be read, in bytes. 2241 * By default, the offset is zero. 2242 * @param { number } length : The length in bytes of the data to be read. 2243 * By default, the length is the rest of bytes in the file from the offset. 2244 * @returns { Promise<void> } Promise used to return the result. 2245 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 2246 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2247 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2248 * @atomicservice 2249 * @since 12 2250 */ 2251 addSubtitleFromFd(fd: number, offset?: number, length?: number): Promise<void>; 2252 2253 /** 2254 * Add subtitle resource represented by url to the player. After the Promise returns, 2255 * subtitle info can be obtained by @getTrackDescription 2256 * @param { string } url : Address of external subtitle file. 2257 * @returns { Promise<void> } Promise used to return the result. 2258 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 2259 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2260 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2261 * @atomicservice 2262 * @since 12 2263 */ 2264 addSubtitleFromUrl(url: string): Promise<void>; 2265 2266 /** 2267 * Get statistic infos of current player. 2268 * @returns { Promise<PlaybackInfo> } Statistic infos of current player. 2269 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2270 * @since 12 2271 */ 2272 getPlaybackInfo(): Promise<PlaybackInfo>; 2273 2274 /** 2275 * Set playback strategy to AVPlayer. 2276 * @param { PlaybackStrategy } strategy : specified strategy of the AVPlayer. 2277 * @returns { Promise<void> } A Promise instance used to return when setPlaybackStrategy completed. 2278 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 2. Parameter verification failed. 2279 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2280 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2281 * @atomicservice 2282 * @since 12 2283 */ 2284 setPlaybackStrategy(strategy: PlaybackStrategy): Promise<void>; 2285 2286 /** 2287 * Mute specified media stream. 2288 * @param { MediaType } mediaType - specified media Type, see @MediaType.. 2289 * @param { boolean } muted - true for mute, false for unmute. 2290 * @returns { Promise<void> } A Promise instance used to return when setMediaMuted completed. 2291 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 2292 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2293 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2294 * @atomicservice 2295 * @since 12 2296 */ 2297 setMediaMuted(mediaType: MediaType, muted: boolean ): Promise<void>; 2298 2299 /** 2300 * Set playback start position and end position. 2301 * @param { number } startTimeMs - Playback start position, should be in [0, duration), 2302 * -1 means that the start position is not set, 2303 * and the playback will start from 0. 2304 * @param { number } endTimeMs - Playback end position, which should usually be in (startTimeMs, duration], 2305 * -1 means that the end position is not set, 2306 * and the playback will be ended at the end of the stream. 2307 * @param { SeekMode } [mode] - Use the specified seek mode to jump to the playback start position, 2308 * currently support SeekMode.SEEK_PREV_SYNC and SeekMode.SEEK_CLOSEST, 2309 * other values are invalid, the default value is SeekMode.SEEK_PREV_SYNC. 2310 * @returns { Promise<void> } Promise used to return the result. 2311 * @throws { BusinessError } 202 - Called from Non-System applications. Return by promise. 2312 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 2313 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 2314 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2315 * @systemapi 2316 * @since 12 2317 */ 2318 setPlaybackRange(startTimeMs: number, endTimeMs: number, mode?: SeekMode) : Promise<void>; 2319 2320 /** 2321 * Media URI. Mainstream media formats are supported. 2322 * Network:http://xxx 2323 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2324 * @since 9 2325 */ 2326 /** 2327 * Media URI. Mainstream media formats are supported. 2328 * Network:http://xxx 2329 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2330 * @atomicservice 2331 * @since 11 2332 */ 2333 /** 2334 * Media URI. Mainstream media formats are supported. 2335 * Network:http://xxx 2336 * @type { ?string } 2337 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2338 * @crossplatform 2339 * @atomicservice 2340 * @since 12 2341 */ 2342 url?: string; 2343 2344 /** 2345 * Media file descriptor. Mainstream media formats are supported. 2346 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2347 * @since 9 2348 */ 2349 /** 2350 * Media file descriptor. Mainstream media formats are supported. 2351 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2352 * @atomicservice 2353 * @since 11 2354 */ 2355 /** 2356 * Media file descriptor. Mainstream media formats are supported. 2357 * @type { ?AVFileDescriptor } 2358 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2359 * @crossplatform 2360 * @atomicservice 2361 * @since 12 2362 */ 2363 fdSrc?: AVFileDescriptor; 2364 2365 /** 2366 * DataSource descriptor. Supports mainstream media formats. 2367 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2368 * @since 10 2369 */ 2370 /** 2371 * DataSource descriptor. Supports mainstream media formats. 2372 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2373 * @atomicservice 2374 * @since 11 2375 */ 2376 /** 2377 * DataSource descriptor. Supports mainstream media formats. 2378 * @type { ?AVDataSrcDescriptor } 2379 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2380 * @crossplatform 2381 * @atomicservice 2382 * @since 12 2383 */ 2384 dataSrc?: AVDataSrcDescriptor; 2385 2386 /** 2387 * Whether to loop media playback. 2388 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2389 * @since 9 2390 */ 2391 /** 2392 * Whether to loop media playback. 2393 * @type { boolean } 2394 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2395 * @crossplatform 2396 * @atomicservice 2397 * @since 12 2398 */ 2399 loop: boolean; 2400 2401 /** 2402 * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not 2403 * set, the default mode will be used. Set it before calling the {@link #play()} in the 2404 * first time in order for the interrupt mode to become effective thereafter. 2405 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2406 * @since 9 2407 */ 2408 /** 2409 * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not 2410 * set, the default mode will be used. Set it before calling the {@link #play()} in the 2411 * first time in order for the interrupt mode to become effective thereafter. 2412 * @type { ?audio.InterruptMode } 2413 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2414 * @atomicservice 2415 * @since 12 2416 */ 2417 audioInterruptMode?: audio.InterruptMode; 2418 2419 /** 2420 * Describes audio renderer info, refer to {@link #audio.AudioRendererInfo}. Set it before 2421 * calling the {@link #prepare()} in the first time in order for the audio renderer info to 2422 * become effective thereafter. 2423 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2424 * @since 10 2425 */ 2426 /** 2427 * Describes audio renderer info, refer to {@link #audio.AudioRendererInfo}. Set it before 2428 * calling the {@link #prepare()} in the first time in order for the audio renderer info to 2429 * become effective thereafter. 2430 * @type { ?audio.AudioRendererInfo } 2431 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2432 * @atomicservice 2433 * @since 12 2434 */ 2435 audioRendererInfo?: audio.AudioRendererInfo; 2436 2437 /** 2438 * Obtains the current audio effect mode, refer to {@link #audio.AudioEffectMode}. 2439 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2440 * @since 10 2441 */ 2442 /** 2443 * Obtains the current audio effect mode, refer to {@link #audio.AudioEffectMode}. 2444 * @type { ?audio.AudioEffectMode } 2445 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2446 * @atomicservice 2447 * @since 12 2448 */ 2449 audioEffectMode ?: audio.AudioEffectMode; 2450 2451 /** 2452 * Current playback position. 2453 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2454 * @since 9 2455 */ 2456 /** 2457 * Current playback position. 2458 * @type { number } 2459 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2460 * @crossplatform 2461 * @atomicservice 2462 * @since 12 2463 */ 2464 readonly currentTime: number; 2465 2466 /** 2467 * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario. 2468 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2469 * @since 9 2470 */ 2471 /** 2472 * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario. 2473 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2474 * @atomicservice 2475 * @since 11 2476 */ 2477 /** 2478 * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario. 2479 * @type { number } 2480 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2481 * @crossplatform 2482 * @atomicservice 2483 * @since 12 2484 */ 2485 readonly duration: number; 2486 2487 /** 2488 * Playback state. 2489 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2490 * @since 9 2491 */ 2492 /** 2493 * Playback state. 2494 * @type { AVPlayerState } 2495 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2496 * @crossplatform 2497 * @atomicservice 2498 * @since 12 2499 */ 2500 readonly state: AVPlayerState; 2501 2502 /** 2503 * Video player will use this id get a surface instance. 2504 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2505 * @since 9 2506 */ 2507 /** 2508 * Video player will use this id get a surface instance. 2509 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2510 * @atomicservice 2511 * @since 11 2512 */ 2513 /** 2514 * Video player will use this id get a surface instance. 2515 * @type { ?string } 2516 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2517 * @crossplatform 2518 * @atomicservice 2519 * @since 12 2520 */ 2521 surfaceId?: string; 2522 2523 /** 2524 * Video width, valid after prepared. 2525 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2526 * @since 9 2527 */ 2528 /** 2529 * Video width, valid after prepared. 2530 * @type { number } 2531 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2532 * @crossplatform 2533 * @atomicservice 2534 * @since 12 2535 */ 2536 readonly width: number; 2537 2538 /** 2539 * Video height, valid after prepared. 2540 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2541 * @since 9 2542 */ 2543 /** 2544 * Video height, valid after prepared. 2545 * @type { number } 2546 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2547 * @crossplatform 2548 * @atomicservice 2549 * @since 12 2550 */ 2551 readonly height: number; 2552 2553 /** 2554 * Video scale type. By default, the {@link #VIDEO_SCALE_TYPE_FIT} will be used, for more 2555 * information, refer to {@link #VideoScaleType} . 2556 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2557 * @since 9 2558 */ 2559 /** 2560 * Video scale type. By default, the {@link #VIDEO_SCALE_TYPE_FIT} will be used, for more 2561 * information, refer to {@link #VideoScaleType} . 2562 * @type { ?VideoScaleType } 2563 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2564 * @crossplatform 2565 * @atomicservice 2566 * @since 12 2567 */ 2568 videoScaleType?: VideoScaleType; 2569 2570 /** 2571 * Set payback speed. 2572 * @param { PlaybackSpeed } speed - playback speed, see @PlaybackSpeed . 2573 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2574 * @since 9 2575 */ 2576 /** 2577 * Set payback speed. 2578 * @param { PlaybackSpeed } speed - playback speed, see @PlaybackSpeed . 2579 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2580 * @crossplatform 2581 * @atomicservice 2582 * @since 12 2583 */ 2584 setSpeed(speed: PlaybackSpeed): void; 2585 2586 /** 2587 * select a specified bitrate to playback, only valid for HLS protocol network stream. By default, the 2588 * player will select the appropriate bitrate according to the network connection speed. The 2589 * available bitrate list reported by {@link #on('availableBitrates')}. Set it to select 2590 * a specified bitrate. If the specified bitrate is not in the list of available bitrate, the player 2591 * will select the minimal and closest one from the available bitrate list. 2592 * @param { number } bitrate - the playback bitrate must be expressed in bits per second. 2593 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2594 * @since 9 2595 */ 2596 /** 2597 * select a specified bitrate to playback, only valid for HLS protocol network stream. By default, the 2598 * player will select the appropriate bitrate according to the network connection speed. The 2599 * available bitrate list reported by {@link #on('availableBitrates')}. Set it to select 2600 * a specified bitrate. If the specified bitrate is not in the list of available bitrate, the player 2601 * will select the minimal and closest one from the available bitrate list. 2602 * @param { number } bitrate - the playback bitrate must be expressed in bits per second. 2603 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2604 * @crossplatform 2605 * @atomicservice 2606 * @since 12 2607 */ 2608 setBitrate(bitrate: number): void; 2609 2610 /** 2611 * Set decryption session to codec module. 2612 * @param { drm.MediaKeySession } mediaKeySession - Handle of MediaKeySession to decrypt encrypted media. 2613 * @param { boolean } secureVideoPath - Secure video path required or not. 2614 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2615 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2616 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2617 * @since 11 2618 */ 2619 /** 2620 * Set decryption session to codec module. 2621 * @param { drm.MediaKeySession } mediaKeySession - Handle of MediaKeySession to decrypt encrypted media. 2622 * @param { boolean } secureVideoPath - Secure video path required or not. 2623 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2624 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2625 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2626 * @atomicservice 2627 * @since 12 2628 */ 2629 setDecryptionConfig(mediaKeySession: drm.MediaKeySession, secureVideoPath: boolean): void; 2630 2631 /** 2632 * Get media key system info from media source. 2633 * @returns { Array<drm.MediaKeySystemInfo> } MediaKeySystemInfo with PSSH. 2634 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2635 * @since 11 2636 */ 2637 /** 2638 * Get media key system info from media source. 2639 * @returns { Array<drm.MediaKeySystemInfo> } MediaKeySystemInfo with PSSH. 2640 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2641 * @atomicservice 2642 * @since 12 2643 */ 2644 getMediaKeySystemInfos(): Array<drm.MediaKeySystemInfo>; 2645 2646 /** 2647 * Register listens for mediaKeySystemInfoUpdate events. 2648 * @param { 'mediaKeySystemInfoUpdate' } type - Type of the event to listen for. 2649 * @param { function } callback - Callback used to listen for the mediaKeySystemInfoUpdate event. 2650 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2651 * @since 11 2652 */ 2653 /** 2654 * Register listens for mediaKeySystemInfoUpdate events. 2655 * @param { 'mediaKeySystemInfoUpdate' } type - Type of the event to listen for. 2656 * @param { Callback<Array<drm.MediaKeySystemInfo>> } callback - Callback used to listen for the mediaKeySystemInfoUpdate event. 2657 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2658 * @atomicservice 2659 * @since 12 2660 */ 2661 on(type: 'mediaKeySystemInfoUpdate', callback: Callback<Array<drm.MediaKeySystemInfo>>): void; 2662 2663 /** 2664 * Unregister listens for mediaKeySystemInfoUpdate events. 2665 * @param { 'mediaKeySystemInfoUpdate' } type - Type of the event to listen for. 2666 * @param { function } callback - Callback for event. 2667 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2668 * @since 11 2669 */ 2670 /** 2671 * Unregister listens for mediaKeySystemInfoUpdate events. 2672 * @param { 'mediaKeySystemInfoUpdate' } type - Type of the event to listen for. 2673 * @param { Callback<Array<drm.MediaKeySystemInfo>> } callback - Callback for event. 2674 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2675 * @atomicservice 2676 * @since 12 2677 */ 2678 off(type: 'mediaKeySystemInfoUpdate', callback?: Callback<Array<drm.MediaKeySystemInfo>>): void; 2679 2680 /** 2681 * Register listens for media playback stateChange event. 2682 * @param { 'stateChange' } type - Type of the playback event to listen for. 2683 * @param { function } callback - Callback used to listen for the playback stateChange event. 2684 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2685 * @since 9 2686 */ 2687 /** 2688 * Register listens for media playback stateChange event. 2689 * @param { 'stateChange' } type - Type of the playback event to listen for. 2690 * @param { function } callback - Callback used to listen for the playback stateChange event. 2691 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2692 * @atomicservice 2693 * @since 11 2694 */ 2695 /** 2696 * Register listens for media playback stateChange event. 2697 * @param { 'stateChange' } type - Type of the playback event to listen for. 2698 * @param { OnAVPlayerStateChangeHandle } callback - Callback used to listen for the playback stateChange event. 2699 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2700 * @crossplatform 2701 * @atomicservice 2702 * @since 12 2703 */ 2704 on(type: 'stateChange', callback: OnAVPlayerStateChangeHandle): void; 2705 /** 2706 * Unregister listens for media playback stateChange event. 2707 * @param { 'stateChange' } type - Type of the playback event to listen for. 2708 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2709 * @since 9 2710 */ 2711 /** 2712 * Unregister listens for media playback stateChange event. 2713 * @param { 'stateChange' } type - Type of the playback event to listen for. 2714 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2715 * @atomicservice 2716 * @since 11 2717 */ 2718 /** 2719 * Unregister listens for media playback stateChange event. 2720 * @param { 'stateChange' } type - Type of the playback event to listen for. 2721 * @param { OnAVPlayerStateChangeHandle } callback - Callback used to listen for stateChange event 2722 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2723 * @crossplatform 2724 * @atomicservice 2725 * @since 12 2726 */ 2727 off(type: 'stateChange', callback?: OnAVPlayerStateChangeHandle): void; 2728 /** 2729 * Register listens for media playback volumeChange event. 2730 * @param { 'volumeChange' } type - Type of the playback event to listen for. 2731 * @param { Callback<number> } callback - Callback used to listen for the playback volume event. 2732 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2733 * @since 9 2734 */ 2735 /** 2736 * Register listens for media playback volumeChange event. 2737 * @param { 'volumeChange' } type - Type of the playback event to listen for. 2738 * @param { Callback<number> } callback - Callback used to listen for the playback volume event. 2739 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2740 * @crossplatform 2741 * @atomicservice 2742 * @since 12 2743 */ 2744 on(type: 'volumeChange', callback: Callback<number>): void; 2745 /** 2746 * Unregister listens for media playback volumeChange event. 2747 * @param { 'volumeChange' } type - Type of the playback event to listen for. 2748 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2749 * @since 9 2750 */ 2751 /** 2752 * Unregister listens for media playback volumeChange event. 2753 * @param { 'volumeChange' } type - Type of the playback event to listen for. 2754 * @param { Callback<number> } callback - Callback used to listen for the playback volume event. 2755 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2756 * @crossplatform 2757 * @since 12 2758 */ 2759 off(type: 'volumeChange', callback?: Callback<number>): void; 2760 /** 2761 * Register listens for media playback endOfStream event. 2762 * @param { 'endOfStream' } type - Type of the playback event to listen for. 2763 * @param { Callback<void> } callback - Callback used to listen for the playback end of stream. 2764 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2765 * @since 9 2766 */ 2767 /** 2768 * Register listens for media playback endOfStream event. 2769 * @param { 'endOfStream' } type - Type of the playback event to listen for. 2770 * @param { Callback<void> } callback - Callback used to listen for the playback end of stream. 2771 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2772 * @crossplatform 2773 * @atomicservice 2774 * @since 12 2775 */ 2776 on(type: 'endOfStream', callback: Callback<void>): void; 2777 /** 2778 * Unregister listens for media playback endOfStream event. 2779 * @param { 'endOfStream' } type - Type of the playback event to listen for. 2780 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2781 * @since 9 2782 */ 2783 /** 2784 * Unregister listens for media playback endOfStream event. 2785 * @param { 'endOfStream' } type - Type of the playback event to listen for. 2786 * @param { Callback<void> } callback - Callback used to listen for the playback end of stream. 2787 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2788 * @crossplatform 2789 * @since 12 2790 */ 2791 off(type: 'endOfStream', callback?: Callback<void>): void; 2792 /** 2793 * Register listens for media playback seekDone event. 2794 * @param { 'seekDone' } type - Type of the playback event to listen for. 2795 * @param { Callback<number> } callback - Callback used to listen for the playback seekDone event. 2796 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2797 * @since 9 2798 */ 2799 /** 2800 * Register listens for media playback seekDone event. 2801 * @param { 'seekDone' } type - Type of the playback event to listen for. 2802 * @param { Callback<number> } callback - Callback used to listen for the playback seekDone event. 2803 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2804 * @atomicservice 2805 * @since 11 2806 */ 2807 /** 2808 * Register listens for media playback seekDone event. 2809 * @param { 'seekDone' } type - Type of the playback event to listen for. 2810 * @param { Callback<number> } callback - Callback used to listen for the playback seekDone event. 2811 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2812 * @crossplatform 2813 * @atomicservice 2814 * @since 12 2815 */ 2816 on(type: 'seekDone', callback: Callback<number>): void; 2817 /** 2818 * Unregister listens for media playback seekDone event. 2819 * @param { 'seekDone' } type - Type of the playback event to listen for. 2820 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2821 * @since 9 2822 */ 2823 /** 2824 * Unregister listens for media playback seekDone event. 2825 * @param { 'seekDone' } type - Type of the playback event to listen for. 2826 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2827 * @atomicservice 2828 * @since 11 2829 */ 2830 /** 2831 * Unregister listens for media playback seekDone event. 2832 * @param { 'seekDone' } type - Type of the playback event to listen for. 2833 * @param { Callback<number> } callback - Callback used to listen for the playback seekDone event. 2834 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2835 * @crossplatform 2836 * @atomicservice 2837 * @since 12 2838 */ 2839 off(type: 'seekDone', callback?: Callback<number>): void; 2840 /** 2841 * Register listens for media playback speedDone event. 2842 * @param { 'speedDone' } type - Type of the playback event to listen for. 2843 * @param { Callback<number> } callback - Callback used to listen for the playback speedDone event. 2844 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2845 * @since 9 2846 */ 2847 /** 2848 * Register listens for media playback speedDone event. 2849 * @param { 'speedDone' } type - Type of the playback event to listen for. 2850 * @param { Callback<number> } callback - Callback used to listen for the playback speedDone event. 2851 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2852 * @crossplatform 2853 * @atomicservice 2854 * @since 12 2855 */ 2856 on(type: 'speedDone', callback: Callback<number>): void; 2857 /** 2858 * Unregister listens for media playback speedDone event. 2859 * @param { 'speedDone' } type - Type of the playback event to listen for. 2860 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2861 * @since 9 2862 */ 2863 /** 2864 * Unregister listens for media playback speedDone event. 2865 * @param { 'speedDone' } type - Type of the playback event to listen for. 2866 * @param { Callback<number> } callback - Callback used to listen for the playback speedDone event. 2867 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2868 * @crossplatform 2869 * @since 12 2870 */ 2871 off(type: 'speedDone', callback?: Callback<number>): void; 2872 /** 2873 * Register listens for media playback setBitrateDone event. 2874 * @param { 'bitrateDone' } type - Type of the playback event to listen for. 2875 * @param { Callback<number> } callback - Callback used to listen for the playback setBitrateDone event. 2876 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2877 * @since 9 2878 */ 2879 /** 2880 * Register listens for media playback setBitrateDone event. 2881 * @param { 'bitrateDone' } type - Type of the playback event to listen for. 2882 * @param { Callback<number> } callback - Callback used to listen for the playback setBitrateDone event. 2883 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2884 * @atomicservice 2885 * @since 12 2886 */ 2887 on(type: 'bitrateDone', callback: Callback<number>): void; 2888 /** 2889 * Unregister listens for media playback setBitrateDone event. 2890 * @param { 'bitrateDone' } type - Type of the playback event to listen for. 2891 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2892 * @since 9 2893 */ 2894 /** 2895 * Unregister listens for media playback setBitrateDone event. 2896 * @param { 'bitrateDone' } type - Type of the playback event to listen for. 2897 * @param { Callback<number> } callback - Callback used to listen for the playback setBitrateDone event. 2898 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2899 * @since 12 2900 */ 2901 off(type: 'bitrateDone', callback?: Callback<number>): void; 2902 /** 2903 * Register listens for media playback timeUpdate event. 2904 * @param { 'timeUpdate' } type - Type of the playback event to listen for. 2905 * @param { Callback<number> } callback - Callback used to listen for the playback timeUpdate event. 2906 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2907 * @since 9 2908 */ 2909 /** 2910 * Register listens for media playback timeUpdate event. 2911 * @param { 'timeUpdate' } type - Type of the playback event to listen for. 2912 * @param { Callback<number> } callback - Callback used to listen for the playback timeUpdate event. 2913 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2914 * @atomicservice 2915 * @since 11 2916 */ 2917 /** 2918 * Register listens for media playback timeUpdate event. 2919 * @param { 'timeUpdate' } type - Type of the playback event to listen for. 2920 * @param { Callback<number> } callback - Callback used to listen for the playback timeUpdate event. 2921 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2922 * @crossplatform 2923 * @atomicservice 2924 * @since 12 2925 */ 2926 on(type: 'timeUpdate', callback: Callback<number>): void; 2927 /** 2928 * Unregister listens for media playback timeUpdate event. 2929 * @param { 'timeUpdate' } type - Type of the playback event to listen for. 2930 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2931 * @since 9 2932 */ 2933 /** 2934 * Unregister listens for media playback timeUpdate event. 2935 * @param { 'timeUpdate' } type - Type of the playback event to listen for. 2936 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2937 * @atomicservice 2938 * @since 11 2939 */ 2940 /** 2941 * Unregister listens for media playback timeUpdate event. 2942 * @param { 'timeUpdate' } type - Type of the playback event to listen for. 2943 * @param { Callback<number> } callback - Callback used to listen for the playback timeUpdate event. 2944 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2945 * @crossplatform 2946 * @atomicservice 2947 * @since 12 2948 */ 2949 off(type: 'timeUpdate', callback?: Callback<number>): void; 2950 /** 2951 * Register listens for media playback durationUpdate event. 2952 * @param { 'durationUpdate' } type - Type of the playback event to listen for. 2953 * @param { Callback<number> } callback - Callback used to listen for the playback durationUpdate event. 2954 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2955 * @since 9 2956 */ 2957 /** 2958 * Register listens for media playback durationUpdate event. 2959 * @param { 'durationUpdate' } type - Type of the playback event to listen for. 2960 * @param { Callback<number> } callback - Callback used to listen for the playback durationUpdate event. 2961 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2962 * @crossplatform 2963 * @atomicservice 2964 * @since 12 2965 */ 2966 on(type: 'durationUpdate', callback: Callback<number>): void; 2967 /** 2968 * Unregister listens for media playback durationUpdate event. 2969 * @param { 'durationUpdate' } type - Type of the playback event to listen for. 2970 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2971 * @since 9 2972 */ 2973 /** 2974 * Unregister listens for media playback durationUpdate event. 2975 * @param { 'durationUpdate' } type - Type of the playback event to listen for. 2976 * @param { Callback<number> } callback - Callback used to listen for the playback durationUpdate event. 2977 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2978 * @crossplatform 2979 * @since 12 2980 */ 2981 off(type: 'durationUpdate', callback?: Callback<number>): void; 2982 2983 /** 2984 * Register listens for video playback buffering events. 2985 * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. 2986 * @param { function } callback - Callback used to listen for the buffering update event, 2987 * return BufferingInfoType and the value. 2988 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2989 * @since 9 2990 */ 2991 /** 2992 * Register listens for video playback buffering events. 2993 * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. 2994 * @param { OnBufferingUpdateHandler } callback - Callback used to listen for the buffering update event, 2995 * return BufferingInfoType and the value. 2996 * @syscap SystemCapability.Multimedia.Media.AVPlayer 2997 * @crossplatform 2998 * @atomicservice 2999 * @since 12 3000 */ 3001 on(type: 'bufferingUpdate', callback: OnBufferingUpdateHandler): void; 3002 3003 /** 3004 * Unregister listens for video playback buffering events. 3005 * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. 3006 * return BufferingInfoType and the value. 3007 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3008 * @since 9 3009 */ 3010 /** 3011 * Unregister listens for video playback buffering events. 3012 * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. 3013 * @param { OnBufferingUpdateHandler } callback - Callback used to listen for the buffering update event, 3014 * return BufferingInfoType and the value. 3015 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3016 * @crossplatform 3017 * @atomicservice 3018 * @since 12 3019 */ 3020 off(type: 'bufferingUpdate', callback?: OnBufferingUpdateHandler): void; 3021 /** 3022 * Register listens for start render video frame events. 3023 * @param { 'startRenderFrame' } type - Type of the playback event to listen for. 3024 * @param { Callback<void> } callback - Callback used to listen for the playback event return . 3025 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3026 * @since 9 3027 */ 3028 /** 3029 * Register listens for start render video frame events. 3030 * @param { 'startRenderFrame' } type - Type of the playback event to listen for. 3031 * @param { Callback<void> } callback - Callback used to listen for the playback event return . 3032 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3033 * @atomicservice 3034 * @since 12 3035 */ 3036 on(type: 'startRenderFrame', callback: Callback<void>): void; 3037 /** 3038 * Unregister listens for start render video frame events. 3039 * @param { 'startRenderFrame' } type - Type of the playback event to listen for. 3040 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3041 * @since 9 3042 */ 3043 /** 3044 * Unregister listens for start render video frame events. 3045 * @param { 'startRenderFrame' } type - Type of the playback event to listen for. 3046 * @param { Callback<void> } callback - Callback used to listen for the playback event return . 3047 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3048 * @since 12 3049 */ 3050 off(type: 'startRenderFrame', callback?: Callback<void>): void; 3051 3052 /** 3053 * Register listens for video size change event. 3054 * @param { 'videoSizeChange' } type - Type of the playback event to listen for. 3055 * @param { function } callback - Callback used to listen for the playback event return video size. 3056 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3057 * @since 9 3058 */ 3059 /** 3060 * Register listens for video size change event. 3061 * @param { 'videoSizeChange' } type - Type of the playback event to listen for. 3062 * @param { OnVideoSizeChangeHandler } callback - Callback used to listen for the playback event return video size. 3063 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3064 * @crossplatform 3065 * @atomicservice 3066 * @since 12 3067 */ 3068 on(type: 'videoSizeChange', callback: OnVideoSizeChangeHandler): void; 3069 /** 3070 * Unregister listens for video size change event. 3071 * @param { 'videoSizeChange' } type - Type of the playback event to listen for. 3072 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3073 * @since 9 3074 */ 3075 /** 3076 * Unregister listens for video size change event. 3077 * @param { 'videoSizeChange' } type - Type of the playback event to listen for. 3078 * @param { OnVideoSizeChangeHandler } callback - Callback used to listen for the playback event return video size. 3079 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3080 * @crossplatform 3081 * @atomicservice 3082 * @since 12 3083 */ 3084 off(type: 'videoSizeChange', callback?: OnVideoSizeChangeHandler): void; 3085 /** 3086 * Register listens for audio interrupt event, refer to {@link #audio.InterruptEvent} 3087 * @param { 'audioInterrupt' } type - Type of the playback event to listen for. 3088 * @param { function } callback - Callback used to listen for the playback event return audio interrupt info. 3089 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3090 * @since 9 3091 */ 3092 /** 3093 * Register listens for audio interrupt event, refer to {@link #audio.InterruptEvent} 3094 * @param { 'audioInterrupt' } type - Type of the playback event to listen for. 3095 * @param { Callback<audio.InterruptEvent> } callback - Callback used to listen for the playback event return audio interrupt info. 3096 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3097 * @crossplatform 3098 * @atomicservice 3099 * @since 12 3100 */ 3101 on(type: 'audioInterrupt', callback: Callback<audio.InterruptEvent>): void; 3102 /** 3103 * Unregister listens for audio interrupt event, refer to {@link #audio.InterruptEvent} 3104 * @param { 'audioInterrupt' } type - Type of the playback event to listen for. 3105 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3106 * @since 9 3107 */ 3108 /** 3109 * Unregister listens for audio interrupt event, refer to {@link #audio.InterruptEvent} 3110 * @param { 'audioInterrupt' } type - Type of the playback event to listen for. 3111 * @param { Callback<audio.InterruptEvent> } callback - Callback used to listen for the playback event return audio interrupt info. 3112 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3113 * @crossplatform 3114 * @atomicservice 3115 * @since 12 3116 */ 3117 off(type: 'audioInterrupt', callback?: Callback<audio.InterruptEvent>): void; 3118 /** 3119 * Register listens for available bitrate list collect completed events for HLS protocol stream playback. 3120 * This event will be reported after the {@link #prepare} called. 3121 * @param { 'availableBitrates' } type - Type of the playback event to listen for. 3122 * @param { function } callback - Callback used to listen for the playback event return available bitrate list. 3123 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3124 * @since 9 3125 */ 3126 /** 3127 * Register listens for available bitrate list collect completed events for HLS protocol stream playback. 3128 * This event will be reported after the {@link #prepare} called. 3129 * @param { 'availableBitrates' } type - Type of the playback event to listen for. 3130 * @param { Callback<Array<number>> } callback - Callback used to listen for the playback event return available bitrate list. 3131 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3132 * @crossplatform 3133 * @atomicservice 3134 * @since 12 3135 */ 3136 on(type: 'availableBitrates', callback: Callback<Array<number>>): void; 3137 /** 3138 * Unregister listens for available bitrate list collect completed events for HLS protocol stream playback. 3139 * This event will be reported after the {@link #prepare} called. 3140 * @param { 'availableBitrates' } type - Type of the playback event to listen for. 3141 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3142 * @since 9 3143 */ 3144 /** 3145 * Unregister listens for available bitrate list collect completed events for HLS protocol stream playback. 3146 * This event will be reported after the {@link #prepare} called. 3147 * @param { 'availableBitrates' } type - Type of the playback event to listen for. 3148 * @param { Callback<Array<number>> } callback - Callback used to listen for the playback event return available bitrate list. 3149 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3150 * @crossplatform 3151 * @atomicservice 3152 * @since 12 3153 */ 3154 off(type: 'availableBitrates', callback?: Callback<Array<number>>): void; 3155 /** 3156 * Register listens for playback error events. 3157 * @param { 'error' } type - Type of the playback error event to listen for. 3158 * @param { ErrorCallback } callback - Callback used to listen for the playback error event. 3159 * @throws { BusinessError } 201 - Permission denied. 3160 * @throws { BusinessError } 401 - The parameter check failed. 3161 * @throws { BusinessError } 801 - Capability not supported. 3162 * @throws { BusinessError } 5400101 - No memory. 3163 * @throws { BusinessError } 5400102 - Operation not allowed. 3164 * @throws { BusinessError } 5400103 - I/O error. 3165 * @throws { BusinessError } 5400104 - Time out. 3166 * @throws { BusinessError } 5400105 - Service died. 3167 * @throws { BusinessError } 5400106 - Unsupported format. 3168 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3169 * @since 9 3170 */ 3171 /** 3172 * Register listens for playback error events. 3173 * @param { 'error' } type - Type of the playback error event to listen for. 3174 * @param { ErrorCallback } callback - Callback used to listen for the playback error event. 3175 * @throws { BusinessError } 201 - Permission denied. 3176 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3177 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3178 * @throws { BusinessError } 801 - Capability not supported. 3179 * @throws { BusinessError } 5400101 - No memory. 3180 * @throws { BusinessError } 5400102 - Operation not allowed. 3181 * @throws { BusinessError } 5400103 - I/O error. 3182 * @throws { BusinessError } 5400104 - Time out. 3183 * @throws { BusinessError } 5400105 - Service died. 3184 * @throws { BusinessError } 5400106 - Unsupported format. 3185 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3186 * @atomicservice 3187 * @since 11 3188 */ 3189 /** 3190 * Register listens for playback error events. 3191 * @param { 'error' } type - Type of the playback error event to listen for. 3192 * @param { ErrorCallback } callback - Callback used to listen for the playback error event. 3193 * @throws { BusinessError } 201 - Permission denied. 3194 * @throws { BusinessError } 401 - The parameter check failed. 3195 * @throws { BusinessError } 801 - Capability not supported. 3196 * @throws { BusinessError } 5400101 - No memory. 3197 * @throws { BusinessError } 5400102 - Operation not allowed. 3198 * @throws { BusinessError } 5400103 - I/O error. 3199 * @throws { BusinessError } 5400104 - Time out. 3200 * @throws { BusinessError } 5400105 - Service died. 3201 * @throws { BusinessError } 5400106 - Unsupport format. 3202 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3203 * @crossplatform 3204 * @atomicservice 3205 * @since 12 3206 */ 3207 /** 3208 * Register listens for playback error events. 3209 * @param { 'error' } type - Type of the playback error event to listen for. 3210 * @param { ErrorCallback } callback - Callback used to listen for the playback error event. 3211 * @throws { BusinessError } 201 - Permission denied. 3212 * @throws { BusinessError } 401 - The parameter check failed. 3213 * @throws { BusinessError } 801 - Capability not supported. 3214 * @throws { BusinessError } 5400101 - No memory. 3215 * @throws { BusinessError } 5400102 - Operation not allowed. 3216 * @throws { BusinessError } 5400104 - Time out. 3217 * @throws { BusinessError } 5400105 - Service died. 3218 * @throws { BusinessError } 5400106 - Unsupport format. 3219 * @throws { BusinessError } 5411001 - IO can not find host. 3220 * @throws { BusinessError } 5411002 - IO connection timeout. 3221 * @throws { BusinessError } 5411003 - IO network abnormal. 3222 * @throws { BusinessError } 5411004 - IO network unavailable. 3223 * @throws { BusinessError } 5411005 - IO no permission. 3224 * @throws { BusinessError } 5411006 - IO request denied. 3225 * @throws { BusinessError } 5411007 - IO resource not found. 3226 * @throws { BusinessError } 5411008 - IO SSL client cert needed. 3227 * @throws { BusinessError } 5411009 - IO SSL connect fail. 3228 * @throws { BusinessError } 5411010 - IO SSL server cert untrusted. 3229 * @throws { BusinessError } 5411011 - IO unsupported request. 3230 * @throws { BusinessError } 5411012 - IO data abnormal. 3231 * @throws { BusinessError } 5411013 - IO file access denied. 3232 * @throws { BusinessError } 5411014 - IO file bad handle. 3233 * @throws { BusinessError } 5411015 - IO file not found. 3234 * @throws { BusinessError } 5411016 - IO file permission denied. 3235 * @throws { BusinessError } 5411017 - IO decode failed. 3236 * @throws { BusinessError } 5411018 - Audio decode init failed. 3237 * @throws { BusinessError } 5411019 - Audio decode unavailable. 3238 * @throws { BusinessError } 5411020 - Audio device error. 3239 * @throws { BusinessError } 5411021 - Audio device invalid state. 3240 * @throws { BusinessError } 5411022 - Audio device timeout. 3241 * @throws { BusinessError } 5411023 - Audio device unavailable. 3242 * @throws { BusinessError } 5411024 - Audio encode failed. 3243 * @throws { BusinessError } 5411025 - Audio encode init failed. 3244 * @throws { BusinessError } 5411026 - Audio encode unavailable. 3245 * @throws { BusinessError } 5411027 - Video decode failed. 3246 * @throws { BusinessError } 5411028 - Video decode init failed. 3247 * @throws { BusinessError } 5411029 - Video decode unavailable. 3248 * @throws { BusinessError } 5411030 - Video device error. 3249 * @throws { BusinessError } 5411031 - Video encode failed. 3250 * @throws { BusinessError } 5411032 - Video encode init failed. 3251 * @throws { BusinessError } 5411033 - Video encode unavailable. 3252 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3253 * @crossplatform 3254 * @atomicservice 3255 * @since 14 3256 */ 3257 on(type: 'error', callback: ErrorCallback): void; 3258 /** 3259 * Unregister listens for playback error events. 3260 * @param { 'error' } type - Type of the playback error event to listen for. 3261 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3262 * @since 9 3263 */ 3264 /** 3265 * Unregister listens for playback error events. 3266 * @param { 'error' } type - Type of the playback error event to listen for. 3267 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3268 * @atomicservice 3269 * @since 11 3270 */ 3271 /** 3272 * Unregister listens for playback error events. 3273 * @param { 'error' } type - Type of the playback error event to listen for. 3274 * @param { ErrorCallback } callback - Callback used to listen for the playback error event. 3275 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3276 * @crossplatform 3277 * @atomicservice 3278 * @since 12 3279 */ 3280 off(type: 'error', callback?: ErrorCallback): void; 3281 3282 /** 3283 * Subscribes output device change event callback. 3284 * The event is triggered when output device change for this stream. 3285 * @param { 'audioOutputDeviceChangeWithInfo' } type - Type of the event to listen for. 3286 * @param { Callback<audio.AudioStreamDeviceChangeInfo> } callback - Callback used to listen device change event. 3287 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3288 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3289 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3290 * @since 11 3291 */ 3292 /** 3293 * Subscribes output device change event callback. 3294 * The event is triggered when output device change for this stream. 3295 * @param { 'audioOutputDeviceChangeWithInfo' } type - Type of the event to listen for. 3296 * @param { Callback<audio.AudioStreamDeviceChangeInfo> } callback - Callback used to listen device change event. 3297 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3298 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3299 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3300 * @atomicservice 3301 * @since 12 3302 */ 3303 on(type: 'audioOutputDeviceChangeWithInfo', callback: Callback<audio.AudioStreamDeviceChangeInfo>): void; 3304 3305 /** 3306 * Unsubscribes output device change event callback. 3307 * @param { 'audioOutputDeviceChangeWithInfo' } type - Type of the event to listen for. 3308 * @param { Callback<audio.AudioStreamDeviceChangeInfo> } callback - Callback used to listen device change event. 3309 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3310 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3311 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3312 * @since 11 3313 */ 3314 /** 3315 * Unsubscribes output device change event callback. 3316 * @param { 'audioOutputDeviceChangeWithInfo' } type - Type of the event to listen for. 3317 * @param { Callback<audio.AudioStreamDeviceChangeInfo> } callback - Callback used to listen device change event. 3318 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3319 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3320 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3321 * @atomicservice 3322 * @since 12 3323 */ 3324 off(type: 'audioOutputDeviceChangeWithInfo', callback?: Callback<audio.AudioStreamDeviceChangeInfo>): void; 3325 3326 /** 3327 * Subscribes listener for subtitle update event. 3328 * @param { 'subtitleUpdate' } type - Type of the event to listen for. 3329 * @param { Callback<SubtitleInfo> } callback - Callback used to listen subtitle update event. 3330 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3331 * @atomicservice 3332 * @since 12 3333 */ 3334 on(type: 'subtitleUpdate', callback: Callback<SubtitleInfo>): void 3335 3336 /** 3337 * Unsubscribes listener for subtitle update event. 3338 * @param { 'subtitleUpdate' } type - Type of the event to listen for. 3339 * @param { Callback<SubtitleInfo> } callback - Callback used to listen subtitle update event. 3340 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3341 * @atomicservice 3342 * @since 12 3343 */ 3344 off(type: 'subtitleUpdate', callback?: Callback<SubtitleInfo>): void 3345 3346 /** 3347 * Subscribes listener for track change event. 3348 * @param { 'trackChange' } type - Type of the event to listen for. 3349 * @param { OnTrackChangeHandler } callback - Callback used to listen track change event. 3350 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3351 * @atomicservice 3352 * @since 12 3353 */ 3354 on(type: 'trackChange', callback: OnTrackChangeHandler): void 3355 3356 /** 3357 * Unsubscribes listener for track change event. 3358 * @param { 'trackChange' } type - Type of the event to listen for. 3359 * @param { OnTrackChangeHandler } callback - Callback used to listen track change event. 3360 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3361 * @atomicservice 3362 * @since 12 3363 */ 3364 off(type: 'trackChange', callback?: OnTrackChangeHandler): void 3365 3366 /** 3367 * Subscribes listener for trackinfo update event. 3368 * @param { 'trackInfoUpdate' } type - Type of the event to listen for. 3369 * @param { Callback<Array<MediaDescription>> } callback - Callback used to listen trackinfo update event. 3370 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3371 * @atomicservice 3372 * @since 12 3373 */ 3374 on(type: 'trackInfoUpdate', callback: Callback<Array<MediaDescription>>): void 3375 3376 /** 3377 * Unsubscribes listener for trackinfo update event. 3378 * @param { 'trackInfoUpdate' } type - Type of the event to listen for. 3379 * @param { Callback<Array<MediaDescription>> } callback - Callback used to listen trackinfo update event. 3380 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3381 * @atomicservice 3382 * @since 12 3383 */ 3384 off(type: 'trackInfoUpdate', callback?: Callback<Array<MediaDescription>>): void 3385 3386 /** 3387 * Subscrips listener for audio playback amplitude update event. 3388 * In each event, an array of amplitude is reported, large index indicates closer to current time. 3389 * @param { 'amplitudeUpdate' } type - Type of the event to listen for. 3390 * @param { Callback<Array<Number>> } callback - Callback used to listen amplitude update event. 3391 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3392 * @since 13 3393 */ 3394 on(type: 'amplitudeUpdate', callback: Callback<Array<Number>>): void 3395 3396 /** 3397 * UnSubscrips listener for audio playback amplitude update event 3398 * @param { 'amplitudeUpdate' } type - Type of the event to listen for. 3399 * @param { Callback<Array<Number>> } callback - Callback used to listen amplitude update event. 3400 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3401 * @since 13 3402 */ 3403 off(type: 'amplitudeUpdate', callback?: Callback<Array<Number>>): void 3404 } 3405 3406 /** 3407 * Provides player statistic info. 3408 * 3409 * @typedef PlaybackInfo 3410 * @syscap SystemCapability.Multimedia.Media.Core 3411 * @since 12 3412 */ 3413 interface PlaybackInfo { 3414 /** 3415 * key:value pair, key see @PlaybackInfoKey. 3416 * @syscap SystemCapability.Multimedia.Media.Core 3417 * @since 12 3418 */ 3419 [key:string]: Object; 3420 } 3421 3422 /** 3423 * Enumerates statistics info keys for player. 3424 * 3425 * @enum { string } 3426 * @syscap SystemCapability.Multimedia.Media.Core 3427 * @since 12 3428 */ 3429 enum PlaybackInfoKey { 3430 /** 3431 * IP address of current network stream. 3432 * @syscap SystemCapability.Multimedia.Media.Core 3433 * @since 12 3434 */ 3435 SERVER_IP_ADDRESS = 'server_ip_address', 3436 3437 /** 3438 * Average download rate during playing except for suspend downloading. 3439 * @syscap SystemCapability.Multimedia.Media.Core 3440 * @since 12 3441 */ 3442 AVG_DOWNLOAD_RATE = 'average_download_rate', 3443 3444 /** 3445 * Current download rate of the last second except for suspend downloading. 3446 * @syscap SystemCapability.Multimedia.Media.Core 3447 * @since 12 3448 */ 3449 DOWNLOAD_RATE = 'download_rate', 3450 3451 /** 3452 * Boolean value, true for current is downloading, false for suspend downloading. 3453 * @syscap SystemCapability.Multimedia.Media.Core 3454 * @since 12 3455 */ 3456 IS_DOWNLOADING = 'is_downloading', 3457 3458 /** 3459 * Cached duration in milliseconds. 3460 * @syscap SystemCapability.Multimedia.Media.Core 3461 * @since 12 3462 */ 3463 BUFFER_DURATION = 'buffer_duration', 3464 } 3465 3466 /** 3467 * Enumerates ErrorCode types, return in BusinessError::code 3468 * 3469 * @enum { number } 3470 * @syscap SystemCapability.Multimedia.Media.Core 3471 * @since 8 3472 * @deprecated since 11 3473 * @useinstead ohos.multimedia.media/media.AVErrorCode 3474 */ 3475 enum MediaErrorCode { 3476 /** 3477 * operation success. 3478 * @syscap SystemCapability.Multimedia.Media.Core 3479 * @since 8 3480 * @deprecated since 11 3481 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_OK 3482 */ 3483 MSERR_OK = 0, 3484 3485 /** 3486 * malloc or new memory failed. maybe system have no memory. 3487 * @syscap SystemCapability.Multimedia.Media.Core 3488 * @since 8 3489 * @deprecated since 11 3490 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_NO_MEMORY 3491 */ 3492 MSERR_NO_MEMORY = 1, 3493 3494 /** 3495 * no permission for the operation. 3496 * @syscap SystemCapability.Multimedia.Media.Core 3497 * @since 8 3498 * @deprecated since 11 3499 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_OPERATE_NOT_PERMIT 3500 */ 3501 MSERR_OPERATION_NOT_PERMIT = 2, 3502 3503 /** 3504 * invalid argument. 3505 * @syscap SystemCapability.Multimedia.Media.Core 3506 * @since 8 3507 * @deprecated since 11 3508 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_INVALID_PARAMETER 3509 */ 3510 MSERR_INVALID_VAL = 3, 3511 3512 /** 3513 * an I/O error occurred. 3514 * @syscap SystemCapability.Multimedia.Media.Core 3515 * @since 8 3516 * @deprecated since 11 3517 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_IO 3518 */ 3519 MSERR_IO = 4, 3520 3521 /** 3522 * operation time out. 3523 * @syscap SystemCapability.Multimedia.Media.Core 3524 * @since 8 3525 * @deprecated since 11 3526 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_TIMEOUT 3527 */ 3528 MSERR_TIMEOUT = 5, 3529 3530 /** 3531 * unknown error. 3532 * @syscap SystemCapability.Multimedia.Media.Core 3533 * @since 8 3534 * @deprecated since 11 3535 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_INVALID_PARAMETER 3536 */ 3537 MSERR_UNKNOWN = 6, 3538 3539 /** 3540 * media service died. 3541 * @syscap SystemCapability.Multimedia.Media.Core 3542 * @since 8 3543 * @deprecated since 11 3544 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_SERVICE_DIED 3545 */ 3546 MSERR_SERVICE_DIED = 7, 3547 3548 /** 3549 * operation is not permit in current state. 3550 * @syscap SystemCapability.Multimedia.Media.Core 3551 * @since 8 3552 * @deprecated since 11 3553 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_INVALID_PARAMETER 3554 */ 3555 MSERR_INVALID_STATE = 8, 3556 3557 /** 3558 * operation is not supported in current version. 3559 * @syscap SystemCapability.Multimedia.Media.Core 3560 * @since 8 3561 * @deprecated since 11 3562 * @useinstead ohos.multimedia.media/media.AVErrorCode#AVERR_UNSUPPORT_CAPABILITY 3563 */ 3564 MSERR_UNSUPPORTED = 9, 3565 } 3566 3567 /** 3568 * Enumerates buffering info type, for network playback. 3569 * 3570 * @enum { number } 3571 * @syscap SystemCapability.Multimedia.Media.Core 3572 * @since 8 3573 */ 3574 /** 3575 * Enumerates buffering info type, for network playback. 3576 * 3577 * @enum { number } 3578 * @syscap SystemCapability.Multimedia.Media.Core 3579 * @crossplatform 3580 * @atomicservice 3581 * @since 12 3582 */ 3583 enum BufferingInfoType { 3584 /** 3585 * begin to buffering 3586 * @syscap SystemCapability.Multimedia.Media.Core 3587 * @since 8 3588 */ 3589 /** 3590 * begin to buffering 3591 * @syscap SystemCapability.Multimedia.Media.Core 3592 * @crossplatform 3593 * @atomicservice 3594 * @since 12 3595 */ 3596 BUFFERING_START = 1, 3597 3598 /** 3599 * end to buffering 3600 * @syscap SystemCapability.Multimedia.Media.Core 3601 * @since 8 3602 */ 3603 /** 3604 * end to buffering 3605 * @syscap SystemCapability.Multimedia.Media.Core 3606 * @crossplatform 3607 * @atomicservice 3608 * @since 12 3609 */ 3610 BUFFERING_END = 2, 3611 3612 /** 3613 * buffering percent 3614 * @syscap SystemCapability.Multimedia.Media.Core 3615 * @since 8 3616 */ 3617 /** 3618 * buffering percent 3619 * @syscap SystemCapability.Multimedia.Media.Core 3620 * @crossplatform 3621 * @atomicservice 3622 * @since 12 3623 */ 3624 BUFFERING_PERCENT = 3, 3625 3626 /** 3627 * cached duration in milliseconds 3628 * @syscap SystemCapability.Multimedia.Media.Core 3629 * @since 8 3630 */ 3631 /** 3632 * cached duration in milliseconds 3633 * @syscap SystemCapability.Multimedia.Media.Core 3634 * @crossplatform 3635 * @atomicservice 3636 * @since 12 3637 */ 3638 CACHED_DURATION = 4, 3639 } 3640 3641 /** 3642 * Media source descriptor. User can set media data information 3643 3644 * @typedef MediaSource 3645 * @syscap SystemCapability.Multimedia.Media.Core 3646 * @atomicservice 3647 * @since 12 3648 */ 3649 interface MediaSource { 3650 /** 3651 * Set Media Mime Type to help player handle extended Media source. 3652 * @param { AVMimeTypes } mimeType - for MediaSource define. see @ AVMimeTypes. 3653 * @syscap SystemCapability.Multimedia.Media.Core 3654 * @atomicservice 3655 * @since 12 3656 */ 3657 setMimeType(mimeType: AVMimeTypes): void; 3658 } 3659 3660 /** 3661 * Enumerates Media Mime types, used for MediaSource define; 3662 * @enum { string } 3663 * @syscap SystemCapability.Multimedia.Media.Core 3664 * @atomicservice 3665 * @since 12 3666 */ 3667 enum AVMimeTypes { 3668 /** 3669 * Indicate current file is index file for hls Media. 3670 * @syscap SystemCapability.Multimedia.Media.Core 3671 * @atomicservice 3672 * @since 12 3673 */ 3674 APPLICATION_M3U8 = 'application/m3u8', 3675 } 3676 /** 3677 * Provides preferred playback settings for player. 3678 * 3679 * @typedef PlaybackStrategy 3680 * @syscap SystemCapability.Multimedia.Media.Core 3681 * @atomicservice 3682 * @since 12 3683 */ 3684 interface PlaybackStrategy { 3685 /** 3686 * Choose a stream with width close to it. 3687 * @type { ?number } 3688 * @syscap SystemCapability.Multimedia.Media.Core 3689 * @atomicservice 3690 * @since 12 3691 */ 3692 preferredWidth?: number; 3693 /** 3694 * Choose a stream with height close to it. 3695 * @type { ?number } 3696 * @syscap SystemCapability.Multimedia.Media.Core 3697 * @atomicservice 3698 * @since 12 3699 */ 3700 preferredHeight?: number; 3701 /** 3702 * Choose a preferred buffer duration. 3703 * @type { ?number } 3704 * @syscap SystemCapability.Multimedia.Media.Core 3705 * @atomicservice 3706 * @since 12 3707 */ 3708 preferredBufferDuration?: number; 3709 3710 /** 3711 * If true, the player should choose HDR stream if exist. 3712 * @type { ?boolean } 3713 * @syscap SystemCapability.Multimedia.Media.Core 3714 * @atomicservice 3715 * @since 12 3716 */ 3717 preferredHdr?: boolean; 3718 3719 /** 3720 * mute the specified media stream when playing. 3721 * @type { ?MediaType } 3722 * @syscap SystemCapability.Multimedia.Media.Core 3723 * @since 12 3724 */ 3725 mutedMediaType?: MediaType; 3726 3727 /** 3728 * Audio language. 3729 * @type { ?string } 3730 * @syscap SystemCapability.Multimedia.Media.Core 3731 * @atomicservice 3732 * @since 13 3733 */ 3734 preferredAudioLanguage?: string; 3735 3736 /** 3737 * Subtitle language. 3738 * @type { ?string } 3739 * @syscap SystemCapability.Multimedia.Media.Core 3740 * @atomicservice 3741 * @since 13 3742 */ 3743 preferredSubtitleLanguage?: string; 3744 } 3745 3746 /** 3747 * Media file descriptor. The caller needs to ensure that the fd is valid and 3748 * the offset and length are correct. 3749 * 3750 * @typedef AVFileDescriptor 3751 * @syscap SystemCapability.Multimedia.Media.Core 3752 * @since 9 3753 */ 3754 /** 3755 * Media file descriptor. The caller needs to ensure that the fd is valid and 3756 * the offset and length are correct. 3757 * 3758 * @typedef AVFileDescriptor 3759 * @syscap SystemCapability.Multimedia.Media.Core 3760 * @atomicservice 3761 * @since 11 3762 */ 3763 /** 3764 * Media file descriptor. The caller needs to ensure that the fd is valid and 3765 * the offset and length are correct. 3766 * 3767 * @typedef AVFileDescriptor 3768 * @syscap SystemCapability.Multimedia.Media.Core 3769 * @crossplatform 3770 * @atomicservice 3771 * @since 12 3772 */ 3773 interface AVFileDescriptor { 3774 /** 3775 * The file descriptor of audio or video source from file system. The caller 3776 * is responsible to close the file descriptor. 3777 * @syscap SystemCapability.Multimedia.Media.Core 3778 * @since 9 3779 */ 3780 /** 3781 * The file descriptor of audio or video source from file system. The caller 3782 * is responsible to close the file descriptor. 3783 * @syscap SystemCapability.Multimedia.Media.Core 3784 * @atomicservice 3785 * @since 11 3786 */ 3787 /** 3788 * The file descriptor of audio or video source from file system. The caller 3789 * is responsible to close the file descriptor. 3790 * @type { number } 3791 * @syscap SystemCapability.Multimedia.Media.Core 3792 * @crossplatform 3793 * @atomicservice 3794 * @since 12 3795 */ 3796 fd: number 3797 3798 /** 3799 * The offset into the file where the data to be read, in bytes. By default, 3800 * the offset is zero. 3801 * @syscap SystemCapability.Multimedia.Media.Core 3802 * @since 9 3803 */ 3804 /** 3805 * The offset into the file where the data to be read, in bytes. By default, 3806 * the offset is zero. 3807 * @syscap SystemCapability.Multimedia.Media.Core 3808 * @atomicservice 3809 * @since 11 3810 */ 3811 /** 3812 * The offset into the file where the data to be read, in bytes. By default, 3813 * the offset is zero. 3814 * @type { ?number } 3815 * @syscap SystemCapability.Multimedia.Media.Core 3816 * @crossplatform 3817 * @atomicservice 3818 * @since 12 3819 */ 3820 offset?: number 3821 3822 /** 3823 * The length in bytes of the data to be read. By default, the length is the 3824 * rest of bytes in the file from the offset. 3825 * @syscap SystemCapability.Multimedia.Media.Core 3826 * @since 9 3827 */ 3828 /** 3829 * The length in bytes of the data to be read. By default, the length is the 3830 * rest of bytes in the file from the offset. 3831 * @syscap SystemCapability.Multimedia.Media.Core 3832 * @atomicservice 3833 * @since 11 3834 */ 3835 /** 3836 * The length in bytes of the data to be read. By default, the length is the 3837 * rest of bytes in the file from the offset. 3838 * @type { ?number } 3839 * @syscap SystemCapability.Multimedia.Media.Core 3840 * @crossplatform 3841 * @atomicservice 3842 * @since 12 3843 */ 3844 length?: number 3845 } 3846 3847 /** 3848 * DataSource descriptor. The caller needs to ensure that the fileSize and 3849 * callback is valid. 3850 * 3851 * @typedef AVDataSrcDescriptor 3852 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3853 * @since 10 3854 */ 3855 /** 3856 * DataSource descriptor. The caller needs to ensure that the fileSize and 3857 * callback is valid. 3858 * 3859 * @typedef AVDataSrcDescriptor 3860 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3861 * @atomicservice 3862 * @since 11 3863 */ 3864 /** 3865 * DataSource descriptor. The caller needs to ensure that the fileSize and 3866 * callback is valid. 3867 * 3868 * @typedef AVDataSrcDescriptor 3869 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3870 * @crossplatform 3871 * @atomicservice 3872 * @since 12 3873 */ 3874 interface AVDataSrcDescriptor { 3875 /** 3876 * Size of the file, -1 means the file size is unknown, in this case, 3877 * seek and setSpeed can't be executed, loop can't be set, and can't replay. 3878 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3879 * @since 10 3880 */ 3881 /** 3882 * Size of the file, -1 means the file size is unknown, in this case, 3883 * seek and setSpeed can't be executed, loop can't be set, and can't replay. 3884 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3885 * @atomicservice 3886 * @since 11 3887 */ 3888 /** 3889 * Size of the file, -1 means the file size is unknown, in this case, 3890 * seek and setSpeed can't be executed, loop can't be set, and can't replay. 3891 * @type { number } 3892 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3893 * @crossplatform 3894 * @atomicservice 3895 * @since 12 3896 */ 3897 fileSize: number; 3898 /** 3899 * Callback function implemented by users, which is used to fill data. 3900 * buffer - The buffer need to fill. 3901 * length - The stream length player want to get. 3902 * pos - The stream position player want get start, and is an optional parameter. 3903 * When fileSize set to -1, this parameter is not used. 3904 * Returns length of the data to be filled. 3905 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3906 * @since 10 3907 */ 3908 /** 3909 * Callback function implemented by users, which is used to fill data. 3910 * buffer - The buffer need to fill. 3911 * length - The stream length player want to get. 3912 * pos - The stream position player want get start, and is an optional parameter. 3913 * When fileSize set to -1, this parameter is not used. 3914 * Returns length of the data to be filled. 3915 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3916 * @atomicservice 3917 * @since 11 3918 */ 3919 /** 3920 * Callback function implemented by users, which is used to fill data. 3921 * buffer - The buffer need to fill. 3922 * length - The stream length player want to get. 3923 * pos - The stream position player want get start, and is an optional parameter. 3924 * When fileSize set to -1, this parameter is not used. 3925 * Returns length of the data to be filled. 3926 * @type { function } 3927 * @syscap SystemCapability.Multimedia.Media.AVPlayer 3928 * @crossplatform 3929 * @atomicservice 3930 * @since 12 3931 */ 3932 callback: (buffer: ArrayBuffer, length: number, pos?: number) => number; 3933 } 3934 3935 /** 3936 * Provides subtitle information. 3937 * Can be synchronized to the time reported by AVPlayer#timeUpdate event 3938 * 3939 * @typedef SubtitleInfo 3940 * @syscap SystemCapability.Multimedia.Media.Core 3941 * @atomicservice 3942 * @since 12 3943 */ 3944 interface SubtitleInfo { 3945 /** 3946 * Duration of the text to be displayed, as milliseconds. 3947 * @type { ?number } 3948 * @syscap SystemCapability.Multimedia.Media.Core 3949 * @atomicservice 3950 * @since 12 3951 */ 3952 duration?: number; 3953 /** 3954 * Display start time of the text, as milliseconds. 3955 * @type { ?number } 3956 * @syscap SystemCapability.Multimedia.Media.Core 3957 * @atomicservice 3958 * @since 12 3959 */ 3960 startTime?: number; 3961 /** 3962 * Text information of current update event. 3963 * @type { ?string } 3964 * @syscap SystemCapability.Multimedia.Media.Core 3965 * @atomicservice 3966 * @since 12 3967 */ 3968 text?: string; 3969 } 3970 3971 /** 3972 * Describes audio playback states. 3973 * @typedef { 'idle' | 'playing' | 'paused' | 'stopped' | 'error' } 3974 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 3975 * @since 6 3976 * @deprecated since 9 3977 * @useinstead ohos.multimedia.media/media.AVPlayerState 3978 */ 3979 type AudioState = 'idle' | 'playing' | 'paused' | 'stopped' | 'error'; 3980 3981 /** 3982 * Manages and plays audio. Before calling an AudioPlayer method, you must use createAudioPlayer() 3983 * to create an AudioPlayer instance. 3984 * 3985 * @typedef AudioPlayer 3986 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 3987 * @since 6 3988 * @deprecated since 9 3989 * @useinstead ohos.multimedia.media/media.AVPlayer 3990 */ 3991 interface AudioPlayer { 3992 /** 3993 * Starts audio playback. 3994 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 3995 * @since 6 3996 * @deprecated since 9 3997 * @useinstead ohos.multimedia.media/media.AVPlayer#play 3998 */ 3999 play(): void; 4000 4001 /** 4002 * Pauses audio playback. 4003 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4004 * @since 6 4005 * @deprecated since 9 4006 * @useinstead ohos.multimedia.media/media.AVPlayer#pause 4007 */ 4008 pause(): void; 4009 4010 /** 4011 * Stops audio playback. 4012 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4013 * @since 6 4014 * @deprecated since 9 4015 * @useinstead ohos.multimedia.media/media.AVPlayer#stop 4016 */ 4017 stop(): void; 4018 4019 /** 4020 * Resets audio playback. 4021 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4022 * @since 7 4023 * @deprecated since 9 4024 * @useinstead ohos.multimedia.media/media.AVPlayer#reset 4025 */ 4026 reset(): void; 4027 4028 /** 4029 * Jumps to the specified playback position. 4030 * @param { number } timeMs - Playback position to jump 4031 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4032 * @since 6 4033 * @deprecated since 9 4034 * @useinstead ohos.multimedia.media/media.AVPlayer#seek 4035 */ 4036 seek(timeMs: number): void; 4037 4038 /** 4039 * Sets the volume. 4040 * @param { number } vol - Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). 4041 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4042 * @since 6 4043 * @deprecated since 9 4044 * @useinstead ohos.multimedia.media/media.AVPlayer#setVolume 4045 */ 4046 setVolume(vol: number): void; 4047 4048 /** 4049 * Releases resources used for audio playback. 4050 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4051 * @since 6 4052 * @deprecated since 9 4053 * @useinstead ohos.multimedia.media/media.AVPlayer#release 4054 */ 4055 release(): void; 4056 4057 /** 4058 * Get all track infos in MediaDescription, should be called after data loaded callback. 4059 * @param { AsyncCallback<Array<MediaDescription>> } callback - async callback return track info in MediaDescription. 4060 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4061 * @since 8 4062 * @deprecated since 9 4063 * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription 4064 */ 4065 getTrackDescription(callback: AsyncCallback<Array<MediaDescription>>): void; 4066 4067 /** 4068 * Get all track infos in MediaDescription, should be called after data loaded callback. 4069 * @returns { Promise<Array<MediaDescription>> } A Promise instance used to return the track info in MediaDescription. 4070 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4071 * @since 8 4072 * @deprecated since 9 4073 * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription 4074 */ 4075 getTrackDescription(): Promise<Array<MediaDescription>>; 4076 4077 /** 4078 * Listens for audio playback buffering events. 4079 * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. 4080 * @param { function } callback - Callback used to listen for the buffering update event, 4081 * return BufferingInfoType and the value. 4082 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4083 * @since 8 4084 * @deprecated since 9 4085 * @useinstead ohos.multimedia.media/media.AVPlayer#event:bufferingUpdate 4086 */ 4087 on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; 4088 4089 /** 4090 * Audio media URI. Mainstream audio formats are supported. 4091 * local:fd://XXX, file://XXX. network:http://xxx 4092 * @type { string } 4093 * @permission ohos.permission.READ_MEDIA or ohos.permission.INTERNET 4094 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4095 * @since 6 4096 * @deprecated since 9 4097 * @useinstead ohos.multimedia.media/media.AVPlayer#url 4098 */ 4099 src: string; 4100 4101 /** 4102 * Audio file descriptor. Mainstream audio formats are supported. 4103 * @type { AVFileDescriptor } 4104 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4105 * @since 9 4106 * @deprecated since 9 4107 * @useinstead ohos.multimedia.media/media.AVPlayer#fdSrc 4108 */ 4109 fdSrc: AVFileDescriptor; 4110 4111 /** 4112 * Whether to loop audio playback. The value true means to loop playback. 4113 * @type { boolean } 4114 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4115 * @since 6 4116 * @deprecated since 9 4117 * @useinstead ohos.multimedia.media/media.AVPlayer#loop 4118 */ 4119 loop: boolean; 4120 4121 /** 4122 * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not 4123 * set, the default mode will be used. Set it before calling the {@link #play()} in the 4124 * first time in order for the interrupt mode to become effective thereafter. 4125 * @type { ?audio.InterruptMode } 4126 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4127 * @since 9 4128 * @deprecated since 9 4129 * @useinstead ohos.multimedia.media/media.AVPlayer#audioInterruptMode 4130 */ 4131 audioInterruptMode?: audio.InterruptMode; 4132 4133 /** 4134 * Current playback position. 4135 * @type { number } 4136 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4137 * @since 6 4138 * @deprecated since 9 4139 * @useinstead ohos.multimedia.media/media.AVPlayer#currentTime 4140 */ 4141 readonly currentTime: number; 4142 4143 /** 4144 * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario. 4145 * @type { number } 4146 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4147 * @since 6 4148 * @deprecated since 9 4149 * @useinstead ohos.multimedia.media/media.AVPlayer#duration 4150 */ 4151 readonly duration: number; 4152 4153 /** 4154 * Playback state. 4155 * @type { AudioState } 4156 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4157 * @since 6 4158 * @deprecated since 9 4159 * @useinstead ohos.multimedia.media/media.AVPlayer#state 4160 */ 4161 readonly state: AudioState; 4162 4163 /** 4164 * Listens for audio playback events. 4165 * @param { 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeChange' } type - Type of the playback event to listen for. 4166 * @param { function } callback - Callback used to listen for the playback event. 4167 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4168 * @since 6 4169 * @deprecated since 9 4170 * @useinstead ohos.multimedia.media/media.AVPlayer#event:stateChange 4171 */ 4172 on(type: 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeChange', callback: () => void): void; 4173 4174 /** 4175 * Listens for audio playback events. 4176 * @param { 'timeUpdate' } type - Type of the playback event to listen for. 4177 * @param { Callback<number> } callback - Callback used to listen for the playback event. 4178 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4179 * @since 6 4180 * @deprecated since 9 4181 * @useinstead ohos.multimedia.media/media.AVPlayer#event:timeUpdate 4182 */ 4183 on(type: 'timeUpdate', callback: Callback<number>): void; 4184 4185 /** 4186 * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent} 4187 * @param { 'audioInterrupt' } type - Type of the playback event to listen for. 4188 * @param { function } callback - Callback used to listen for the playback event return audio interrupt info. 4189 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4190 * @since 9 4191 * @deprecated since 9 4192 * @useinstead ohos.multimedia.media/media.AVPlayer#event:audioInterrupt 4193 */ 4194 on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; 4195 4196 /** 4197 * Listens for playback error events. 4198 * @param { 'error' } type - Type of the playback error event to listen for. 4199 * @param { ErrorCallback } callback - Callback used to listen for the playback error event. 4200 * @syscap SystemCapability.Multimedia.Media.AudioPlayer 4201 * @since 6 4202 * @deprecated since 9 4203 * @useinstead ohos.multimedia.media/media.AVPlayer#event:error 4204 */ 4205 on(type: 'error', callback: ErrorCallback): void; 4206 } 4207 4208 /** 4209 * Describes media recorder states. 4210 * @typedef {'idle' | 'prepared' | 'started' | 'paused' | 'stopped' | 'released' | 'error'} 4211 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4212 * @since 9 4213 */ 4214 /** 4215 * Describes media recorder states. 4216 * @typedef {'idle' | 'prepared' | 'started' | 'paused' | 'stopped' | 'released' | 'error'} 4217 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4218 * @crossplatform 4219 * @atomicservice 4220 * @since 12 4221 */ 4222 type AVRecorderState = 'idle' | 'prepared' | 'started' | 'paused' | 'stopped' | 'released' | 'error'; 4223 4224 /** 4225 * Defines the onMove callback. 4226 * 4227 * @typedef { function } OnAVRecorderStateChangeHandler 4228 * @param { AVRecorderState } state - state value for AVRecorder. 4229 * @param { StateChangeReason } reason - reason for state change. 4230 * @syscap SystemCapability.Multimedia.Media.AVPlayer 4231 * @crossplatform 4232 * @atomicservice 4233 * @since 12 4234 */ 4235 type OnAVRecorderStateChangeHandler = (state: AVRecorderState, reason: StateChangeReason) => void; 4236 4237 /** 4238 * Manages and record audio/video. Before calling an AVRecorder method, you must use createAVRecorder() 4239 * to create an AVRecorder instance. 4240 * 4241 * @typedef AVRecorder 4242 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4243 * @since 9 4244 */ 4245 /** 4246 * Manages and record audio/video. Before calling an AVRecorder method, you must use createAVRecorder() 4247 * to create an AVRecorder instance. 4248 * 4249 * @typedef AVRecorder 4250 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4251 * @crossplatform 4252 * @atomicservice 4253 * @since 12 4254 */ 4255 interface AVRecorder { 4256 /** 4257 * Prepares for recording. 4258 * @permission ohos.permission.MICROPHONE 4259 * @param { AVRecorderConfig } config - Recording parameters. 4260 * @param { AsyncCallback<void> } callback - A callback instance used to return when prepare completed. 4261 * @throws { BusinessError } 201 - Permission denied. Return by callback. 4262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4263 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4264 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4265 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4266 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4267 * @since 9 4268 */ 4269 /** 4270 * Prepares for recording. 4271 * @permission ohos.permission.MICROPHONE 4272 * @param { AVRecorderConfig } config - Recording parameters. 4273 * @param { AsyncCallback<void> } callback - A callback instance used to return when prepare completed. 4274 * @throws { BusinessError } 201 - Permission denied. Return by callback. 4275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4276 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4277 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4278 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4279 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4280 * @crossplatform 4281 * @since 12 4282 */ 4283 prepare(config: AVRecorderConfig, callback: AsyncCallback<void>): void; 4284 4285 /** 4286 * Prepares for recording. 4287 * @permission ohos.permission.MICROPHONE 4288 * @param { AVRecorderConfig } config - Recording parameters. 4289 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 4290 * @throws { BusinessError } 201 - Permission denied. Return by promise. 4291 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 4292 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4293 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4294 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4295 * @since 9 4296 */ 4297 /** 4298 * Prepares for recording. 4299 * @permission ohos.permission.MICROPHONE 4300 * @param { AVRecorderConfig } config - Recording parameters. 4301 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 4302 * @throws { BusinessError } 201 - Permission denied. Return by promise. 4303 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4304 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4305 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4306 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4307 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4308 * @crossplatform 4309 * @atomicservice 4310 * @since 12 4311 */ 4312 prepare(config: AVRecorderConfig): Promise<void>; 4313 4314 /** 4315 * Get AVRecorderConfig.it must be called after prepare. 4316 * @param { AsyncCallback<AVRecorderConfig> } callback - Callback used to return the input config in AVRecorderConfig. 4317 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4318 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4319 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4320 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4321 * @since 11 4322 */ 4323 getAVRecorderConfig(callback: AsyncCallback<AVRecorderConfig>): void; 4324 4325 /** 4326 * Get AVRecorderConfig.it must be called after prepare. 4327 * @returns { Promise<AVRecorderConfig> } A Promise instance used to return the input config in AVRecorderConfig. 4328 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4329 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4330 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4331 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4332 * @since 11 4333 */ 4334 getAVRecorderConfig(): Promise<AVRecorderConfig>; 4335 4336 /** 4337 * Get input surface.it must be called between prepare completed and start. 4338 * @param { AsyncCallback<string> } callback - Callback used to return the input surface id in string. 4339 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4340 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4341 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4342 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4343 * @since 9 4344 */ 4345 getInputSurface(callback: AsyncCallback<string>): void; 4346 4347 /** 4348 * Get input surface. it must be called between prepare completed and start. 4349 * @returns { Promise<string> } A Promise instance used to return the input surface id in string. 4350 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4351 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4352 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4353 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4354 * @since 9 4355 */ 4356 getInputSurface(): Promise<string>; 4357 4358 /** 4359 * Get input meta surface for specified meta source type. it must be called between prepare completed and start. 4360 * @param { MetaSourceType } type - Meta source type. 4361 * @returns { Promise<string> } A Promise instance used to return the input surface id in string. 4362 * @throws { BusinessError } 202 - Called from Non-System applications. Return by promise. 4363 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4364 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4365 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4366 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4367 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4368 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4369 * @systemapi 4370 * @since 12 4371 */ 4372 getInputMetaSurface(type: MetaSourceType): Promise<string>; 4373 4374 /** 4375 * Check if the avrecorder has watermark capability. 4376 * @returns { Promise<boolean> } A Promise instance used to return true or false when the function is finished. 4377 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4378 * @systemapi 4379 * @since 12 4380 */ 4381 isWatermarkSupported(): Promise<boolean>; 4382 /** 4383 * Set watermark image to recorder. 4384 * @param { image.PixelMap } watermark : Watermark image. 4385 * @param { WatermarkConfig } config : Configures of the watermark. 4386 * @returns { Promise<void> } A Promise instance used to return when the function is finished. 4387 * @throws { BusinessError } 401 - The parameter check failed. 4388 * @throws { BusinessError } 801 - Capability not supported. 4389 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4390 * @systemapi 4391 * @since 12 4392 */ 4393 setWatermark(watermark: image.PixelMap, config: WatermarkConfig): Promise<void> 4394 /** 4395 * Update the video orientation before recorder start. 4396 * @param { number } rotation - Rotation angle, should be [0, 90, 180, 270]. 4397 * @returns { Promise<void> } A Promise instance used to return when the function is finished. 4398 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4399 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4400 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 4401 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4402 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4403 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4404 * @since 12 4405 */ 4406 updateRotation(rotation: number): Promise<void>; 4407 4408 /** 4409 * Start AVRecorder, it will to started state. 4410 * @param { AsyncCallback<void> } callback - A callback instance used to return when start completed. 4411 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4412 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4413 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4414 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4415 * @since 9 4416 */ 4417 /** 4418 * Start AVRecorder, it will to started state. 4419 * @param { AsyncCallback<void> } callback - A callback instance used to return when start completed. 4420 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4421 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4422 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4423 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4424 * @crossplatform 4425 * @since 12 4426 */ 4427 start(callback: AsyncCallback<void>): void; 4428 4429 /** 4430 * Start AVRecorder, it will to started state. 4431 * @returns { Promise<void> } A Promise instance used to return when start completed. 4432 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4433 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4434 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4435 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4436 * @since 9 4437 */ 4438 /** 4439 * Start AVRecorder, it will to started state. 4440 * @returns { Promise<void> } A Promise instance used to return when start completed. 4441 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4442 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4443 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4444 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4445 * @crossplatform 4446 * @atomicservice 4447 * @since 12 4448 */ 4449 start(): Promise<void>; 4450 4451 /** 4452 * Start AVRecorder, it will to paused state. 4453 * @param { AsyncCallback<void> } callback - A callback instance used to return when pause completed. 4454 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4455 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4456 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4457 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4458 * @since 9 4459 */ 4460 /** 4461 * Start AVRecorder, it will to paused state. 4462 * @param { AsyncCallback<void> } callback - A callback instance used to return when pause completed. 4463 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4464 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4465 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4466 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4467 * @crossplatform 4468 * @since 12 4469 */ 4470 pause(callback: AsyncCallback<void>): void; 4471 4472 /** 4473 * Start AVRecorder, it will to paused state. 4474 * @returns { Promise<void> } A Promise instance used to return when pause completed. 4475 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4476 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4477 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4478 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4479 * @since 9 4480 */ 4481 /** 4482 * Start AVRecorder, it will to paused state. 4483 * @returns { Promise<void> } A Promise instance used to return when pause completed. 4484 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4485 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4486 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4487 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4488 * @crossplatform 4489 * @atomicservice 4490 * @since 12 4491 */ 4492 pause(): Promise<void>; 4493 4494 /** 4495 * Resume AVRecorder, it will to started state. 4496 * @param { AsyncCallback<void> } callback - A callback instance used to return when resume completed. 4497 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4498 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4499 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4500 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4501 * @since 9 4502 */ 4503 /** 4504 * Resume AVRecorder, it will to started state. 4505 * @param { AsyncCallback<void> } callback - A callback instance used to return when resume completed. 4506 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4507 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4508 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4509 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4510 * @crossplatform 4511 * @since 12 4512 */ 4513 resume(callback: AsyncCallback<void>): void; 4514 4515 /** 4516 * Resume AVRecorder, it will to started state. 4517 * @returns { Promise<void> } A Promise instance used to return when resume completed. 4518 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4519 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4520 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4521 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4522 * @since 9 4523 */ 4524 /** 4525 * Resume AVRecorder, it will to started state. 4526 * @returns { Promise<void> } A Promise instance used to return when resume completed. 4527 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4528 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4529 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4530 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4531 * @crossplatform 4532 * @atomicservice 4533 * @since 12 4534 */ 4535 resume(): Promise<void>; 4536 4537 /** 4538 * Stop AVRecorder, it will to stopped state. 4539 * @param { AsyncCallback<void> } callback - A callback instance used to return when stop completed. 4540 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4541 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4542 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4543 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4544 * @since 9 4545 */ 4546 /** 4547 * Stop AVRecorder, it will to stopped state. 4548 * @param { AsyncCallback<void> } callback - A callback instance used to return when stop completed. 4549 * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. 4550 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4551 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4552 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4553 * @crossplatform 4554 * @since 12 4555 */ 4556 stop(callback: AsyncCallback<void>): void; 4557 4558 /** 4559 * Stop AVRecorder, it will to stopped state. 4560 * @returns { Promise<void> } A Promise instance used to return when stop completed. 4561 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4562 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4563 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4564 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4565 * @since 9 4566 */ 4567 /** 4568 * Stop AVRecorder, it will to stopped state. 4569 * @returns { Promise<void> } A Promise instance used to return when stop completed. 4570 * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. 4571 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4572 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4573 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4574 * @crossplatform 4575 * @atomicservice 4576 * @since 12 4577 */ 4578 stop(): Promise<void>; 4579 4580 /** 4581 * Reset AVRecorder, it will to idle state. 4582 * @param { AsyncCallback<void> } callback - A callback instance used to return when reset completed. 4583 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4584 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4585 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4586 * @since 9 4587 */ 4588 /** 4589 * Reset AVRecorder, it will to idle state. 4590 * @param { AsyncCallback<void> } callback - A callback instance used to return when reset completed. 4591 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4592 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4593 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4594 * @crossplatform 4595 * @since 12 4596 */ 4597 reset(callback: AsyncCallback<void>): void; 4598 4599 /** 4600 * Reset AVRecorder, it will to idle state. 4601 * @returns { Promise<void> } A Promise instance used to return when reset completed. 4602 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4603 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4604 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4605 * @since 9 4606 */ 4607 /** 4608 * Reset AVRecorder, it will to idle state. 4609 * @returns { Promise<void> } A Promise instance used to return when reset completed. 4610 * @throws { BusinessError } 5400103 - IO error. Return by promise. 4611 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4612 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4613 * @crossplatform 4614 * @since 12 4615 */ 4616 reset(): Promise<void>; 4617 4618 /** 4619 * Releases resources used for AVRecorder, it will to released state. 4620 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 4621 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4622 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4623 * @since 9 4624 */ 4625 /** 4626 * Releases resources used for AVRecorder, it will to released state. 4627 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 4628 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4629 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4630 * @crossplatform 4631 * @since 12 4632 */ 4633 release(callback: AsyncCallback<void>): void; 4634 4635 /** 4636 * Releases resources used for AVRecorder, it will to released state. 4637 * @returns { Promise<void> } A Promise instance used to return when release completed. 4638 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4639 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4640 * @since 9 4641 */ 4642 /** 4643 * Releases resources used for AVRecorder, it will to released state. 4644 * @returns { Promise<void> } A Promise instance used to return when release completed. 4645 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4646 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4647 * @crossplatform 4648 * @atomicservice 4649 * @since 12 4650 */ 4651 release(): Promise<void>; 4652 4653 /** 4654 * Get AudioCapturer info from current AVRecorder. 4655 * @param { AsyncCallback<audio.AudioCapturerChangeInfo> } callback - A callback used to return AudioCapturerChangeInfo. 4656 * @throws { BusinessError } 5400102 - Operation not allowed. 4657 * @throws { BusinessError } 5400103 - I/O error. 4658 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4659 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4660 * @since 11 4661 */ 4662 getCurrentAudioCapturerInfo(callback: AsyncCallback<audio.AudioCapturerChangeInfo>): void; 4663 4664 /** 4665 * Get AudioCapturer info from current AVRecorder. 4666 * @returns { Promise<audio.AudioCapturerChangeInfo> } A Promise instance used to return AudioCapturerChangeInfo. 4667 * @throws { BusinessError } 5400102 - Operation not allowed. 4668 * @throws { BusinessError } 5400103 - I/O error. 4669 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4670 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4671 * @since 11 4672 */ 4673 getCurrentAudioCapturerInfo(): Promise<audio.AudioCapturerChangeInfo>; 4674 4675 /** 4676 * Get max audio capturer amplitude from current AVRecorder. 4677 * @param { AsyncCallback<number> } callback - A callback used to return max Amplitude. 4678 * @throws { BusinessError } 5400102 - Operation not allowed. 4679 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4680 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4681 * @since 11 4682 */ 4683 getAudioCapturerMaxAmplitude(callback: AsyncCallback<number>): void; 4684 4685 /** 4686 * Get max audio capturer amplitude from current AVRecorder. 4687 * @returns { Promise<number> } A Promise instance used to return max Amplitude. 4688 * @throws { BusinessError } 5400102 - Operation not allowed. 4689 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4690 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4691 * @since 11 4692 */ 4693 getAudioCapturerMaxAmplitude(): Promise<number>; 4694 4695 /** 4696 * Get available encoder and encoder info for AVRecorder. 4697 * @param { AsyncCallback<Array<EncoderInfo>> } callback - A callback used to return available encoder info. 4698 * @throws { BusinessError } 5400102 - Operation not allowed. 4699 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4700 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4701 * @since 11 4702 */ 4703 getAvailableEncoder(callback: AsyncCallback<Array<EncoderInfo>>): void; 4704 4705 /** 4706 * Get available encoder and encoder info for AVRecorder. 4707 * @returns { Promise<Array<EncoderInfo>> } A Promise instance used to return available encoder info. 4708 * @throws { BusinessError } 5400102 - Operation not allowed. 4709 * @throws { BusinessError } 5400105 - Service died. Return by promise. 4710 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4711 * @since 11 4712 */ 4713 getAvailableEncoder(): Promise<Array<EncoderInfo>>; 4714 4715 /** 4716 * Recorder state. 4717 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4718 * @since 9 4719 */ 4720 /** 4721 * Recorder state. 4722 * @type { AVRecorderState } 4723 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4724 * @crossplatform 4725 * @atomicservice 4726 * @since 12 4727 */ 4728 readonly state: AVRecorderState; 4729 4730 /** 4731 * Listens for recording audioCapturerChange events. 4732 * @param { 'audioCapturerChange' } type - Type of the audioCapturerChange event to listen for. 4733 * @param { Callback<audio.AudioCapturerChangeInfo> } callback - Callback used to listen device change event. 4734 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4735 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4736 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4737 * @since 11 4738 */ 4739 on(type: 'audioCapturerChange', callback: Callback<audio.AudioCapturerChangeInfo>): void; 4740 4741 /** 4742 * Listens for photo asset events. 4743 * @param { 'photoAssetAvailable' } type - Type of the recording event to listen for. 4744 * @param { Callback<photoAccessHelper.PhotoAsset> } callback - Callback used to listen for the photo asset event. 4745 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4746 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4747 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4748 * @since 12 4749 */ 4750 on(type: 'photoAssetAvailable', callback: Callback<photoAccessHelper.PhotoAsset>): void; 4751 /** 4752 * Listens for recording stateChange events. 4753 * @param { 'stateChange' } type - Type of the recording event to listen for. 4754 * @param { function } callback - Callback used to listen for the recorder stateChange event. 4755 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4756 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4757 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4758 * @since 9 4759 */ 4760 /** 4761 * Listens for recording stateChange events. 4762 * @param { 'stateChange' } type - Type of the recording event to listen for. 4763 * @param { OnAVRecorderStateChangeHandler } callback - Callback used to listen for the recorder stateChange event. 4764 * @throws { BusinessError } 5400103 - IO error. Return by callback. 4765 * @throws { BusinessError } 5400105 - Service died. Return by callback. 4766 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4767 * @crossplatform 4768 * @atomicservice 4769 * @since 12 4770 */ 4771 on(type: 'stateChange', callback: OnAVRecorderStateChangeHandler): void; 4772 4773 /** 4774 * Listens for recording error events. 4775 * @param { 'error' } type - Type of the recording error event to listen for. 4776 * @param { ErrorCallback } callback - Callback used to listen for the recorder error event. 4777 * @throws { BusinessError } 201 - Permission denied. 4778 * @throws { BusinessError } 401 - The parameter check failed. 4779 * @throws { BusinessError } 801 - Capability not supported. 4780 * @throws { BusinessError } 5400101 - No memory. 4781 * @throws { BusinessError } 5400102 - Operation not allowed. 4782 * @throws { BusinessError } 5400103 - I/O error. 4783 * @throws { BusinessError } 5400104 - Time out. 4784 * @throws { BusinessError } 5400105 - Service died. 4785 * @throws { BusinessError } 5400106 - Unsupported format. 4786 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4787 * @since 9 4788 */ 4789 /** 4790 * Listens for recording error events. 4791 * @param { 'error' } type - Type of the recording error event to listen for. 4792 * @param { ErrorCallback } callback - Callback used to listen for the recorder error event. 4793 * @throws { BusinessError } 201 - Permission denied. 4794 * @throws { BusinessError } 401 - The parameter check failed. 4795 * @throws { BusinessError } 801 - Capability not supported. 4796 * @throws { BusinessError } 5400101 - No memory. 4797 * @throws { BusinessError } 5400102 - Operation not allowed. 4798 * @throws { BusinessError } 5400103 - I/O error. 4799 * @throws { BusinessError } 5400104 - Time out. 4800 * @throws { BusinessError } 5400105 - Service died. 4801 * @throws { BusinessError } 5400106 - Unsupported format. 4802 * @throws { BusinessError } 5400107 - Audio interrupted. 4803 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4804 * @since 11 4805 */ 4806 /** 4807 * Listens for recording error events. 4808 * @param { 'error' } type - Type of the recording error event to listen for. 4809 * @param { ErrorCallback } callback - Callback used to listen for the recorder error event. 4810 * @throws { BusinessError } 201 - Permission denied. 4811 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4812 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4813 * @throws { BusinessError } 801 - Capability not supported. 4814 * @throws { BusinessError } 5400101 - No memory. 4815 * @throws { BusinessError } 5400102 - Operation not allowed. 4816 * @throws { BusinessError } 5400103 - I/O error. 4817 * @throws { BusinessError } 5400104 - Time out. 4818 * @throws { BusinessError } 5400105 - Service died. 4819 * @throws { BusinessError } 5400106 - Unsupported format. 4820 * @throws { BusinessError } 5400107 - Audio interrupted. 4821 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4822 * @crossplatform 4823 * @atomicservice 4824 * @since 12 4825 */ 4826 on(type: 'error', callback: ErrorCallback): void; 4827 4828 /** 4829 * Cancel Listens for recording stateChange events. 4830 * @param { 'stateChange' } type - Type of the recording stateChange event to listen for. 4831 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4832 * @since 9 4833 */ 4834 /** 4835 * Cancel Listens for recording stateChange events. 4836 * @param { 'stateChange' } type - Type of the recording stateChange event to listen for. 4837 * @param { OnAVRecorderStateChangeHandler } callback - Callback used to listen for the recorder stateChange event. 4838 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4839 * @crossplatform 4840 * @atomicservice 4841 * @since 12 4842 */ 4843 off(type: 'stateChange', callback?: OnAVRecorderStateChangeHandler): void; 4844 4845 /** 4846 * Cancel Listens for recording error events. 4847 * @param { 'error' } type - Type of the recording error event to listen for. 4848 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4849 * @since 9 4850 */ 4851 /** 4852 * Cancel Listens for recording error events. 4853 * @param { 'error' } type - Type of the recording error event to listen for. 4854 * @param { ErrorCallback } callback - Callback used to listen for the recorder error event. 4855 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4856 * @crossplatform 4857 * @atomicservice 4858 * @since 12 4859 */ 4860 off(type: 'error', callback?: ErrorCallback): void; 4861 4862 /** 4863 * Cancel Listens for recording audioCapturerChange events. 4864 * @param { 'audioCapturerChange' } type - Type of the audioCapturerChange event to listen for. 4865 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4866 * @since 11 4867 */ 4868 /** 4869 * Cancel Listens for recording audioCapturerChange events. 4870 * @param { 'audioCapturerChange' } type - Type of the audioCapturerChange event to listen for. 4871 * @param { Callback<audio.AudioCapturerChangeInfo> } callback - Callback used to listen device change event. 4872 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4873 * @since 12 4874 */ 4875 off(type: 'audioCapturerChange', callback?: Callback<audio.AudioCapturerChangeInfo>): void; 4876 4877 /** 4878 * Cancel Listens for photo asset events. 4879 * @param { 'photoAssetAvailable' } type - Type of the recording event to listen for. 4880 * @param { Callback<photoAccessHelper.PhotoAsset> } callback - Callback used to listen for the photo asset event. 4881 * @syscap SystemCapability.Multimedia.Media.AVRecorder 4882 * @since 12 4883 */ 4884 off(type: 'photoAssetAvailable', callback?: Callback<photoAccessHelper.PhotoAsset>): void; 4885 } 4886 4887 /** 4888 * Enumerates audio encoding formats, it will be deprecated after API8, use @CodecMimeType to replace. 4889 * 4890 * @enum { number } 4891 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4892 * @since 6 4893 * @deprecated since 8 4894 * @useinstead ohos.multimedia.media/media.CodecMimeType 4895 */ 4896 enum AudioEncoder { 4897 /** 4898 * Default audio encoding format, which is AMR-NB. 4899 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4900 * @since 6 4901 * @deprecated since 8 4902 */ 4903 DEFAULT = 0, 4904 4905 /** 4906 * Indicates the AMR-NB audio encoding format. 4907 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4908 * @since 6 4909 * @deprecated since 8 4910 */ 4911 AMR_NB = 1, 4912 4913 /** 4914 * Indicates the AMR-WB audio encoding format. 4915 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4916 * @since 6 4917 * @deprecated since 8 4918 */ 4919 AMR_WB = 2, 4920 4921 /** 4922 * Advanced Audio Coding Low Complexity (AAC-LC). 4923 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4924 * @since 6 4925 * @deprecated since 8 4926 */ 4927 AAC_LC = 3, 4928 4929 /** 4930 * High-Efficiency Advanced Audio Coding (HE-AAC). 4931 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4932 * @since 6 4933 * @deprecated since 8 4934 */ 4935 HE_AAC = 4 4936 } 4937 4938 /** 4939 * Enumerates audio output formats, it will be deprecated after API8, use @ContainerFormatType to replace. 4940 * 4941 * @enum { number } 4942 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4943 * @since 6 4944 * @deprecated since 8 4945 * @useinstead ohos.multimedia.media/media.ContainerFormatType 4946 */ 4947 enum AudioOutputFormat { 4948 /** 4949 * Default audio output format, which is Moving Pictures Expert Group 4 (MPEG-4). 4950 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4951 * @since 6 4952 * @deprecated since 8 4953 */ 4954 DEFAULT = 0, 4955 4956 /** 4957 * Indicates the Moving Picture Experts Group-4 (MPEG4) media format. 4958 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4959 * @since 6 4960 * @deprecated since 8 4961 */ 4962 MPEG_4 = 2, 4963 4964 /** 4965 * Indicates the Adaptive Multi-Rate Narrowband (AMR-NB) media format. 4966 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4967 * @since 6 4968 * @deprecated since 8 4969 */ 4970 AMR_NB = 3, 4971 4972 /** 4973 * Indicates the Adaptive Multi-Rate Wideband (AMR-WB) media format. 4974 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4975 * @since 6 4976 * @deprecated since 8 4977 */ 4978 AMR_WB = 4, 4979 4980 /** 4981 * Audio Data Transport Stream (ADTS), a transmission stream format of Advanced Audio Coding (AAC) audio. 4982 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 4983 * @since 6 4984 * @deprecated since 8 4985 */ 4986 AAC_ADTS = 6 4987 } 4988 4989 /** 4990 * Provides the geographical location definitions for media resources. 4991 * 4992 * @typedef Location 4993 * @syscap SystemCapability.Multimedia.Media.Core 4994 * @since 6 4995 */ 4996 /** 4997 * Provides the geographical location definitions for media resources. 4998 * 4999 * @typedef Location 5000 * @syscap SystemCapability.Multimedia.Media.Core 5001 * @crossplatform 5002 * @since 12 5003 */ 5004 interface Location { 5005 /** 5006 * Latitude. 5007 * @syscap SystemCapability.Multimedia.Media.Core 5008 * @since 6 5009 */ 5010 /** 5011 * Latitude. 5012 * @type { number } 5013 * @syscap SystemCapability.Multimedia.Media.Core 5014 * @crossplatform 5015 * @since 12 5016 */ 5017 latitude: number; 5018 5019 /** 5020 * Longitude. 5021 * @syscap SystemCapability.Multimedia.Media.Core 5022 * @since 6 5023 */ 5024 /** 5025 * Longitude. 5026 * @type { number } 5027 * @syscap SystemCapability.Multimedia.Media.Core 5028 * @crossplatform 5029 * @since 12 5030 */ 5031 longitude: number; 5032 } 5033 /** 5034 * Set configures of a watermark to AVRecorder. The position starts at top left corner. 5035 * 5036 * @typedef WatermarkConfig 5037 * @syscap SystemCapability.Multimedia.Media.Core 5038 * @systemapi 5039 * @since 12 5040 */ 5041 interface WatermarkConfig { 5042 /** 5043 * Offset of the watermark to the top line of pixel. 5044 * @type { number } 5045 * @syscap SystemCapability.Multimedia.Media.Core 5046 * @systemapi 5047 * @since 12 5048 */ 5049 top: number; 5050 /** 5051 * Offset of the watermark to the left line of pixel. 5052 * @type { number } 5053 * @syscap SystemCapability.Multimedia.Media.Core 5054 * @systemapi 5055 * @since 12 5056 */ 5057 left: number; 5058 } 5059 5060 /** 5061 * Provides the audio recorder configuration definitions. 5062 * 5063 * @typedef AudioRecorderConfig 5064 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5065 * @since 6 5066 * @deprecated since 9 5067 * @useinstead ohos.multimedia.media/media.AVRecorderConfig 5068 */ 5069 interface AudioRecorderConfig { 5070 /** 5071 * Audio encoding format. The default value is DEFAULT, it will be deprecated after API8. 5072 * use "audioEncoderMime" instead. 5073 * @type { ?AudioEncoder } 5074 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5075 * @since 6 5076 * @deprecated since 8 5077 * @useinstead ohos.multimedia.media/media.AudioRecorderConfig.audioEncoderMime 5078 */ 5079 audioEncoder?: AudioEncoder; 5080 5081 /** 5082 * Audio encoding bit rate. 5083 * @type { ?number } 5084 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5085 * @since 6 5086 * @deprecated since 9 5087 */ 5088 audioEncodeBitRate?: number; 5089 5090 /** 5091 * Audio sampling rate. 5092 * @type { ?number } 5093 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5094 * @since 6 5095 * @deprecated since 9 5096 */ 5097 audioSampleRate?: number; 5098 5099 /** 5100 * Number of audio channels. 5101 * @type { ?number } 5102 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5103 * @since 6 5104 * @deprecated since 9 5105 */ 5106 numberOfChannels?: number; 5107 5108 /** 5109 * Audio output format. The default value is DEFAULT, it will be deprecated after API8. 5110 * it will be replaced with "fileFormat". 5111 * @type { ?AudioOutputFormat } 5112 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5113 * @since 6 5114 * @deprecated since 8 5115 * @useinstead ohos.multimedia.media/media.AudioRecorderConfig.fileFormat 5116 */ 5117 format?: AudioOutputFormat; 5118 5119 /** 5120 * Audio output uri.support two kind of uri now. 5121 * format like: scheme + "://" + "context". 5122 * file: file://path 5123 * fd: fd://fd 5124 * @type { string } 5125 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5126 * @since 6 5127 * @deprecated since 9 5128 */ 5129 uri: string; 5130 5131 /** 5132 * Geographical location information. 5133 * @type { ?Location } 5134 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5135 * @since 6 5136 * @deprecated since 9 5137 */ 5138 location?: Location; 5139 5140 /** 5141 * audio encoding format MIME. it used to replace audioEncoder. 5142 * @type { ?CodecMimeType } 5143 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5144 * @since 8 5145 * @deprecated since 9 5146 */ 5147 audioEncoderMime?: CodecMimeType; 5148 /** 5149 * output file format. see @ContainerFormatType , it used to replace "format". 5150 * @type { ?ContainerFormatType } 5151 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5152 * @since 8 5153 * @deprecated since 9 5154 */ 5155 fileFormat?: ContainerFormatType; 5156 } 5157 5158 /** 5159 * Manages and record audio. Before calling an AudioRecorder method, you must use createAudioRecorder() 5160 * to create an AudioRecorder instance. 5161 * 5162 * @typedef AudioRecorder 5163 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5164 * @since 6 5165 * @deprecated since 9 5166 * @useinstead ohos.multimedia.media/media.AVRecorder 5167 */ 5168 interface AudioRecorder { 5169 /** 5170 * Prepares for recording. 5171 * @permission ohos.permission.MICROPHONE 5172 * @param { AudioRecorderConfig } config - Recording parameters. 5173 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5174 * @since 6 5175 * @deprecated since 9 5176 * @useinstead ohos.multimedia.media/media.AVRecorder#prepare 5177 */ 5178 /** 5179 * Prepares for recording. 5180 * @permission ohos.permission.MICROPHONE 5181 * @param { AudioRecorderConfig } config - Recording parameters. 5182 * @throws { BusinessError } 201 - permission denied. 5183 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5184 * @since 12 5185 * @deprecated since 9 5186 * @useinstead ohos.multimedia.media/media.AVRecorder#prepare 5187 */ 5188 prepare(config: AudioRecorderConfig): void; 5189 5190 /** 5191 * Starts audio recording. 5192 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5193 * @since 6 5194 * @deprecated since 9 5195 * @useinstead ohos.multimedia.media/media.AVRecorder#start 5196 */ 5197 start(): void; 5198 5199 /** 5200 * Pauses audio recording. 5201 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5202 * @since 6 5203 * @deprecated since 9 5204 * @useinstead ohos.multimedia.media/media.AVRecorder#pause 5205 */ 5206 pause(): void; 5207 5208 /** 5209 * Resumes audio recording. 5210 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5211 * @since 6 5212 * @deprecated since 9 5213 * @useinstead ohos.multimedia.media/media.AVRecorder#resume 5214 */ 5215 resume(): void; 5216 5217 /** 5218 * Stops audio recording. 5219 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5220 * @since 6 5221 * @deprecated since 9 5222 * @useinstead ohos.multimedia.media/media.AVRecorder#stop 5223 */ 5224 stop(): void; 5225 5226 /** 5227 * Releases resources used for audio recording. 5228 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5229 * @since 6 5230 * @deprecated since 9 5231 * @useinstead ohos.multimedia.media/media.AVRecorder#release 5232 */ 5233 release(): void; 5234 5235 /** 5236 * Resets audio recording. 5237 * Before resetting audio recording, you must call stop() to stop recording. After audio recording is reset, 5238 * you must call prepare() to set the recording configurations for another recording. 5239 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5240 * @since 6 5241 * @deprecated since 9 5242 * @useinstead ohos.multimedia.media/media.AVRecorder#reset 5243 */ 5244 reset(): void; 5245 5246 /** 5247 * Listens for audio recording events. 5248 * @param { 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset' } type - Type of the audio recording event to listen for. 5249 * @param { function } callback - Callback used to listen for the audio recording event. 5250 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5251 * @since 6 5252 * @deprecated since 9 5253 * @useinstead ohos.multimedia.media/media.AVRecorder#on 5254 */ 5255 on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset', callback: () => void): void; 5256 5257 /** 5258 * Listens for audio recording error events. 5259 * @param { 'error' } type - Type of the audio recording error event to listen for. 5260 * @param { ErrorCallback } callback - Callback used to listen for the audio recording error event. 5261 * @syscap SystemCapability.Multimedia.Media.AudioRecorder 5262 * @since 6 5263 * @deprecated since 9 5264 * @useinstead ohos.multimedia.media/media.AVRecorder#on 5265 */ 5266 on(type: 'error', callback: ErrorCallback): void; 5267 } 5268 5269 /** 5270 * The maintenance of this interface has been stopped since version api 9. Please use AVRecorderState. 5271 * Describes video recorder states. 5272 * 5273 * @typedef { 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error' } 5274 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5275 * @systemapi 5276 * @since 9 5277 */ 5278 type VideoRecordState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error'; 5279 5280 /** 5281 * The maintenance of this interface has been stopped since version api 9. Please use AVRecorder. 5282 * Manages and record video. Before calling an VideoRecorder method, you must use createVideoRecorder() 5283 * to create an VideoRecorder instance. 5284 * 5285 * @typedef VideoRecorder 5286 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5287 * @systemapi 5288 * @since 9 5289 */ 5290 interface VideoRecorder { 5291 /** 5292 * Prepares for recording. 5293 * @permission ohos.permission.MICROPHONE 5294 * @param { VideoRecorderConfig } config - Recording parameters. 5295 * @param { AsyncCallback<void> } callback - A callback instance used to return when prepare completed. 5296 * @throws { BusinessError } 201 - Permission denied. Return by callback. 5297 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5298 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5299 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5300 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5301 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5302 * @systemapi 5303 * @since 9 5304 */ 5305 /** 5306 * Prepares for recording. 5307 * @permission ohos.permission.MICROPHONE 5308 * @param { VideoRecorderConfig } config - Recording parameters. 5309 * @param { AsyncCallback<void> } callback - A callback instance used to return when prepare completed. 5310 * @throws { BusinessError } 201 - Permission denied. Return by callback. 5311 * @throws { BusinessError } 202 - Not System App. 5312 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5313 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5314 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5315 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5316 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5317 * @systemapi 5318 * @since 12 5319 */ 5320 prepare(config: VideoRecorderConfig, callback: AsyncCallback<void>): void; 5321 /** 5322 * Prepares for recording. 5323 * @permission ohos.permission.MICROPHONE 5324 * @param { VideoRecorderConfig } config - Recording parameters. 5325 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 5326 * @throws { BusinessError } 201 - Permission denied. Return by promise. 5327 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5328 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5329 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5330 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5331 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5332 * @systemapi 5333 * @since 9 5334 */ 5335 /** 5336 * Prepares for recording. 5337 * @permission ohos.permission.MICROPHONE 5338 * @param { VideoRecorderConfig } config - Recording parameters. 5339 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 5340 * @throws { BusinessError } 201 - Permission denied. Return by promise. 5341 * @throws { BusinessError } 202 - Not System App. 5342 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5343 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5344 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5345 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5346 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5347 * @systemapi 5348 * @since 12 5349 */ 5350 prepare(config: VideoRecorderConfig): Promise<void>; 5351 /** 5352 * get input surface.it must be called between prepare completed and start. 5353 * @param { AsyncCallback<string> } callback - Callback used to return the input surface id in string. 5354 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5355 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5356 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5357 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5358 * @systemapi 5359 * @since 9 5360 */ 5361 /** 5362 * get input surface.it must be called between prepare completed and start. 5363 * @param { AsyncCallback<string> } callback - Callback used to return the input surface id in string. 5364 * @throws { BusinessError } 202 - Not System App. 5365 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5366 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5367 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5368 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5369 * @systemapi 5370 * @since 12 5371 */ 5372 getInputSurface(callback: AsyncCallback<string>): void; 5373 /** 5374 * get input surface. it must be called between prepare completed and start. 5375 * @returns { Promise<string> } A Promise instance used to return the input surface id in string. 5376 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5377 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5378 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5379 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5380 * @systemapi 5381 * @since 9 5382 */ 5383 /** 5384 * get input surface. it must be called between prepare completed and start. 5385 * @returns { Promise<string> } A Promise instance used to return the input surface id in string. 5386 * @throws { BusinessError } 202 - Not System App. 5387 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5388 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5389 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5390 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5391 * @systemapi 5392 * @since 12 5393 */ 5394 getInputSurface(): Promise<string>; 5395 /** 5396 * Starts video recording. 5397 * @param { AsyncCallback<void> } callback - A callback instance used to return when start completed. 5398 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5399 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5400 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5401 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5402 * @systemapi 5403 * @since 9 5404 */ 5405 /** 5406 * Starts video recording. 5407 * @param { AsyncCallback<void> } callback - A callback instance used to return when start completed. 5408 * @throws { BusinessError } 202 - Not System App. 5409 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5410 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5411 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5412 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5413 * @systemapi 5414 * @since 12 5415 */ 5416 start(callback: AsyncCallback<void>): void; 5417 /** 5418 * Starts video recording. 5419 * @returns { Promise<void> } A Promise instance used to return when start completed. 5420 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5421 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5422 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5423 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5424 * @systemapi 5425 * @since 9 5426 */ 5427 /** 5428 * Starts video recording. 5429 * @returns { Promise<void> } A Promise instance used to return when start completed. 5430 * @throws { BusinessError } 202 - Not System App. 5431 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5432 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5433 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5434 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5435 * @systemapi 5436 * @since 12 5437 */ 5438 start(): Promise<void>; 5439 /** 5440 * Pauses video recording. 5441 * @param { AsyncCallback<void> } callback - A callback instance used to return when pause completed. 5442 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5443 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5444 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5445 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5446 * @systemapi 5447 * @since 9 5448 */ 5449 /** 5450 * Pauses video recording. 5451 * @param { AsyncCallback<void> } callback - A callback instance used to return when pause completed. 5452 * @throws { BusinessError } 202 - Not System App. 5453 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5454 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5455 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5456 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5457 * @systemapi 5458 * @since 12 5459 */ 5460 pause(callback: AsyncCallback<void>): void; 5461 /** 5462 * Pauses video recording. 5463 * @returns { Promise<void> } A Promise instance used to return when pause completed. 5464 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5465 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5466 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5467 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5468 * @systemapi 5469 * @since 9 5470 */ 5471 /** 5472 * Pauses video recording. 5473 * @returns { Promise<void> } A Promise instance used to return when pause completed. 5474 * @throws { BusinessError } 202 - Not System App. 5475 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5476 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5477 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5478 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5479 * @systemapi 5480 * @since 12 5481 */ 5482 pause(): Promise<void>; 5483 /** 5484 * Resumes video recording. 5485 * @param { AsyncCallback<void> } callback - A callback instance used to return when resume completed. 5486 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5487 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5488 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5489 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5490 * @systemapi 5491 * @since 9 5492 */ 5493 /** 5494 * Resumes video recording. 5495 * @param { AsyncCallback<void> } callback - A callback instance used to return when resume completed. 5496 * @throws { BusinessError } 202 - Not System App. 5497 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5498 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5499 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5500 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5501 * @systemapi 5502 * @since 12 5503 */ 5504 resume(callback: AsyncCallback<void>): void; 5505 /** 5506 * Resumes video recording. 5507 * @returns { Promise<void> } A Promise instance used to return when resume completed. 5508 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5509 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5510 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5511 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5512 * @systemapi 5513 * @since 9 5514 */ 5515 /** 5516 * Resumes video recording. 5517 * @returns { Promise<void> } A Promise instance used to return when resume completed. 5518 * @throws { BusinessError } 202 - Not System App. 5519 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5520 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5521 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5522 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5523 * @systemapi 5524 * @since 12 5525 */ 5526 resume(): Promise<void>; 5527 /** 5528 * Stops video recording. 5529 * @param { AsyncCallback<void> } callback A callback instance used to return when stop completed. 5530 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5531 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5532 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5533 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5534 * @systemapi 5535 * @since 9 5536 */ 5537 /** 5538 * Stops video recording. 5539 * @param { AsyncCallback<void> } callback A callback instance used to return when stop completed. 5540 * @throws { BusinessError } 202 - Not System App. 5541 * @throws { BusinessError } 5400102 - Operation not allowed. Return by callback. 5542 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5543 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5544 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5545 * @systemapi 5546 * @since 12 5547 */ 5548 stop(callback: AsyncCallback<void>): void; 5549 /** 5550 * Stops video recording. 5551 * @returns { Promise<void> } A Promise instance used to return when stop completed. 5552 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5553 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5554 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5555 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5556 * @systemapi 5557 * @since 9 5558 */ 5559 /** 5560 * Stops video recording. 5561 * @returns { Promise<void> } A Promise instance used to return when stop completed. 5562 * @throws { BusinessError } 202 - Not System App. 5563 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 5564 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5565 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5566 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5567 * @systemapi 5568 * @since 12 5569 */ 5570 stop(): Promise<void>; 5571 /** 5572 * Releases resources used for video recording. 5573 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 5574 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5575 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5576 * @systemapi 5577 * @since 9 5578 */ 5579 /** 5580 * Releases resources used for video recording. 5581 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 5582 * @throws { BusinessError } 202 - Not System App. 5583 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5584 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5585 * @systemapi 5586 * @since 12 5587 */ 5588 release(callback: AsyncCallback<void>): void; 5589 /** 5590 * Releases resources used for video recording. 5591 * @returns { Promise<void> } A Promise instance used to return when release completed. 5592 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5593 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5594 * @systemapi 5595 * @since 9 5596 */ 5597 /** 5598 * Releases resources used for video recording. 5599 * @returns { Promise<void> } A Promise instance used to return when release completed. 5600 * @throws { BusinessError } 202 - Not System App. 5601 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5602 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5603 * @systemapi 5604 * @since 12 5605 */ 5606 release(): Promise<void>; 5607 /** 5608 * Resets video recording. 5609 * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, 5610 * you must call prepare() to set the recording configurations for another recording. 5611 * @param { AsyncCallback<void> } callback - A callback instance used to return when reset completed. 5612 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5613 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5614 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5615 * @systemapi 5616 * @since 9 5617 */ 5618 /** 5619 * Resets video recording. 5620 * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, 5621 * you must call prepare() to set the recording configurations for another recording. 5622 * @param { AsyncCallback<void> } callback - A callback instance used to return when reset completed. 5623 * @throws { BusinessError } 202 - Not System App. 5624 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5625 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5626 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5627 * @systemapi 5628 * @since 12 5629 */ 5630 reset(callback: AsyncCallback<void>): void; 5631 /** 5632 * Resets video recording. 5633 * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, 5634 * you must call prepare() to set the recording configurations for another recording. 5635 * @returns { Promise<void> } A Promise instance used to return when reset completed. 5636 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5637 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5638 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5639 * @systemapi 5640 * @since 9 5641 */ 5642 /** 5643 * Resets video recording. 5644 * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, 5645 * you must call prepare() to set the recording configurations for another recording. 5646 * @returns { Promise<void> } A Promise instance used to return when reset completed. 5647 * @throws { BusinessError } 202 - Not System App. 5648 * @throws { BusinessError } 5400103 - I/O error. Return by promise. 5649 * @throws { BusinessError } 5400105 - Service died. Return by promise. 5650 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5651 * @systemapi 5652 * @since 12 5653 */ 5654 reset(): Promise<void>; 5655 /** 5656 * Listens for video recording error events. 5657 * @param { 'error' } type - Type of the video recording error event to listen for. 5658 * @param { ErrorCallback } callback - Callback used to listen for the video recording error event. 5659 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5660 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5661 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5662 * @systemapi 5663 * @since 9 5664 */ 5665 /** 5666 * Listens for video recording error events. 5667 * @param { 'error' } type - Type of the video recording error event to listen for. 5668 * @param { ErrorCallback } callback - Callback used to listen for the video recording error event. 5669 * @throws { BusinessError } 201 - permission denied. 5670 * @throws { BusinessError } 202 - Not System App. 5671 * @throws { BusinessError } 5400103 - I/O error. Return by callback. 5672 * @throws { BusinessError } 5400105 - Service died. Return by callback. 5673 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5674 * @systemapi 5675 * @since 12 5676 */ 5677 on(type: 'error', callback: ErrorCallback): void; 5678 5679 /** 5680 * video recorder state. 5681 * @type { VideoRecordState } 5682 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 5683 * @systemapi 5684 * @since 9 5685 */ 5686 readonly state: VideoRecordState; 5687 } 5688 5689 /** 5690 * Describes video playback states. 5691 * @typedef { 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error' } 5692 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5693 * @since 8 5694 * @deprecated since 9 5695 * @useinstead ohos.multimedia.media/media.AVPlayerState 5696 */ 5697 type VideoPlayState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error'; 5698 5699 /** 5700 * Enumerates playback speed. 5701 * 5702 * @enum { number } 5703 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5704 * @since 8 5705 */ 5706 /** 5707 * Enumerates playback speed. 5708 * 5709 * @enum { number } 5710 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5711 * @crossplatform 5712 * @atomicservice 5713 * @since 12 5714 */ 5715 enum PlaybackSpeed { 5716 /** 5717 * playback at 0.75x normal speed 5718 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5719 * @since 8 5720 */ 5721 /** 5722 * playback at 0.75x normal speed 5723 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5724 * @crossplatform 5725 * @atomicservice 5726 * @since 12 5727 */ 5728 SPEED_FORWARD_0_75_X = 0, 5729 /** 5730 * playback at normal speed 5731 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5732 * @since 8 5733 */ 5734 /** 5735 * playback at normal speed 5736 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5737 * @crossplatform 5738 * @atomicservice 5739 * @since 12 5740 */ 5741 SPEED_FORWARD_1_00_X = 1, 5742 /** 5743 * playback at 1.25x normal speed 5744 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5745 * @since 8 5746 */ 5747 /** 5748 * playback at 1.25x normal speed 5749 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5750 * @crossplatform 5751 * @atomicservice 5752 * @since 12 5753 */ 5754 SPEED_FORWARD_1_25_X = 2, 5755 /** 5756 * playback at 1.75x normal speed 5757 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5758 * @since 8 5759 */ 5760 /** 5761 * playback at 1.75x normal speed 5762 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5763 * @crossplatform 5764 * @atomicservice 5765 * @since 12 5766 */ 5767 SPEED_FORWARD_1_75_X = 3, 5768 /** 5769 * playback at 2.0x normal speed 5770 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5771 * @since 8 5772 */ 5773 /** 5774 * playback at 2.0x normal speed 5775 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5776 * @crossplatform 5777 * @atomicservice 5778 * @since 12 5779 */ 5780 SPEED_FORWARD_2_00_X = 4, 5781 /** 5782 * playback at 0.5x normal speed 5783 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5784 * @atomicservice 5785 * @since 12 5786 */ 5787 SPEED_FORWARD_0_50_X = 5, 5788 /** 5789 * playback at 1.5x normal speed 5790 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5791 * @atomicservice 5792 * @since 12 5793 */ 5794 SPEED_FORWARD_1_50_X = 6, 5795 /** 5796 * playback at 3.0x normal speed 5797 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5798 * @atomicservice 5799 * @since 13 5800 */ 5801 SPEED_FORWARD_3_00_X = 7, 5802 /** 5803 * playback at 0.25x normal speed 5804 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5805 * @atomicservice 5806 * @since 12 5807 */ 5808 SPEED_FORWARD_0_25_X = 8, 5809 /** 5810 * playback at 0.125x normal speed 5811 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5812 * @atomicservice 5813 * @since 12 5814 */ 5815 SPEED_FORWARD_0_125_X = 9, 5816 } 5817 5818 /** 5819 * Manages and plays video. Before calling an video method, you must use createVideoPlayer() to create an VideoPlayer 5820 * instance. 5821 * 5822 * @typedef VideoPlayer 5823 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5824 * @since 8 5825 * @deprecated since 9 5826 * @useinstead ohos.multimedia.media/media.AVPlayer 5827 */ 5828 interface VideoPlayer { 5829 /** 5830 * Set display surface. 5831 * @param {string} surfaceId - surface id, video player will use this id get a surface instance. 5832 * @param { AsyncCallback<void> } callback - A callback instance used to return when release output buffer completed. 5833 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5834 * @since 8 5835 * @deprecated since 9 5836 * @useinstead ohos.multimedia.media/media.AVPlayer#surfaceId 5837 */ 5838 setDisplaySurface(surfaceId: string, callback: AsyncCallback<void>): void; 5839 /** 5840 * Set display surface. 5841 * @param {string} surfaceId - surface id, video player will use this id get a surface instance. 5842 * @returns { Promise<void> } A Promise instance used to return when release output buffer completed. 5843 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5844 * @since 8 5845 * @deprecated since 9 5846 * @useinstead ohos.multimedia.media/media.AVPlayer#surfaceId 5847 */ 5848 setDisplaySurface(surfaceId: string): Promise<void>; 5849 /** 5850 * Prepare video playback, it will request resource for playing. 5851 * @param { AsyncCallback<void> } callback - A callback instance used to return when prepare completed. 5852 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5853 * @since 8 5854 * @deprecated since 9 5855 * @useinstead ohos.multimedia.media/media.AVPlayer#prepare 5856 */ 5857 prepare(callback: AsyncCallback<void>): void; 5858 /** 5859 * Prepare video playback, it will request resource for playing. 5860 * @returns { Promise<void> } A Promise instance used to return when prepare completed. 5861 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5862 * @since 8 5863 * @deprecated since 9 5864 * @useinstead ohos.multimedia.media/media.AVPlayer#prepare 5865 */ 5866 prepare(): Promise<void>; 5867 /** 5868 * Starts video playback. 5869 * @param { AsyncCallback<void> } callback - A callback instance used to return when start completed. 5870 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5871 * @since 8 5872 * @deprecated since 9 5873 * @useinstead ohos.multimedia.media/media.AVPlayer#play 5874 */ 5875 play(callback: AsyncCallback<void>): void; 5876 /** 5877 * Starts video playback. 5878 * @returns { Promise<void> } A Promise instance used to return when start completed. 5879 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5880 * @since 8 5881 * @deprecated since 9 5882 * @useinstead ohos.multimedia.media/media.AVPlayer#play 5883 */ 5884 play(): Promise<void>; 5885 /** 5886 * Pauses video playback. 5887 * @param { AsyncCallback<void> } callback - A callback instance used to return when pause completed. 5888 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5889 * @since 8 5890 * @deprecated since 9 5891 * @useinstead ohos.multimedia.media/media.AVPlayer#pause 5892 */ 5893 pause(callback: AsyncCallback<void>): void; 5894 /** 5895 * Pauses video playback. 5896 * @returns { Promise<void> } A Promise instance used to return when pause completed. 5897 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5898 * @since 8 5899 * @deprecated since 9 5900 * @useinstead ohos.multimedia.media/media.AVPlayer#pause 5901 */ 5902 pause(): Promise<void>; 5903 /** 5904 * Stops video playback. 5905 * @param { AsyncCallback<void> } callback - A callback instance used to return when stop completed. 5906 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5907 * @since 8 5908 * @deprecated since 9 5909 * @useinstead ohos.multimedia.media/media.AVPlayer#stop 5910 */ 5911 stop(callback: AsyncCallback<void>): void; 5912 /** 5913 * Stops video playback. 5914 * @returns { Promise<void> } A Promise instance used to return when stop completed. 5915 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5916 * @since 8 5917 * @deprecated since 9 5918 * @useinstead ohos.multimedia.media/media.AVPlayer#stop 5919 */ 5920 stop(): Promise<void>; 5921 /** 5922 * Resets video playback, it will release the resource. 5923 * @param { AsyncCallback<void> } callback - A callback instance used to return when reset completed. 5924 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5925 * @since 8 5926 * @deprecated since 9 5927 * @useinstead ohos.multimedia.media/media.AVPlayer#reset 5928 */ 5929 reset(callback: AsyncCallback<void>): void; 5930 /** 5931 * Resets video playback, it will release the resource. 5932 * @returns { Promise<void> } A Promise instance used to return when reset completed. 5933 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5934 * @since 8 5935 * @deprecated since 9 5936 * @useinstead ohos.multimedia.media/media.AVPlayer#reset 5937 */ 5938 reset(): Promise<void>; 5939 /** 5940 * Jumps to the specified playback position by default SeekMode(SEEK_PREV_SYNC), 5941 * the performance may be not the best. 5942 * @param { number } timeMs - Playback position to jump 5943 * @param { AsyncCallback<number> } callback - A callback instance used to return when seek completed 5944 * and return the seeking position result. 5945 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5946 * @since 8 5947 * @deprecated since 9 5948 * @useinstead ohos.multimedia.media/media.AVPlayer#seek 5949 */ 5950 seek(timeMs: number, callback: AsyncCallback<number>): void; 5951 /** 5952 * Jumps to the specified playback position. 5953 * @param { number } timeMs - Playback position to jump 5954 * @param { SeekMode } mode - seek mode, see @SeekMode . 5955 * @param { AsyncCallback<number> } callback - A callback instance used to return when seek completed 5956 * and return the seeking position result. 5957 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5958 * @since 8 5959 * @deprecated since 9 5960 * @useinstead ohos.multimedia.media/media.AVPlayer#seek 5961 */ 5962 seek(timeMs: number, mode: SeekMode, callback: AsyncCallback<number>): void; 5963 /** 5964 * Jumps to the specified playback position. 5965 * @param { number } timeMs - Playback position to jump 5966 * @param { SeekMode } mode - seek mode, see @SeekMode . 5967 * @returns { Promise<number> } A Promise instance used to return when seek completed 5968 * and return the seeking position result. 5969 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5970 * @since 8 5971 * @deprecated since 9 5972 * @useinstead ohos.multimedia.media/media.AVPlayer#seek 5973 */ 5974 seek(timeMs: number, mode?: SeekMode): Promise<number>; 5975 /** 5976 * Sets the volume. 5977 * @param { number } vol - Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). 5978 * @param { AsyncCallback<void> } callback - A callback instance used to return when set volume completed. 5979 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5980 * @since 8 5981 * @deprecated since 9 5982 * @useinstead ohos.multimedia.media/media.AVPlayer#setVolume 5983 */ 5984 setVolume(vol: number, callback: AsyncCallback<void>): void; 5985 /** 5986 * Sets the volume. 5987 * @param { number } vol - Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). 5988 * @returns { Promise<void> } A Promise instance used to return when set volume completed. 5989 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5990 * @since 8 5991 * @deprecated since 9 5992 * @useinstead ohos.multimedia.media/media.AVPlayer#setVolume 5993 */ 5994 setVolume(vol: number): Promise<void>; 5995 /** 5996 * Releases resources used for video playback. 5997 * @param { AsyncCallback<void> } callback - A callback instance used to return when release completed. 5998 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 5999 * @since 8 6000 * @deprecated since 9 6001 * @useinstead ohos.multimedia.media/media.AVPlayer#release 6002 */ 6003 release(callback: AsyncCallback<void>): void; 6004 /** 6005 * Releases resources used for video playback. 6006 * @returns { Promise<void> } A Promise instance used to return when release completed. 6007 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6008 * @since 8 6009 * @deprecated since 9 6010 * @useinstead ohos.multimedia.media/media.AVPlayer#release 6011 */ 6012 release(): Promise<void>; 6013 /** 6014 * Get all track infos in MediaDescription, should be called after data loaded callback. 6015 * @param { AsyncCallback<Array<MediaDescription>> } callback - async callback return track info in MediaDescription. 6016 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6017 * @since 8 6018 * @deprecated since 9 6019 * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription 6020 */ 6021 getTrackDescription(callback: AsyncCallback<Array<MediaDescription>>): void; 6022 6023 /** 6024 * Get all track infos in MediaDescription, should be called after data loaded callback. 6025 * @returns { Promise<Array<MediaDescription>> } A Promise instance used to return the track info in MediaDescription. 6026 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6027 * @since 8 6028 * @deprecated since 9 6029 * @useinstead ohos.multimedia.media/media.AVPlayer#getTrackDescription 6030 */ 6031 getTrackDescription(): Promise<Array<MediaDescription>>; 6032 6033 /** 6034 * media url. Mainstream video formats are supported. 6035 * local:fd://XXX, file://XXX. network:http://xxx 6036 * @type { string } 6037 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6038 * @since 8 6039 * @deprecated since 9 6040 * @useinstead ohos.multimedia.media/media.AVPlayer#url 6041 */ 6042 url: string; 6043 6044 /** 6045 * Video file descriptor. Mainstream video formats are supported. 6046 * @type { AVFileDescriptor } 6047 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6048 * @since 9 6049 * @deprecated since 9 6050 * @useinstead ohos.multimedia.media/media.AVPlayer#fdSrc 6051 */ 6052 fdSrc: AVFileDescriptor; 6053 6054 /** 6055 * Whether to loop video playback. The value true means to loop playback. 6056 * @type { boolean } 6057 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6058 * @since 8 6059 * @deprecated since 9 6060 * @useinstead ohos.multimedia.media/media.AVPlayer#loop 6061 */ 6062 loop: boolean; 6063 6064 /** 6065 * Current playback position. 6066 * @type { number } 6067 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6068 * @since 8 6069 * @deprecated since 9 6070 * @useinstead ohos.multimedia.media/media.AVPlayer#currentTime 6071 */ 6072 readonly currentTime: number; 6073 6074 /** 6075 * Playback duration, if -1 means cannot seek. 6076 * @type { number } 6077 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6078 * @since 8 6079 * @deprecated since 9 6080 * @useinstead ohos.multimedia.media/media.AVPlayer#duration 6081 */ 6082 readonly duration: number; 6083 6084 /** 6085 * Playback state. 6086 * @type { VideoPlayState } 6087 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6088 * @since 8 6089 * @deprecated since 9 6090 * @useinstead ohos.multimedia.media/media.AVPlayer#state 6091 */ 6092 readonly state: VideoPlayState; 6093 6094 /** 6095 * video width, valid after prepared. 6096 * @type { number } 6097 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6098 * @since 8 6099 * @deprecated since 9 6100 * @useinstead ohos.multimedia.media/media.AVPlayer#width 6101 */ 6102 readonly width: number; 6103 6104 /** 6105 * video height, valid after prepared. 6106 * @type { number } 6107 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6108 * @since 8 6109 * @deprecated since 9 6110 * @useinstead ohos.multimedia.media/media.AVPlayer#height 6111 */ 6112 readonly height: number; 6113 6114 /** 6115 * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not 6116 * set, the default mode will be used. Set it before calling the {@link #play()} in the 6117 * first time in order for the interrupt mode to become effective thereafter. 6118 * @type { ?audio.InterruptMode } 6119 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6120 * @since 9 6121 * @deprecated since 9 6122 * @useinstead ohos.multimedia.media/media.AVPlayer#audioInterruptMode 6123 */ 6124 audioInterruptMode?: audio.InterruptMode; 6125 6126 /** 6127 * video scale type. By default, the {@link #VIDEO_SCALE_TYPE_FIT} will be used, for more 6128 * information, refer to {@link #VideoScaleType} 6129 * @type { ?VideoScaleType } 6130 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6131 * @since 9 6132 * @deprecated since 9 6133 * @useinstead ohos.multimedia.media/media.AVPlayer#videoScaleType 6134 */ 6135 videoScaleType?: VideoScaleType; 6136 6137 /** 6138 * set payback speed. 6139 * @param { number } speed - playback speed, see @PlaybackSpeed . 6140 * @param { AsyncCallback<number> } callback Callback used to return actually speed. 6141 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6142 * @since 8 6143 * @deprecated since 9 6144 * @useinstead ohos.multimedia.media/media.AVPlayer#setSpeed 6145 */ 6146 setSpeed(speed: number, callback: AsyncCallback<number>): void; 6147 /** 6148 * set output surface. 6149 * @param { number } speed - playback speed, see @PlaybackSpeed . 6150 * @returns { Promise<number> } A Promise instance used to return actually speed. 6151 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6152 * @since 8 6153 * @deprecated since 9 6154 * @useinstead ohos.multimedia.media/media.AVPlayer#setSpeed 6155 */ 6156 setSpeed(speed: number): Promise<number>; 6157 6158 /** 6159 * Listens for video playback completed events. 6160 * @param { 'playbackCompleted' } type - Type of the playback event to listen for. 6161 * @param { Callback<void> } callback - Callback used to listen for the playback event return. 6162 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6163 * @since 8 6164 * @deprecated since 9 6165 * @useinstead ohos.multimedia.media/media.AVPlayer#event:stateChange 6166 */ 6167 on(type: 'playbackCompleted', callback: Callback<void>): void; 6168 6169 /** 6170 * Listens for video playback buffering events. 6171 * @param { 'bufferingUpdate' } type - Type of the playback buffering update event to listen for. 6172 * @param { function } callback - Callback used to listen for the buffering update event, 6173 * return BufferingInfoType and the value. 6174 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6175 * @since 8 6176 * @deprecated since 9 6177 * @useinstead ohos.multimedia.media/media.AVPlayer#event:bufferingUpdate 6178 */ 6179 on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; 6180 6181 /** 6182 * Listens for start render video frame events. 6183 * @param { 'startRenderFrame' } type - Type of the playback event to listen for. 6184 * @param { Callback<void> } callback - Callback used to listen for the playback event return. 6185 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6186 * @since 8 6187 * @deprecated since 9 6188 * @useinstead ohos.multimedia.media/media.AVPlayer#event:startRenderFrame 6189 */ 6190 on(type: 'startRenderFrame', callback: Callback<void>): void; 6191 6192 /** 6193 * Listens for video size changed event. 6194 * @param { 'videoSizeChanged' } type - Type of the playback event to listen for. 6195 * @param { function } callback - Callback used to listen for the playback event return video size. 6196 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6197 * @since 8 6198 * @deprecated since 9 6199 * @useinstead ohos.multimedia.media/media.AVPlayer#event:videoSizeChange 6200 */ 6201 on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): void; 6202 6203 /** 6204 * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent} 6205 * @param { 'audioInterrupt' } type - Type of the playback event to listen for. 6206 * @param { function } callback - Callback used to listen for the playback event return audio interrupt info. 6207 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6208 * @since 9 6209 * @deprecated since 9 6210 * @useinstead ohos.multimedia.media/media.AVPlayer#event:audioInterrupt 6211 */ 6212 on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; 6213 6214 /** 6215 * Listens for playback error events. 6216 * @param { 'error' } type - Type of the playback error event to listen for. 6217 * @param { ErrorCallback } callback - Callback used to listen for the playback error event. 6218 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6219 * @since 8 6220 * @deprecated since 9 6221 * @useinstead ohos.multimedia.media/media.AVPlayer#event:error 6222 */ 6223 on(type: 'error', callback: ErrorCallback): void; 6224 } 6225 6226 /** 6227 * Enumerates video scale type. 6228 * 6229 * @enum { number } 6230 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6231 * @since 9 6232 */ 6233 /** 6234 * Enumerates video scale type. 6235 * 6236 * @enum { number } 6237 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6238 * @crossplatform 6239 * @atomicservice 6240 * @since 12 6241 */ 6242 enum VideoScaleType { 6243 /** 6244 * The content is stretched to the fit the display surface rendering area. When 6245 * the aspect ratio of the content is not same as the display surface, the aspect 6246 * of the content is not maintained. This is the default scale type. 6247 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6248 * @since 9 6249 */ 6250 /** 6251 * The content is stretched to the fit the display surface rendering area. When 6252 * the aspect ratio of the content is not same as the display surface, the aspect 6253 * of the content is not maintained. This is the default scale type. 6254 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6255 * @crossplatform 6256 * @atomicservice 6257 * @since 12 6258 */ 6259 VIDEO_SCALE_TYPE_FIT = 0, 6260 6261 /** 6262 * The content is stretched to the fit the display surface rendering area. When 6263 * the aspect ratio of the content is not the same as the display surface, content's 6264 * aspect ratio is maintained and the content is cropped to fit the display surface. 6265 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6266 * @since 9 6267 */ 6268 /** 6269 * The content is stretched to the fit the display surface rendering area. When 6270 * the aspect ratio of the content is not the same as the display surface, content's 6271 * aspect ratio is maintained and the content is cropped to fit the display surface. 6272 * @syscap SystemCapability.Multimedia.Media.VideoPlayer 6273 * @crossplatform 6274 * @atomicservice 6275 * @since 12 6276 */ 6277 VIDEO_SCALE_TYPE_FIT_CROP = 1, 6278 } 6279 6280 /** 6281 * Enumerates container format type(The abbreviation for 'container format type' is CFT). 6282 * 6283 * @enum { number } 6284 * @syscap SystemCapability.Multimedia.Media.Core 6285 * @since 8 6286 */ 6287 /** 6288 * Enumerates container format type(The abbreviation for 'container format type' is CFT). 6289 * 6290 * @enum { number } 6291 * @syscap SystemCapability.Multimedia.Media.Core 6292 * @crossplatform 6293 * @atomicservice 6294 * @since 12 6295 */ 6296 enum ContainerFormatType { 6297 /** 6298 * A video container format type mp4. 6299 * @syscap SystemCapability.Multimedia.Media.Core 6300 * @since 8 6301 */ 6302 /** 6303 * A video container format type mp4. 6304 * @syscap SystemCapability.Multimedia.Media.Core 6305 * @crossplatform 6306 * @since 12 6307 */ 6308 CFT_MPEG_4 = 'mp4', 6309 6310 /** 6311 * A audio container format type m4a. 6312 * @syscap SystemCapability.Multimedia.Media.Core 6313 * @since 8 6314 */ 6315 /** 6316 * A audio container format type m4a. 6317 * @syscap SystemCapability.Multimedia.Media.Core 6318 * @crossplatform 6319 * @atomicservice 6320 * @since 12 6321 */ 6322 CFT_MPEG_4A = 'm4a', 6323 6324 /** 6325 * A audio container format type mp3. 6326 * @syscap SystemCapability.Multimedia.Media.Core 6327 * @since 12 6328 */ 6329 CFT_MP3 = 'mp3', 6330 /** 6331 * A audio container format type wav. 6332 * @syscap SystemCapability.Multimedia.Media.Core 6333 * @since 12 6334 */ 6335 CFT_WAV = 'wav', 6336 } 6337 6338 /** 6339 * Enumerates media data type. 6340 * 6341 * @enum { number } 6342 * @syscap SystemCapability.Multimedia.Media.Core 6343 * @since 8 6344 */ 6345 /** 6346 * Enumerates media data type. 6347 * 6348 * @enum { number } 6349 * @syscap SystemCapability.Multimedia.Media.Core 6350 * @atomicservice 6351 * @since 11 6352 */ 6353 /** 6354 * Enumerates media data type. 6355 * 6356 * @enum { number } 6357 * @syscap SystemCapability.Multimedia.Media.Core 6358 * @crossplatform 6359 * @atomicservice 6360 * @since 12 6361 */ 6362 enum MediaType { 6363 /** 6364 * track is audio. 6365 * @syscap SystemCapability.Multimedia.Media.Core 6366 * @since 8 6367 */ 6368 /** 6369 * track is audio. 6370 * @syscap SystemCapability.Multimedia.Media.Core 6371 * @atomicservice 6372 * @since 11 6373 */ 6374 /** 6375 * track is audio. 6376 * @syscap SystemCapability.Multimedia.Media.Core 6377 * @crossplatform 6378 * @atomicservice 6379 * @since 12 6380 */ 6381 MEDIA_TYPE_AUD = 0, 6382 /** 6383 * track is video. 6384 * @syscap SystemCapability.Multimedia.Media.Core 6385 * @since 8 6386 */ 6387 /** 6388 * track is video. 6389 * @syscap SystemCapability.Multimedia.Media.Core 6390 * @atomicservice 6391 * @since 11 6392 */ 6393 /** 6394 * track is video. 6395 * @syscap SystemCapability.Multimedia.Media.Core 6396 * @crossplatform 6397 * @atomicservice 6398 * @since 12 6399 */ 6400 MEDIA_TYPE_VID = 1, 6401 /** 6402 * Track is subtitle. 6403 * @syscap SystemCapability.Multimedia.Media.Core 6404 * @atomicservice 6405 * @since 12 6406 */ 6407 MEDIA_TYPE_SUBTITLE = 2, 6408 } 6409 6410 /** 6411 * Enumerates media description key. 6412 * 6413 * @enum { number } 6414 * @syscap SystemCapability.Multimedia.Media.Core 6415 * @since 8 6416 */ 6417 /** 6418 * Enumerates media description key. 6419 * 6420 * @enum { number } 6421 * @syscap SystemCapability.Multimedia.Media.Core 6422 * @atomicservice 6423 * @since 11 6424 */ 6425 /** 6426 * Enumerates media description key. 6427 * 6428 * @enum { number } 6429 * @syscap SystemCapability.Multimedia.Media.Core 6430 * @crossplatform 6431 * @atomicservice 6432 * @since 12 6433 */ 6434 enum MediaDescriptionKey { 6435 /** 6436 * key for track index, value type is number. 6437 * @syscap SystemCapability.Multimedia.Media.Core 6438 * @since 8 6439 */ 6440 /** 6441 * key for track index, value type is number. 6442 * @syscap SystemCapability.Multimedia.Media.Core 6443 * @atomicservice 6444 * @since 11 6445 */ 6446 /** 6447 * key for track index, value type is number. 6448 * @syscap SystemCapability.Multimedia.Media.Core 6449 * @crossplatform 6450 * @atomicservice 6451 * @since 12 6452 */ 6453 MD_KEY_TRACK_INDEX = 'track_index', 6454 6455 /** 6456 * key for track type, value type is number, see @MediaType. 6457 * @syscap SystemCapability.Multimedia.Media.Core 6458 * @since 8 6459 */ 6460 /** 6461 * key for track type, value type is number, see @MediaType. 6462 * @syscap SystemCapability.Multimedia.Media.Core 6463 * @atomicservice 6464 * @since 11 6465 */ 6466 /** 6467 * key for track type, value type is number, see @MediaType. 6468 * @syscap SystemCapability.Multimedia.Media.Core 6469 * @crossplatform 6470 * @atomicservice 6471 * @since 12 6472 */ 6473 MD_KEY_TRACK_TYPE = 'track_type', 6474 6475 /** 6476 * key for codec mime type, value type is string. 6477 * @syscap SystemCapability.Multimedia.Media.Core 6478 * @since 8 6479 */ 6480 /** 6481 * key for codec mime type, value type is string. 6482 * @syscap SystemCapability.Multimedia.Media.Core 6483 * @atomicservice 6484 * @since 11 6485 */ 6486 /** 6487 * key for codec mime type, value type is string. 6488 * @syscap SystemCapability.Multimedia.Media.Core 6489 * @crossplatform 6490 * @atomicservice 6491 * @since 12 6492 */ 6493 MD_KEY_CODEC_MIME = 'codec_mime', 6494 6495 /** 6496 * key for duration, value type is number. 6497 * @syscap SystemCapability.Multimedia.Media.Core 6498 * @since 8 6499 */ 6500 /** 6501 * key for duration, value type is number. 6502 * @syscap SystemCapability.Multimedia.Media.Core 6503 * @atomicservice 6504 * @since 11 6505 */ 6506 /** 6507 * key for duration, value type is number. 6508 * @syscap SystemCapability.Multimedia.Media.Core 6509 * @crossplatform 6510 * @atomicservice 6511 * @since 12 6512 */ 6513 MD_KEY_DURATION = 'duration', 6514 6515 /** 6516 * key for bitrate, value type is number. 6517 * @syscap SystemCapability.Multimedia.Media.Core 6518 * @since 8 6519 */ 6520 /** 6521 * key for bitrate, value type is number. 6522 * @syscap SystemCapability.Multimedia.Media.Core 6523 * @atomicservice 6524 * @since 11 6525 */ 6526 /** 6527 * key for bitrate, value type is number. 6528 * @syscap SystemCapability.Multimedia.Media.Core 6529 * @crossplatform 6530 * @atomicservice 6531 * @since 12 6532 */ 6533 MD_KEY_BITRATE = 'bitrate', 6534 6535 /** 6536 * key for video width, value type is number. 6537 * @syscap SystemCapability.Multimedia.Media.Core 6538 * @since 8 6539 */ 6540 /** 6541 * key for video width, value type is number. 6542 * @syscap SystemCapability.Multimedia.Media.Core 6543 * @atomicservice 6544 * @since 11 6545 */ 6546 /** 6547 * key for video width, value type is number. 6548 * @syscap SystemCapability.Multimedia.Media.Core 6549 * @crossplatform 6550 * @atomicservice 6551 * @since 12 6552 */ 6553 MD_KEY_WIDTH = 'width', 6554 6555 /** 6556 * key for video height, value type is number. 6557 * @syscap SystemCapability.Multimedia.Media.Core 6558 * @since 8 6559 */ 6560 /** 6561 * key for video height, value type is number. 6562 * @syscap SystemCapability.Multimedia.Media.Core 6563 * @atomicservice 6564 * @since 11 6565 */ 6566 /** 6567 * key for video height, value type is number. 6568 * @syscap SystemCapability.Multimedia.Media.Core 6569 * @crossplatform 6570 * @atomicservice 6571 * @since 12 6572 */ 6573 MD_KEY_HEIGHT = 'height', 6574 6575 /** 6576 * key for video frame rate, value type is number. 6577 * @syscap SystemCapability.Multimedia.Media.Core 6578 * @since 8 6579 */ 6580 /** 6581 * key for video frame rate, value type is number. 6582 * @syscap SystemCapability.Multimedia.Media.Core 6583 * @atomicservice 6584 * @since 11 6585 */ 6586 /** 6587 * key for video frame rate, value type is number. 6588 * @syscap SystemCapability.Multimedia.Media.Core 6589 * @crossplatform 6590 * @atomicservice 6591 * @since 12 6592 */ 6593 MD_KEY_FRAME_RATE = 'frame_rate', 6594 6595 /** 6596 * key for audio channel count, value type is number 6597 * @syscap SystemCapability.Multimedia.Media.Core 6598 * @since 8 6599 */ 6600 /** 6601 * key for audio channel count, value type is number 6602 * @syscap SystemCapability.Multimedia.Media.Core 6603 * @atomicservice 6604 * @since 11 6605 */ 6606 /** 6607 * key for audio channel count, value type is number 6608 * @syscap SystemCapability.Multimedia.Media.Core 6609 * @crossplatform 6610 * @atomicservice 6611 * @since 12 6612 */ 6613 MD_KEY_AUD_CHANNEL_COUNT = 'channel_count', 6614 6615 /** 6616 * key for audio sample rate, value type is number 6617 * @syscap SystemCapability.Multimedia.Media.Core 6618 * @since 8 6619 */ 6620 /** 6621 * key for audio sample rate, value type is number 6622 * @syscap SystemCapability.Multimedia.Media.Core 6623 * @atomicservice 6624 * @since 11 6625 */ 6626 /** 6627 * key for audio sample rate, value type is number 6628 * @syscap SystemCapability.Multimedia.Media.Core 6629 * @crossplatform 6630 * @atomicservice 6631 * @since 12 6632 */ 6633 MD_KEY_AUD_SAMPLE_RATE = 'sample_rate', 6634 6635 /** 6636 * key for audio bit depth, value type is number 6637 * @syscap SystemCapability.Multimedia.Media.Core 6638 * @atomicservice 6639 * @since 12 6640 */ 6641 MD_KEY_AUD_SAMPLE_DEPTH = 'sample_depth', 6642 6643 /** 6644 * Key for language. 6645 * @syscap SystemCapability.Multimedia.Media.Core 6646 * @atomicservice 6647 * @since 12 6648 */ 6649 MD_KEY_LANGUAGE = 'language', 6650 6651 /** 6652 * Key for track name, value is string. 6653 * @syscap SystemCapability.Multimedia.Media.Core 6654 * @atomicservice 6655 * @since 12 6656 */ 6657 MD_KEY_TRACK_NAME = 'track_name', 6658 6659 /** 6660 * Key for video hdr type, value type is number. 6661 * @syscap SystemCapability.Multimedia.Media.Core 6662 * @atomicservice 6663 * @since 12 6664 */ 6665 MD_KEY_HDR_TYPE = 'hdr_type', 6666 } 6667 6668 /** 6669 * Provides the video recorder profile definitions. 6670 * 6671 * @typedef VideoRecorderProfile 6672 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6673 * @systemapi 6674 * @since 9 6675 */ 6676 interface VideoRecorderProfile { 6677 /** 6678 * Indicates the audio bit rate. 6679 * @type { number } 6680 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6681 * @systemapi 6682 * @since 9 6683 */ 6684 readonly audioBitrate: number; 6685 6686 /** 6687 * Indicates the number of audio channels. 6688 * @type { number } 6689 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6690 * @systemapi 6691 * @since 9 6692 */ 6693 readonly audioChannels: number; 6694 6695 /** 6696 * Indicates the audio encoding format. 6697 * @type { CodecMimeType } 6698 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6699 * @systemapi 6700 * @since 9 6701 */ 6702 readonly audioCodec: CodecMimeType; 6703 6704 /** 6705 * Indicates the audio sampling rate. 6706 * @type { number } 6707 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6708 * @systemapi 6709 * @since 9 6710 */ 6711 readonly audioSampleRate: number; 6712 6713 /** 6714 * Indicates the output file format. 6715 * @type { ContainerFormatType } 6716 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6717 * @systemapi 6718 * @since 9 6719 */ 6720 readonly fileFormat: ContainerFormatType; 6721 6722 /** 6723 * Indicates the video bit rate. 6724 * @type { number } 6725 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6726 * @systemapi 6727 * @since 9 6728 */ 6729 readonly videoBitrate: number; 6730 6731 /** 6732 * Indicates the video encoding format. 6733 * @type { CodecMimeType } 6734 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6735 * @systemapi 6736 * @since 9 6737 */ 6738 readonly videoCodec: CodecMimeType; 6739 6740 /** 6741 * Indicates the video width. 6742 * @type { number } 6743 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6744 * @systemapi 6745 * @since 9 6746 */ 6747 readonly videoFrameWidth: number; 6748 6749 /** 6750 * Indicates the video height. 6751 * @type { number } 6752 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6753 * @systemapi 6754 * @since 9 6755 */ 6756 readonly videoFrameHeight: number; 6757 6758 /** 6759 * Indicates the video frame rate. 6760 * @type { number } 6761 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6762 * @systemapi 6763 * @since 9 6764 */ 6765 readonly videoFrameRate: number; 6766 } 6767 6768 /** 6769 * Enumerates audio source type for recorder. 6770 * 6771 * @enum { number } 6772 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6773 * @since 9 6774 */ 6775 /** 6776 * Enumerates audio source type for recorder. 6777 * 6778 * @enum { number } 6779 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6780 * @crossplatform 6781 * @atomicservice 6782 * @since 12 6783 */ 6784 enum AudioSourceType { 6785 /** 6786 * Default audio source type. 6787 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6788 * @since 9 6789 */ 6790 /** 6791 * Default audio source type. 6792 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6793 * @crossplatform 6794 * @since 12 6795 */ 6796 AUDIO_SOURCE_TYPE_DEFAULT = 0, 6797 /** 6798 * Source type mic. 6799 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6800 * @since 9 6801 */ 6802 /** 6803 * Source type mic. 6804 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6805 * @crossplatform 6806 * @atomicservice 6807 * @since 12 6808 */ 6809 AUDIO_SOURCE_TYPE_MIC = 1, 6810 /** 6811 * Source type Voice recognition. 6812 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6813 * @since 12 6814 */ 6815 AUDIO_SOURCE_TYPE_VOICE_RECOGNITION = 2, 6816 6817 /** 6818 * Source type Voice communication. 6819 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6820 * @since 12 6821 */ 6822 AUDIO_SOURCE_TYPE_VOICE_COMMUNICATION = 7, 6823 /** 6824 * Source type Voice message. 6825 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6826 * @since 12 6827 */ 6828 AUDIO_SOURCE_TYPE_VOICE_MESSAGE = 10, 6829 /** 6830 * Source type Camcorder. 6831 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6832 * @since 12 6833 */ 6834 AUDIO_SOURCE_TYPE_CAMCORDER = 13, 6835 } 6836 6837 /** 6838 * Enumerates video source type for recorder. 6839 * 6840 * @enum { number } 6841 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6842 * @since 9 6843 */ 6844 /** 6845 * Enumerates video source type for recorder. 6846 * 6847 * @enum { number } 6848 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6849 * @crossplatform 6850 * @since 12 6851 */ 6852 enum VideoSourceType { 6853 /** 6854 * Surface raw data. 6855 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6856 * @since 9 6857 */ 6858 /** 6859 * Surface raw data. 6860 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6861 * @crossplatform 6862 * @since 12 6863 */ 6864 VIDEO_SOURCE_TYPE_SURFACE_YUV = 0, 6865 /** 6866 * Surface ES data. 6867 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6868 * @since 9 6869 */ 6870 /** 6871 * Surface ES data. 6872 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6873 * @crossplatform 6874 * @since 12 6875 */ 6876 VIDEO_SOURCE_TYPE_SURFACE_ES = 1, 6877 } 6878 6879 /** 6880 * Enumerates meta source type for recorder. 6881 * 6882 * @enum { number } 6883 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6884 * @systemapi 6885 * @since 12 6886 */ 6887 enum MetaSourceType { 6888 /** 6889 * Maker info for video. 6890 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6891 * @systemapi 6892 * @since 12 6893 */ 6894 VIDEO_MAKER_INFO = 0, 6895 } 6896 6897 /** 6898 * Enumerates mode of creating recorder file 6899 * 6900 * @enum { number } 6901 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6902 * @since 12 6903 */ 6904 enum FileGenerationMode { 6905 /** 6906 * file created by app 6907 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6908 * @since 12 6909 */ 6910 APP_CREATE = 0, 6911 /** 6912 * file created by system, valid only in camera scene. 6913 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6914 * @since 12 6915 */ 6916 AUTO_CREATE_CAMERA_SCENE = 1, 6917 } 6918 /** 6919 * Provides the video recorder configuration definitions. 6920 * 6921 * @typedef VideoRecorderConfig 6922 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6923 * @systemapi 6924 * @since 9 6925 */ 6926 interface VideoRecorderConfig { 6927 /** 6928 * audio source type, details see @AudioSourceType . 6929 * @type { ?AudioSourceType } 6930 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6931 * @systemapi 6932 * @since 9 6933 */ 6934 audioSourceType?: AudioSourceType; 6935 /** 6936 * video source type, details see @VideoSourceType . 6937 * @type { VideoSourceType } 6938 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6939 * @systemapi 6940 * @since 9 6941 */ 6942 videoSourceType: VideoSourceType; 6943 /** 6944 * video recorder profile, can get by "getVideoRecorderProfile", details see @VideoRecorderProfile .= 6945 * @type { VideoRecorderProfile } 6946 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6947 * @systemapi 6948 * @since 9 6949 */ 6950 profile: VideoRecorderProfile; 6951 /** 6952 * video output uri.support two kind of uri now. 6953 * format like: scheme + "://" + "context". 6954 * fd: fd://fd 6955 * @type { string } 6956 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6957 * @systemapi 6958 * @since 9 6959 */ 6960 url: string; 6961 /** 6962 * Sets the video rotation angle in output file, and for the file to playback. mp4 support. 6963 * the range of rotation angle should be {0, 90, 180, 270}, default is 0. 6964 * @type { ?number } 6965 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6966 * @systemapi 6967 * @since 9 6968 */ 6969 rotation?: number; 6970 /** 6971 * geographical location information. 6972 * @type { ?Location } 6973 * @syscap SystemCapability.Multimedia.Media.VideoRecorder 6974 * @systemapi 6975 * @since 9 6976 */ 6977 location?: Location; 6978 } 6979 6980 /** 6981 * Provides encoder info. 6982 * 6983 * @typedef EncoderInfo 6984 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6985 * @since 11 6986 */ 6987 interface EncoderInfo { 6988 /** 6989 * encoder format MIME 6990 * @type { CodecMimeType } 6991 * @syscap SystemCapability.Multimedia.Media.AVRecorder 6992 * @since 11 6993 */ 6994 mimeType: CodecMimeType; 6995 6996 /** 6997 * encoder type, audio or video 6998 * @type { string } 6999 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7000 * @since 11 7001 */ 7002 type: string; 7003 7004 /** 7005 * audio or video encoder bitRate range 7006 * @type { ?Range } 7007 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7008 * @since 11 7009 */ 7010 bitRate?: Range; 7011 7012 /** 7013 * video encoder frame rate range 7014 * @type { ?Range } 7015 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7016 * @since 11 7017 */ 7018 frameRate?: Range; 7019 7020 /** 7021 * video encoder width range 7022 * @type { ?Range } 7023 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7024 * @since 11 7025 */ 7026 width?: Range; 7027 7028 /** 7029 * video encoder height range 7030 * @type { ?Range } 7031 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7032 * @since 11 7033 */ 7034 height?: Range; 7035 7036 /** 7037 * audio encoder channel range 7038 * @type { ?Range } 7039 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7040 * @since 11 7041 */ 7042 channels?: Range; 7043 7044 /** 7045 * audio encoder sample rate collection 7046 * @type { ?Array<number> } 7047 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7048 * @since 11 7049 */ 7050 sampleRate?: Array<number>; 7051 } 7052 7053 /** 7054 * Provides Range with lower and upper limit. 7055 * 7056 * @typedef Range 7057 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7058 * @since 11 7059 */ 7060 interface Range { 7061 /** 7062 * lower limit of the range 7063 * @type { number } 7064 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7065 * @since 11 7066 */ 7067 min: number; 7068 7069 /** 7070 * upper limit of the range 7071 * @type { number } 7072 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7073 * @since 11 7074 */ 7075 max: number; 7076 } 7077 7078 /** 7079 * Provides the media recorder profile definitions. 7080 * 7081 * @typedef AVRecorderProfile 7082 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7083 * @since 9 7084 */ 7085 /** 7086 * Provides the media recorder profile definitions. 7087 * 7088 * @typedef AVRecorderProfile 7089 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7090 * @crossplatform 7091 * @atomicservice 7092 * @since 12 7093 */ 7094 interface AVRecorderProfile { 7095 /** 7096 * Indicates the audio bitrate. 7097 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7098 * @since 9 7099 */ 7100 /** 7101 * Indicates the audio bitrate. 7102 * @type { ?number } 7103 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7104 * @crossplatform 7105 * @atomicservice 7106 * @since 12 7107 */ 7108 audioBitrate?: number; 7109 7110 /** 7111 * Indicates the number of audio channels. 7112 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7113 * @since 9 7114 */ 7115 /** 7116 * Indicates the number of audio channels. 7117 * @type { ?number } 7118 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7119 * @crossplatform 7120 * @atomicservice 7121 * @since 12 7122 */ 7123 audioChannels?: number; 7124 7125 /** 7126 * Indicates the audio encoding format. 7127 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7128 * @since 9 7129 */ 7130 /** 7131 * Indicates the audio encoding format. 7132 * @type { ?CodecMimeType } 7133 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7134 * @crossplatform 7135 * @atomicservice 7136 * @since 12 7137 */ 7138 audioCodec?: CodecMimeType; 7139 7140 /** 7141 * Indicates the audio sampling rate. 7142 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7143 * @since 9 7144 */ 7145 /** 7146 * Indicates the audio sampling rate. 7147 * @type { ?number } 7148 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7149 * @crossplatform 7150 * @atomicservice 7151 * @since 12 7152 */ 7153 audioSampleRate?: number; 7154 7155 /** 7156 * Indicates the output file format. 7157 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7158 * @since 9 7159 */ 7160 /** 7161 * Indicates the output file format. 7162 * @type { ContainerFormatType } 7163 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7164 * @crossplatform 7165 * @atomicservice 7166 * @since 12 7167 */ 7168 fileFormat: ContainerFormatType; 7169 7170 /** 7171 * Indicates the video bitrate. 7172 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7173 * @since 9 7174 */ 7175 /** 7176 * Indicates the video bitrate. 7177 * @type { ?number } 7178 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7179 * @crossplatform 7180 * @since 12 7181 */ 7182 videoBitrate?: number; 7183 7184 /** 7185 * Indicates the video encoding format. 7186 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7187 * @since 9 7188 */ 7189 /** 7190 * Indicates the video encoding format. 7191 * @type { ?CodecMimeType } 7192 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7193 * @crossplatform 7194 * @since 12 7195 */ 7196 videoCodec?: CodecMimeType; 7197 7198 /** 7199 * Indicates the video width. 7200 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7201 * @since 9 7202 */ 7203 /** 7204 * Indicates the video width. 7205 * @type { ?number } 7206 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7207 * @crossplatform 7208 * @since 12 7209 */ 7210 videoFrameWidth?: number; 7211 7212 /** 7213 * Indicates the video height. 7214 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7215 * @since 9 7216 */ 7217 /** 7218 * Indicates the video height. 7219 * @type { ?number } 7220 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7221 * @crossplatform 7222 * @since 12 7223 */ 7224 videoFrameHeight?: number; 7225 7226 /** 7227 * Indicates the video frame rate. 7228 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7229 * @since 9 7230 */ 7231 /** 7232 * Indicates the video frame rate. 7233 * @type { ?number } 7234 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7235 * @crossplatform 7236 * @since 12 7237 */ 7238 videoFrameRate?: number; 7239 7240 /** 7241 * Whether to record HDR video. 7242 * @type { ?boolean } 7243 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7244 * @since 11 7245 */ 7246 /** 7247 * Whether to record HDR video. 7248 * @type { ?boolean } 7249 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7250 * @crossplatform 7251 * @since 12 7252 */ 7253 isHdr?: boolean; 7254 7255 /** 7256 * Whether to encode the video in temporal scale mode. 7257 * @type { ?boolean } 7258 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7259 * @crossplatform 7260 * @since 12 7261 */ 7262 enableTemporalScale?: boolean; 7263 } 7264 7265 /** 7266 * Provides the media recorder configuration definitions. 7267 * 7268 * @typedef AVRecorderConfig 7269 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7270 * @since 9 7271 */ 7272 /** 7273 * Provides the media recorder configuration definitions. 7274 * 7275 * @typedef AVRecorderConfig 7276 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7277 * @crossplatform 7278 * @atomicservice 7279 * @since 12 7280 */ 7281 interface AVRecorderConfig { 7282 /** 7283 * Audio source type, details see @AudioSourceType . 7284 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7285 * @since 9 7286 */ 7287 /** 7288 * Audio source type, details see @AudioSourceType . 7289 * @type { ?AudioSourceType } 7290 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7291 * @crossplatform 7292 * @atomicservice 7293 * @since 12 7294 */ 7295 audioSourceType?: AudioSourceType; 7296 /** 7297 * Video source type, details see @VideoSourceType . 7298 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7299 * @since 9 7300 */ 7301 /** 7302 * Video source type, details see @VideoSourceType . 7303 * @type { ?VideoSourceType } 7304 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7305 * @crossplatform 7306 * @since 12 7307 */ 7308 videoSourceType?: VideoSourceType; 7309 /** 7310 * Meta source types, details see @MetaSourceType . 7311 * @type { ?Array<MetaSourceType> } 7312 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7313 * @systemapi 7314 * @since 12 7315 */ 7316 metaSourceTypes?: Array<MetaSourceType>; 7317 /** 7318 * Video recorder profile, details see @AVRecorderProfile . 7319 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7320 * @since 9 7321 */ 7322 /** 7323 * Video recorder profile, details see @AVRecorderProfile . 7324 * @type { AVRecorderProfile } 7325 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7326 * @crossplatform 7327 * @atomicservice 7328 * @since 12 7329 */ 7330 profile: AVRecorderProfile; 7331 /** 7332 * File output uri, support a kind of uri now. 7333 * format like: "fd://" + "context". 7334 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7335 * @since 9 7336 */ 7337 /** 7338 * File output uri, support a kind of uri now. 7339 * format like: "fd://" + "context". 7340 * @type { string } 7341 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7342 * @crossplatform 7343 * @atomicservice 7344 * @since 12 7345 */ 7346 url: string; 7347 7348 /** 7349 * Mode of creating recorder file, details see @FileGenerationMode. 7350 * @type { ?FileGenerationMode } 7351 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7352 * @since 12 7353 */ 7354 fileGenerationMode?: FileGenerationMode; 7355 /** 7356 * Sets the video rotation angle in output file, and for the file to playback, mp4 support 7357 * the range of rotation angle should be {0, 90, 180, 270}, default is 0. 7358 * @type { ?number } 7359 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7360 * @since 9 7361 * @deprecated since 12 7362 * @useinstead ohos.multimedia.media/media.AVMetadata#videoOrientation 7363 */ 7364 rotation?: number; 7365 /** 7366 * Geographical location information. 7367 * @type { ?Location } 7368 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7369 * @since 9 7370 * @deprecated since 12 7371 * @useinstead ohos.multimedia.media/media.AVMetadata#location 7372 */ 7373 location?: Location; 7374 /** 7375 * Set global metadata info. Details see @AVMetadata 7376 * @type { ?AVMetadata } 7377 * @syscap SystemCapability.Multimedia.Media.AVRecorder 7378 * @since 12 7379 */ 7380 metadata?: AVMetadata; 7381 } 7382 7383 /** 7384 * Provides the container definition for media description key-value pairs. 7385 * 7386 * @typedef MediaDescription 7387 * @syscap SystemCapability.Multimedia.Media.Core 7388 * @since 8 7389 */ 7390 /** 7391 * Provides the container definition for media description key-value pairs. 7392 * 7393 * @typedef MediaDescription 7394 * @syscap SystemCapability.Multimedia.Media.Core 7395 * @atomicservice 7396 * @since 11 7397 */ 7398 /** 7399 * Provides the container definition for media description key-value pairs. 7400 * 7401 * @typedef MediaDescription 7402 * @syscap SystemCapability.Multimedia.Media.Core 7403 * @crossplatform 7404 * @atomicservice 7405 * @since 12 7406 */ 7407 interface MediaDescription { 7408 /** 7409 * key:value pair, key see @MediaDescriptionKey . 7410 * @syscap SystemCapability.Multimedia.Media.Core 7411 * @since 8 7412 */ 7413 /** 7414 * key:value pair, key see @MediaDescriptionKey . 7415 * @syscap SystemCapability.Multimedia.Media.Core 7416 * @atomicservice 7417 * @since 11 7418 */ 7419 /** 7420 * key:value pair, key see @MediaDescriptionKey . 7421 * @syscap SystemCapability.Multimedia.Media.Core 7422 * @crossplatform 7423 * @atomicservice 7424 * @since 12 7425 */ 7426 [key: string]: Object; 7427 } 7428 7429 /** 7430 * Enumerates seek mode. 7431 * 7432 * @enum { number } 7433 * @syscap SystemCapability.Multimedia.Media.Core 7434 * @since 8 7435 */ 7436 /** 7437 * Enumerates seek mode. 7438 * 7439 * @enum { number } 7440 * @syscap SystemCapability.Multimedia.Media.Core 7441 * @atomicservice 7442 * @since 11 7443 */ 7444 /** 7445 * Enumerates seek mode. 7446 * 7447 * @enum { number } 7448 * @syscap SystemCapability.Multimedia.Media.Core 7449 * @crossplatform 7450 * @atomicservice 7451 * @since 12 7452 */ 7453 enum SeekMode { 7454 /** 7455 * seek to the next sync frame of the given timestamp 7456 * @syscap SystemCapability.Multimedia.Media.Core 7457 * @since 8 7458 */ 7459 /** 7460 * seek to the next sync frame of the given timestamp 7461 * @syscap SystemCapability.Multimedia.Media.Core 7462 * @atomicservice 7463 * @since 11 7464 */ 7465 /** 7466 * seek to the next sync frame of the given timestamp 7467 * @syscap SystemCapability.Multimedia.Media.Core 7468 * @crossplatform 7469 * @atomicservice 7470 * @since 12 7471 */ 7472 SEEK_NEXT_SYNC = 0, 7473 /** 7474 * seek to the previous sync frame of the given timestamp 7475 * @syscap SystemCapability.Multimedia.Media.Core 7476 * @since 8 7477 */ 7478 /** 7479 * seek to the previous sync frame of the given timestamp 7480 * @syscap SystemCapability.Multimedia.Media.Core 7481 * @atomicservice 7482 * @since 11 7483 */ 7484 /** 7485 * seek to the previous sync frame of the given timestamp 7486 * @syscap SystemCapability.Multimedia.Media.Core 7487 * @crossplatform 7488 * @atomicservice 7489 * @since 12 7490 */ 7491 SEEK_PREV_SYNC = 1, 7492 /** 7493 * Seek to the closest frame of the given timestamp. 7494 * @syscap SystemCapability.Multimedia.Media.Core 7495 * @atomicservice 7496 * @since 12 7497 */ 7498 SEEK_CLOSEST = 2, 7499 /** 7500 * Seek in continuous mode. 7501 * @syscap SystemCapability.Multimedia.Media.Core 7502 * @systemapi 7503 * @since 13 7504 */ 7505 SEEK_CONTINUOUS = 3, 7506 } 7507 7508 /** 7509 * Enumerates switch mode. 7510 * 7511 * @enum { number } 7512 * @syscap SystemCapability.Multimedia.Media.Core 7513 * @crossplatform 7514 * @atomicservice 7515 * @since 12 7516 */ 7517 enum SwitchMode { 7518 /** 7519 * switch to the next sync frame of the given timestamp 7520 * @syscap SystemCapability.Multimedia.Media.Core 7521 * @crossplatform 7522 * @atomicservice 7523 * @since 12 7524 */ 7525 SMOOTH = 0, 7526 /** 7527 * switch to the previous sync frame of the given timestamp 7528 * @syscap SystemCapability.Multimedia.Media.Core 7529 * @crossplatform 7530 * @atomicservice 7531 * @since 12 7532 */ 7533 SEGMENT = 1, 7534 /** 7535 * switch to the closest frame of the given timestamp. 7536 * @syscap SystemCapability.Multimedia.Media.Core 7537 * @atomicservice 7538 * @since 12 7539 */ 7540 CLOSEST = 2, 7541 } 7542 7543 /** 7544 * Enumerates Codec MIME types. 7545 * 7546 * @enum { string } 7547 * @syscap SystemCapability.Multimedia.Media.Core 7548 * @since 8 7549 */ 7550 /** 7551 * Enumerates Codec MIME types. 7552 * 7553 * @enum { string } 7554 * @syscap SystemCapability.Multimedia.Media.Core 7555 * @crossplatform 7556 * @atomicservice 7557 * @since 12 7558 */ 7559 enum CodecMimeType { 7560 /** 7561 * H.263 codec MIME type. 7562 * @syscap SystemCapability.Multimedia.Media.Core 7563 * @since 8 7564 */ 7565 /** 7566 * H.263 codec MIME type. 7567 * @syscap SystemCapability.Multimedia.Media.Core 7568 * @crossplatform 7569 * @since 12 7570 */ 7571 VIDEO_H263 = 'video/h263', 7572 /** 7573 * H.264 codec MIME type. 7574 * @syscap SystemCapability.Multimedia.Media.Core 7575 * @since 8 7576 */ 7577 /** 7578 * H.264 codec MIME type. 7579 * @syscap SystemCapability.Multimedia.Media.Core 7580 * @crossplatform 7581 * @since 12 7582 */ 7583 VIDEO_AVC = 'video/avc', 7584 /** 7585 * MPEG2 codec MIME type. 7586 * @syscap SystemCapability.Multimedia.Media.Core 7587 * @since 8 7588 */ 7589 /** 7590 * MPEG2 codec MIME type. 7591 * @syscap SystemCapability.Multimedia.Media.Core 7592 * @crossplatform 7593 * @since 12 7594 */ 7595 VIDEO_MPEG2 = 'video/mpeg2', 7596 /** 7597 * MPEG4 codec MIME type 7598 * @syscap SystemCapability.Multimedia.Media.Core 7599 * @since 8 7600 */ 7601 /** 7602 * MPEG4 codec MIME type 7603 * @syscap SystemCapability.Multimedia.Media.Core 7604 * @crossplatform 7605 * @since 12 7606 */ 7607 VIDEO_MPEG4 = 'video/mp4v-es', 7608 7609 /** 7610 * VP8 codec MIME type 7611 * @syscap SystemCapability.Multimedia.Media.Core 7612 * @since 8 7613 */ 7614 /** 7615 * VP8 codec MIME type 7616 * @syscap SystemCapability.Multimedia.Media.Core 7617 * @crossplatform 7618 * @since 12 7619 */ 7620 VIDEO_VP8 = 'video/x-vnd.on2.vp8', 7621 7622 /** 7623 * AAC codec MIME type. 7624 * @syscap SystemCapability.Multimedia.Media.Core 7625 * @since 8 7626 */ 7627 /** 7628 * AAC codec MIME type. 7629 * @syscap SystemCapability.Multimedia.Media.Core 7630 * @crossplatform 7631 * @atomicservice 7632 * @since 12 7633 */ 7634 AUDIO_AAC = 'audio/mp4a-latm', 7635 7636 /** 7637 * vorbis codec MIME type. 7638 * @syscap SystemCapability.Multimedia.Media.Core 7639 * @since 8 7640 */ 7641 /** 7642 * vorbis codec MIME type. 7643 * @syscap SystemCapability.Multimedia.Media.Core 7644 * @crossplatform 7645 * @since 12 7646 */ 7647 AUDIO_VORBIS = 'audio/vorbis', 7648 7649 /** 7650 * flac codec MIME type. 7651 * @syscap SystemCapability.Multimedia.Media.Core 7652 * @since 8 7653 */ 7654 /** 7655 * flac codec MIME type. 7656 * @syscap SystemCapability.Multimedia.Media.Core 7657 * @crossplatform 7658 * @since 12 7659 */ 7660 AUDIO_FLAC = 'audio/flac', 7661 7662 /** 7663 * H.265 codec MIME type. 7664 * @syscap SystemCapability.Multimedia.Media.Core 7665 * @since 11 7666 */ 7667 /** 7668 * H.265 codec MIME type. 7669 * @syscap SystemCapability.Multimedia.Media.Core 7670 * @crossplatform 7671 * @since 12 7672 */ 7673 VIDEO_HEVC = 'video/hevc', 7674 /** 7675 * mp3 codec MIME type. 7676 * @syscap SystemCapability.Multimedia.Media.Core 7677 * @since 12 7678 */ 7679 AUDIO_MP3 = 'audio/mpeg', 7680 /** 7681 * G711-mulaw codec MIME type. 7682 * @syscap SystemCapability.Multimedia.Media.Core 7683 * @since 12 7684 */ 7685 AUDIO_G711MU = 'audio/g711mu', 7686 } 7687 7688 /** 7689 * Enumerates AVScreenCaptureRecord preset types. 7690 * 7691 * @enum { number } 7692 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7693 * @since 12 7694 */ 7695 enum AVScreenCaptureRecordPreset { 7696 /** 7697 * Screen record normal type, h264/aac mp4 7698 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7699 * @since 12 7700 */ 7701 SCREEN_RECORD_PRESET_H264_AAC_MP4 = 0, 7702 /** 7703 * Screen record high efficient type, h265/aac mp4 7704 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7705 * @since 12 7706 */ 7707 SCREEN_RECORD_PRESET_H265_AAC_MP4 = 1, 7708 } 7709 7710 /** 7711 * Enumerates AVScreenCapture callback state type. 7712 * 7713 * @enum { number } 7714 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7715 * @since 12 7716 */ 7717 enum AVScreenCaptureStateCode { 7718 /** 7719 * Screen capture started 7720 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7721 * @since 12 7722 */ 7723 SCREENCAPTURE_STATE_STARTED = 0, 7724 /** 7725 * Screen capture canceled 7726 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7727 * @since 12 7728 */ 7729 SCREENCAPTURE_STATE_CANCELED = 1, 7730 /** 7731 * Screen capture stopped by user 7732 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7733 * @since 12 7734 */ 7735 SCREENCAPTURE_STATE_STOPPED_BY_USER = 2, 7736 /** 7737 * Screen capture stopped by interrupt 7738 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7739 * @since 12 7740 */ 7741 SCREENCAPTURE_STATE_INTERRUPTED_BY_OTHER = 3, 7742 /** 7743 * Screen capture stopped by phone call 7744 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7745 * @since 12 7746 */ 7747 SCREENCAPTURE_STATE_STOPPED_BY_CALL = 4, 7748 /** 7749 * Screen capture microphone not available 7750 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7751 * @since 12 7752 */ 7753 SCREENCAPTURE_STATE_MIC_UNAVAILABLE = 5, 7754 /** 7755 * Screen capture microphone is muted by user 7756 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7757 * @since 12 7758 */ 7759 SCREENCAPTURE_STATE_MIC_MUTED_BY_USER = 6, 7760 /** 7761 * Screen capture microphone is unmuted by user 7762 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7763 * @since 12 7764 */ 7765 SCREENCAPTURE_STATE_MIC_UNMUTED_BY_USER = 7, 7766 /** 7767 * Screen capture enter private scene 7768 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7769 * @since 12 7770 */ 7771 SCREENCAPTURE_STATE_ENTER_PRIVATE_SCENE = 8, 7772 /** 7773 * Screen capture exit private scene 7774 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7775 * @since 12 7776 */ 7777 SCREENCAPTURE_STATE_EXIT_PRIVATE_SCENE = 9, 7778 /** 7779 * Screen capture stopped by user switches 7780 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7781 * @since 12 7782 */ 7783 SCREENCAPTURE_STATE_STOPPED_BY_USER_SWITCHES = 10, 7784 } 7785 7786 /** 7787 * Provides the media AVScreenCaptureRecord config definition. 7788 * 7789 * @typedef AVScreenCaptureRecordConfig 7790 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7791 * @since 12 7792 */ 7793 interface AVScreenCaptureRecordConfig { 7794 /** 7795 * Indicates record file descriptor. 7796 * @type { number } 7797 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7798 * @since 12 7799 */ 7800 fd: number; 7801 /** 7802 * Indicates video frame width. 7803 * @type { ?number } 7804 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7805 * @since 12 7806 */ 7807 frameWidth?: number; 7808 /** 7809 * Indicates video frame height. 7810 * @type { ?number } 7811 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7812 * @since 12 7813 */ 7814 frameHeight?: number; 7815 /** 7816 * Indicates video bitrate. 7817 * @type { ?number } 7818 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7819 * @since 12 7820 */ 7821 videoBitrate?: number; 7822 /** 7823 * Indicates audio sample rate. 7824 * @type { ?number } 7825 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7826 * @since 12 7827 */ 7828 audioSampleRate?: number; 7829 /** 7830 * Indicates audio channel count. 7831 * @type { ?number } 7832 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7833 * @since 12 7834 */ 7835 audioChannelCount?: number; 7836 /** 7837 * Indicates audio bitrate. 7838 * @type { ?number } 7839 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7840 * @since 12 7841 */ 7842 audioBitrate?: number; 7843 /** 7844 * Indicates AVScreenCaptureRecordPreset, details see @AVScreenCaptureRecordPreset 7845 * @type { ?AVScreenCaptureRecordPreset } 7846 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7847 * @since 12 7848 */ 7849 preset?: AVScreenCaptureRecordPreset; 7850 } 7851 7852 /** 7853 * Provides screen capture record. Before calling an AVScreenCaptureRecorder method, you must use createAVScreenCaptureRecorder() 7854 * to create an AVScreenCaptureRecorder instance. 7855 * 7856 * @typedef AVScreenCaptureRecorder 7857 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7858 * @since 12 7859 */ 7860 interface AVScreenCaptureRecorder { 7861 /** 7862 * Init AVScreenCaptureRecorder. 7863 * @param { AVScreenCaptureRecordConfig } config - AVScreenCaptureRecorder config. 7864 * @returns { Promise<void> } A Promise instance used to return when init completed. 7865 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7866 * <br>2. Incorrect parameter types. 3. Parameter verification failed. Return by promise. 7867 * @throws { BusinessError } 5400103 - IO error. Return by promise. 7868 * @throws { BusinessError } 5400105 - Service died. Return by promise. 7869 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7870 * @since 12 7871 */ 7872 init(config: AVScreenCaptureRecordConfig): Promise<void>; 7873 7874 /** 7875 * Start screen capture recording. 7876 * @returns { Promise<void> } A Promise instance used to return when startRecording completed. 7877 * @throws { BusinessError } 5400103 - IO error. Return by promise. 7878 * @throws { BusinessError } 5400105 - Service died. Return by promise. 7879 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7880 * @since 12 7881 */ 7882 startRecording(): Promise<void>; 7883 7884 /** 7885 * Stop screen capture recording. 7886 * @returns { Promise<void> } A Promise instance used to return when stopRecording completed. 7887 * @throws { BusinessError } 5400103 - IO error. Return by promise. 7888 * @throws { BusinessError } 5400105 - Service died. Return by promise. 7889 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7890 * @since 12 7891 */ 7892 stopRecording(): Promise<void>; 7893 7894 /** 7895 * Skip some windows' privacy mode of current app during the screen recording. 7896 * @param { Array<number> } windowIDs - windowID list to be skipped privacy mode . 7897 * @returns { Promise<void> } A Promise instance used to return when skipPrivacyMode completed. 7898 * @throws { BusinessError } 5400103 - IO error. Return by promise. 7899 * @throws { BusinessError } 5400105 - Service died. Return by promise. 7900 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7901 * @since 12 7902 */ 7903 skipPrivacyMode(windowIDs: Array<number>): Promise<void>; 7904 7905 /** 7906 * Set microphone enable or disable. 7907 * @param { boolean } enable - Set microphone enable or disable during recording. 7908 * @returns { Promise<void> } A Promise instance used to return when setMicEnabled completed. 7909 * @throws { BusinessError } 5400103 - IO error. Return by promise. 7910 * @throws { BusinessError } 5400105 - Service died. Return by promise. 7911 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7912 * @since 12 7913 */ 7914 setMicEnabled(enable: boolean): Promise<void>; 7915 7916 /** 7917 * Release screen capture recording. 7918 * @returns { Promise<void> } A Promise instance used to return when release completed. 7919 * @throws { BusinessError } 5400103 - IO error. Return by promise. 7920 * @throws { BusinessError } 5400105 - Service died. Return by promise. 7921 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7922 * @since 12 7923 */ 7924 release(): Promise<void>; 7925 7926 /** 7927 * Listens for AVScreenCaptureRecord info callback. 7928 * @param { 'stateChange' } type - Type of the AVScreenCaptureRecord event to listen for. 7929 * @param { Callback<AVScreenCaptureStateCode> } callback - Callback used to listen for the AVScreenCaptureRecord info return. 7930 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7931 * @since 12 7932 */ 7933 on(type: 'stateChange', callback: Callback<AVScreenCaptureStateCode>): void; 7934 7935 /** 7936 * Listens for AVScreenCaptureRecord info callback. 7937 * @param { 'error' } type - Type of the AVScreenCaptureRecord event to listen for. 7938 * @param { ErrorCallback } callback - Callback used to listen for the AVScreenCaptureRecord error return. 7939 * @throws { BusinessError } 201 - permission denied. 7940 * @throws { BusinessError } 5400103 - IO error. Return by ErrorCallback. 7941 * @throws { BusinessError } 5400105 - Service died. Return by ErrorCallback. 7942 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7943 * @since 12 7944 */ 7945 on(type: 'error', callback: ErrorCallback): void; 7946 7947 /** 7948 * Unregister listens for AVScreenCaptureRecord info callback. 7949 * @param { 'stateChange' } type - Type of the AVScreenCaptureRecord event to listen for. 7950 * @param { Callback<AVScreenCaptureStateCode> } callback - Callback used to listen for the AVScreenCaptureRecord info return. 7951 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7952 * @since 12 7953 */ 7954 off(type: 'stateChange', callback?: Callback<AVScreenCaptureStateCode>): void; 7955 7956 /** 7957 * Unregister listens for AVScreenCaptureRecord error callback. 7958 * @param { 'error' } type - Type of the AVScreenCaptureRecord event to listen for. 7959 * @param { ErrorCallback } callback - Callback used to listen for the AVScreenCaptureRecord error return. 7960 * @syscap SystemCapability.Multimedia.Media.AVScreenCapture 7961 * @since 12 7962 */ 7963 off(type: 'error', callback?: ErrorCallback): void; 7964 } 7965 7966 /** 7967 * Provides the video transcode configuration definitions 7968 * 7969 * @typedef AVTranscoderConfig 7970 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 7971 * @since 12 7972 */ 7973 interface AVTranscoderConfig { 7974 /** 7975 * Indicates the audio bitrate. 7976 * @type { ?number } 7977 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 7978 * @since 12 7979 */ 7980 audioBitrate?: number; 7981 7982 /** 7983 * Indicates the audio encoding format. 7984 * @type { ?CodecMimeType } 7985 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 7986 * @since 12 7987 */ 7988 audioCodec?: CodecMimeType; 7989 7990 /** 7991 * Indicates the output file format. 7992 * @type { ContainerFormatType } 7993 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 7994 * @since 12 7995 */ 7996 fileFormat: ContainerFormatType; 7997 7998 /** 7999 * Indicates the video bitrate. 8000 * @type { ?number } 8001 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8002 * @since 12 8003 */ 8004 videoBitrate?: number; 8005 8006 /** 8007 * Indicates the video encoding foramt. 8008 * @type { ?CodecMimeType } 8009 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8010 * @since 12 8011 */ 8012 videoCodec?: CodecMimeType; 8013 8014 /** 8015 * Indicates the video width. 8016 * @type { ?number } 8017 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8018 * @since 12 8019 */ 8020 videoFrameWidth?: number; 8021 8022 /** 8023 * Indicates the video height. 8024 * @type { ?number } 8025 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8026 * @since 12 8027 */ 8028 videoFrameHeight?: number; 8029 } 8030 8031 /** 8032 * Transcode a source video file to a destination video file. 8033 * Before calling an AVTranscoder method, you must use @createAVTranscoder 8034 * to create an AVTranscoder instance. 8035 * 8036 * @typedef AVTranscoder 8037 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8038 * @since 12 8039 */ 8040 interface AVTranscoder { 8041 /** 8042 * Source media file descriptor. Mainstream media formats are supported. 8043 * @type { AVFileDescriptor } 8044 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8045 * @since 12 8046 */ 8047 fdSrc: AVFileDescriptor; 8048 8049 /** 8050 * Destination media file descriptor. Mainstream media formats are supported. 8051 * @type { number } 8052 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8053 * @since 12 8054 */ 8055 fdDst: number; 8056 8057 /** 8058 * Prepares for transcoding. 8059 * @param { AVTranscoderConfig } config : Recording parameters. 8060 * @returns { Promise<void> } A promise instance used to return when prepare completes. 8061 * @throws { BusinessError } 401 - The parameter check failed. Return by promise. 8062 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 8063 * @throws { BusinessError } 5400105 - Service died. Return by promise. 8064 * @throws { BusinessError } 5400106 - Unsupported format. Returned by promise. 8065 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8066 * @since 12 8067 */ 8068 prepare(config: AVTranscoderConfig): Promise<void>; 8069 8070 /** 8071 * Start AVTranscoder. 8072 * @returns { Promise<void> } A promise instance used to return when start completes. 8073 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 8074 * @throws { BusinessError } 5400103 - IO error. Return by promise. 8075 * @throws { BusinessError } 5400105 - Service died. Return by promise. 8076 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8077 * @since 12 8078 */ 8079 start(): Promise<void>; 8080 8081 /** 8082 * Pause AVTranscoder. 8083 * @returns { Promise<void> } A promise instance used to return when pause completes. 8084 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 8085 * @throws { BusinessError } 5400103 - IO error. Return by promise. 8086 * @throws { BusinessError } 5400105 - Service died. Return by promise. 8087 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8088 * @since 12 8089 */ 8090 pause(): Promise<void>; 8091 8092 /** 8093 * Resume AVTranscoder. 8094 * @returns { Promise<void> } A promise instance used to return when resume completes. 8095 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 8096 * @throws { BusinessError } 5400103 - IO error. Return by promise. 8097 * @throws { BusinessError } 5400105 - Service died. Return by promise. 8098 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8099 * @since 12 8100 */ 8101 resume(): Promise<void>; 8102 8103 /** 8104 * Cancel AVTranscoder. 8105 * @returns { Promise<void> } A promise instance used to return when cancel completes. 8106 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 8107 * @throws { BusinessError } 5400103 - IO error. Return by promise. 8108 * @throws { BusinessError } 5400105 - Service died. Return by promise. 8109 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8110 * @since 12 8111 */ 8112 cancel(): Promise<void>; 8113 8114 /** 8115 * Release resources used for AVTranscoder. 8116 * @returns { Promise<void> } A promise instance used to return when cancel completes. 8117 * @throws { BusinessError } 5400102 - Operation not allowed. Return by promise. 8118 * @throws { BusinessError } 5400105 - Service died. Return by promise. 8119 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8120 * @since 12 8121 */ 8122 release(): Promise<void>; 8123 8124 /** 8125 * Register listener for trancoding complete event. 8126 * @param { 'complete' } type - Type of the event to listen for. 8127 * @param { Callback<void> } callback - Callback used to listen for the complete event. 8128 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8129 * @since 12 8130 */ 8131 on(type:'complete', callback: Callback<void>):void; 8132 8133 /** 8134 * Register listener for trancoding error event. 8135 * @param { 'error' } type - Type of the event to listen for. 8136 * @param { ErrorCallback } callback - Callback used to listen for the error event. 8137 * @throws { BusinessError } 401 - The parameter check failed. 8138 * @throws { BusinessError } 801 - Capability not supported. 8139 * @throws { BusinessError } 5400101 - No memory. 8140 * @throws { BusinessError } 5400102 - Operation not allowed. 8141 * @throws { BusinessError } 5400103 - I/O error. 8142 * @throws { BusinessError } 5400104 - Time out. 8143 * @throws { BusinessError } 5400105 - Service died. 8144 * @throws { BusinessError } 5400106 - Unsupport format. 8145 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8146 * @since 12 8147 */ 8148 on(type:'error', callback: ErrorCallback):void; 8149 8150 /** 8151 * Register listener for trancoding progressUpdate event. 8152 * @param { 'progressUpdate' } type - Type of the event to listen for. 8153 * @param { Callback<number> } callback - Callback used to listen for the progressUpdate event. 8154 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8155 * @since 12 8156 */ 8157 on(type:'progressUpdate', callback: Callback<number>):void; 8158 8159 /** 8160 * Unregister listener for trancoding complete event. 8161 * @param { 'complete' } type - Type of the event to listen for. 8162 * @param { Callback<void> } [callback] - Callback used to listen for the complete event. 8163 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8164 * @since 12 8165 */ 8166 off(type:'complete', callback?: Callback<void>):void; 8167 8168 /** 8169 * Unregister listener for trancoding error event. 8170 * @param { 'error' } type - Type of the event to listen for. 8171 * @param { ErrorCallback } [callback] - Callback used to listen for the error event. 8172 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8173 * @since 12 8174 */ 8175 off(type:'error', callback?: ErrorCallback):void; 8176 8177 /** 8178 * Unregister listener for trancoding progressUpdate event. 8179 * @param { 'progressUpdate' } type - Type of the event to listen for. 8180 * @param { Callback<number> } [callback] - Callback used to listen for the progressUpdate event. 8181 * @syscap SystemCapability.Multimedia.Media.AVTranscoder 8182 * @since 12 8183 */ 8184 off(type:'progressUpdate', callback?: Callback<number>):void; 8185 } 8186} 8187export default media; 8188