1/* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit AudioKit 19 */ 20 21import { ErrorCallback, AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * @namespace audio 25 * @since 7 26 */ 27/** 28 * @namespace audio 29 * @syscap SystemCapability.Multimedia.Audio.Core 30 * @crossplatform 31 * @atomicservice 32 * @since 12 33 */ 34declare namespace audio { 35 /** 36 * Enumerates audio errors. 37 * @enum { number } 38 * @syscap SystemCapability.Multimedia.Audio.Core 39 * @since 9 40 */ 41 /** 42 * Enumerates audio errors. 43 * @enum { number } 44 * @syscap SystemCapability.Multimedia.Audio.Core 45 * @crossplatform 46 * @since 12 47 */ 48 enum AudioErrors { 49 /** 50 * Invalid parameter. 51 * @syscap SystemCapability.Multimedia.Audio.Core 52 * @since 9 53 */ 54 /** 55 * Invalid parameter. 56 * @syscap SystemCapability.Multimedia.Audio.Core 57 * @crossplatform 58 * @since 12 59 */ 60 ERROR_INVALID_PARAM = 6800101, 61 /** 62 * Allocate memory failed. 63 * @syscap SystemCapability.Multimedia.Audio.Core 64 * @since 9 65 */ 66 /** 67 * Allocate memory failed. 68 * @syscap SystemCapability.Multimedia.Audio.Core 69 * @crossplatform 70 * @since 12 71 */ 72 ERROR_NO_MEMORY = 6800102, 73 /** 74 * Operation not permit at current state. 75 * @syscap SystemCapability.Multimedia.Audio.Core 76 * @since 9 77 */ 78 /** 79 * Operation not permit at current state. 80 * @syscap SystemCapability.Multimedia.Audio.Core 81 * @crossplatform 82 * @since 12 83 */ 84 ERROR_ILLEGAL_STATE = 6800103, 85 /** 86 * Unsupported option. 87 * @syscap SystemCapability.Multimedia.Audio.Core 88 * @since 9 89 */ 90 /** 91 * Unsupported option. 92 * @syscap SystemCapability.Multimedia.Audio.Core 93 * @crossplatform 94 * @since 12 95 */ 96 ERROR_UNSUPPORTED = 6800104, 97 /** 98 * Time out. 99 * @syscap SystemCapability.Multimedia.Audio.Core 100 * @since 9 101 */ 102 ERROR_TIMEOUT = 6800105, 103 /** 104 * Audio specific errors. 105 * @syscap SystemCapability.Multimedia.Audio.Core 106 * @since 9 107 */ 108 ERROR_STREAM_LIMIT = 6800201, 109 /** 110 * Default error. 111 * @syscap SystemCapability.Multimedia.Audio.Core 112 * @since 9 113 */ 114 /** 115 * Default error. 116 * @syscap SystemCapability.Multimedia.Audio.Core 117 * @crossplatform 118 * @since 12 119 */ 120 ERROR_SYSTEM = 6800301 121 } 122 123 /** 124 * Define local device network id for audio 125 * @syscap SystemCapability.Multimedia.Audio.Device 126 * @systemapi 127 * @since 9 128 */ 129 const LOCAL_NETWORK_ID: string; 130 131 /** 132 * Define default volume group id for audio 133 * @syscap SystemCapability.Multimedia.Audio.Volume 134 * @since 9 135 */ 136 /** 137 * Define default volume group id for audio 138 * @syscap SystemCapability.Multimedia.Audio.Volume 139 * @crossplatform 140 * @since 12 141 */ 142 const DEFAULT_VOLUME_GROUP_ID: number; 143 144 /** 145 * Define default interrupt group id for audio 146 * @syscap SystemCapability.Multimedia.Audio.Interrupt 147 * @since 9 148 */ 149 const DEFAULT_INTERRUPT_GROUP_ID: number; 150 151 /** 152 * Obtains an {@link AudioManager} instance. 153 * @returns { AudioManager } this {@link AudioManager} object. 154 * @syscap SystemCapability.Multimedia.Audio.Core 155 * @since 7 156 */ 157 /** 158 * Obtains an {@link AudioManager} instance. 159 * <p><strong>NOTE</strong>: 160 * The {@link AudioManager} instance is not a singleton. 161 * </p> 162 * 163 * @returns { AudioManager } this {@link AudioManager} object. 164 * @syscap SystemCapability.Multimedia.Audio.Core 165 * @crossplatform 166 * @since 12 167 */ 168 function getAudioManager(): AudioManager; 169 170 /** 171 * Obtains an {@link AudioCapturer} instance. 172 * Success: This method uses an asynchronous callback to return the capturer instance. 173 * Failure: This method uses an asynchronous callback to return the error instance. Possible causes: 174 * 6800301: Parameter verification failed, Permission denied, System error; 175 * 6800101: Mandatory parameters are left unspecified, Incorrect parameter types. 176 * @param { AudioCapturerOptions } options - Capturer configurations. 177 * @param { AsyncCallback<AudioCapturer> } callback - Callback used to return the audio capturer instance. 178 * @syscap SystemCapability.Multimedia.Audio.Capturer 179 * @since 8 180 */ 181 /** 182 * Obtains an {@link AudioCapturer} instance. This method uses an asynchronous callback to return the capturer instance. 183 * @param { AudioCapturerOptions } options - Capturer configurations. 184 * @param { AsyncCallback<AudioCapturer> } callback - Callback used to return the audio capturer instance. 185 * @syscap SystemCapability.Multimedia.Audio.Capturer 186 * @crossplatform 187 * @since 12 188 */ 189 function createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<AudioCapturer>): void; 190 191 /** 192 * Obtains an {@link AudioCapturer} instance. 193 * Success: This method uses a promise to return the capturer instance. 194 * Failure: This method uses a promise to return the error instance. Possible causes: 195 * 6800301: Parameter verification failed, Permission denied, System error; 196 * 6800101: Mandatory parameters are left unspecified, Incorrect parameter types. 197 * @param { AudioCapturerOptions } options - Capturer configurations. 198 * @returns { Promise<AudioCapturer> } Promise used to return the audio capturer instance. 199 * @syscap SystemCapability.Multimedia.Audio.Capturer 200 * @since 8 201 */ 202 /** 203 * Obtains an {@link AudioCapturer} instance. This method uses a promise to return the capturer instance. 204 * @param { AudioCapturerOptions } options - Capturer configurations. 205 * @returns { Promise<AudioCapturer> } Promise used to return the audio capturer instance. 206 * @syscap SystemCapability.Multimedia.Audio.Capturer 207 * @crossplatform 208 * @since 12 209 */ 210 function createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer>; 211 212 /** 213 * Obtains an {@link AudioRenderer} instance. 214 * This method uses an asynchronous callback to return the renderer instance. 215 * @param { AudioRendererOptions } options - Renderer configurations. 216 * @param { AsyncCallback<AudioRenderer> } callback - Callback used to return the audio renderer instance. 217 * @syscap SystemCapability.Multimedia.Audio.Renderer 218 * @since 8 219 */ 220 /** 221 * Obtains an {@link AudioRenderer} instance. 222 * This method uses a promise to return the renderer instance. 223 * 224 * The AudioRenderer instance is used to play streaming audio data. 225 * When using AudioRenderer apis, there are many instructions for application 226 * to achieve better performance and lower power consumption: 227 * In music or audiobook background playback situation, you can have low power 228 * consumption by following this best practices document **Low-Power Rules in Music Playback Scenarios**. 229 * And for navigation situation, you can follow **Low-Power Rules in Navigation and Positioning Scenarios**. 230 * 231 * Application developer should also be careful when app goes to background, please check if your audio playback 232 * is still needed, see **Audio Resources** in best practices document. 233 * And avoiding to send silence audio data continuously to waste system resources, otherwise system will take 234 * control measures when this behavior is detected, see **Audio Playback** in best practices document. 235 * 236 * If you want to use AudioRenderer api to implement a music playback application, there are also many interactive 237 * scenes to consider, see **Developing an Audio Application** in best practices document. 238 * 239 * @param { AudioRendererOptions } options - Renderer configurations. 240 * @param { AsyncCallback<AudioRenderer> } callback - Callback used to return the audio renderer instance. 241 * @syscap SystemCapability.Multimedia.Audio.Renderer 242 * @crossplatform 243 * @since 12 244 */ 245 function createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback<AudioRenderer>): void; 246 247 /** 248 * Obtains an {@link AudioRenderer} instance. 249 * This method uses a promise to return the renderer instance. 250 * @param { AudioRendererOptions } options - Renderer configurations. 251 * @returns { Promise<AudioRenderer> } Promise used to return the audio renderer instance. 252 * @syscap SystemCapability.Multimedia.Audio.Renderer 253 * @since 8 254 */ 255 /** 256 * Obtains an {@link AudioRenderer} instance. 257 * This method uses a promise to return the renderer instance. 258 * 259 * The AudioRenderer instance is used to play streaming audio data. 260 * When using AudioRenderer apis, there are many instructions for application 261 * to achieve better performance and lower power consumption: 262 * In music or audiobook background playback situation, you can have low power 263 * consumption by following this best practices document **Low-Power Rules in Music Playback Scenarios**. 264 * And for navigation situation, you can follow **Low-Power Rules in Navigation and Positioning Scenarios**. 265 * 266 * Application developer should also be careful when app goes to background, please check if your audio playback 267 * is still needed, see **Audio Resources** in best practices document. 268 * And avoiding to send silence audio data continuously to waste system resources, otherwise system will take 269 * control measures when this behavior is detected, see **Audio Playback** in best practices document. 270 * 271 * If you want to use AudioRenderer api to implement a music playback application, there are also many interactive 272 * scenes to consider, see **Developing an Audio Application** in best practices document. 273 * 274 * @param { AudioRendererOptions } options - Renderer configurations. 275 * @returns { Promise<AudioRenderer> } Promise used to return the audio renderer instance. 276 * @syscap SystemCapability.Multimedia.Audio.Renderer 277 * @crossplatform 278 * @since 12 279 */ 280 function createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer>; 281 282 /** 283 * Obtains a {@link TonePlayer} instance. This method uses an asynchronous callback to return the renderer instance. 284 * @param { AudioRendererInfo } options - Tone playing attribute. 285 * @param { AsyncCallback<TonePlayer> } callback - Callback used to return the tonePlayer instance. 286 * @syscap SystemCapability.Multimedia.Audio.Tone 287 * @systemapi 288 * @since 9 289 */ 290 function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback<TonePlayer>): void; 291 292 /** 293 * Obtains a {@link TonePlayer} instance. This method uses a promise to return the renderer instance. 294 * @param { AudioRendererInfo } options - Tone playing attribute. 295 * @returns { Promise<TonePlayer> } Promise used to return the tonePlayer instance. 296 * @syscap SystemCapability.Multimedia.Audio.Tone 297 * @systemapi 298 * @since 9 299 */ 300 function createTonePlayer(options: AudioRendererInfo): Promise<TonePlayer>; 301 302 /** 303 * Creates an <b>AudioLoopback</b> instance, which provides low-latency in-ear monitoring using a fast capturer and renderer. 304 * 305 * @permission ohos.permission.MICROPHONE 306 * @param { AudioLoopbackMode } mode Audio loopback mode. 307 * @returns { Promise<AudioLoopback> } Promise used to return the <b>AudioLoopback</b> instance. 308 * @throws { BusinessError } 201 - Permission denied. 309 * @throws { BusinessError } 801 - Unsupported API. 310 * @throws { BusinessError } 6800101 - Parameter verification failed. 311 * @throws { BusinessError } 6800104 - Loopback mode is unsupported. 312 * @syscap SystemCapability.Multimedia.Audio.Capturer 313 * @since 20 314 */ 315 function createAudioLoopback(mode: AudioLoopbackMode): Promise<AudioLoopback>; 316 317 /** 318 * Enumerates the audio states. 319 * @enum { number } 320 * @syscap SystemCapability.Multimedia.Audio.Core 321 * @since 8 322 */ 323 /** 324 * Enumerates the audio states. 325 * @enum { number } 326 * @syscap SystemCapability.Multimedia.Audio.Core 327 * @crossplatform 328 * @since 12 329 */ 330 enum AudioState { 331 /** 332 * Invalid state. 333 * @syscap SystemCapability.Multimedia.Audio.Core 334 * @since 8 335 */ 336 /** 337 * Invalid state. 338 * @syscap SystemCapability.Multimedia.Audio.Core 339 * @crossplatform 340 * @since 12 341 */ 342 STATE_INVALID = -1, 343 /** 344 * Create new instance state. 345 * @syscap SystemCapability.Multimedia.Audio.Core 346 * @since 8 347 */ 348 /** 349 * Create new instance state. 350 * @syscap SystemCapability.Multimedia.Audio.Core 351 * @crossplatform 352 * @since 12 353 */ 354 STATE_NEW = 0, 355 /** 356 * Prepared state. 357 * @syscap SystemCapability.Multimedia.Audio.Core 358 * @since 8 359 */ 360 /** 361 * Prepared state. 362 * @syscap SystemCapability.Multimedia.Audio.Core 363 * @crossplatform 364 * @since 12 365 */ 366 STATE_PREPARED = 1, 367 /** 368 * Running state. 369 * @syscap SystemCapability.Multimedia.Audio.Core 370 * @since 8 371 */ 372 /** 373 * Running state. 374 * @syscap SystemCapability.Multimedia.Audio.Core 375 * @crossplatform 376 * @since 12 377 */ 378 STATE_RUNNING = 2, 379 /** 380 * Stopped state. 381 * @syscap SystemCapability.Multimedia.Audio.Core 382 * @since 8 383 */ 384 /** 385 * Stopped state. 386 * @syscap SystemCapability.Multimedia.Audio.Core 387 * @crossplatform 388 * @since 12 389 */ 390 STATE_STOPPED = 3, 391 /** 392 * Released state. 393 * @syscap SystemCapability.Multimedia.Audio.Core 394 * @since 8 395 */ 396 /** 397 * Released state. 398 * @syscap SystemCapability.Multimedia.Audio.Core 399 * @crossplatform 400 * @since 12 401 */ 402 STATE_RELEASED = 4, 403 /** 404 * Paused state. 405 * @syscap SystemCapability.Multimedia.Audio.Core 406 * @since 8 407 */ 408 /** 409 * Paused state. 410 * @syscap SystemCapability.Multimedia.Audio.Core 411 * @crossplatform 412 * @since 12 413 */ 414 STATE_PAUSED = 5 415 } 416 417 /** 418 * Enumerates audio loopback mode. 419 * @enum { number } 420 * @syscap SystemCapability.Multimedia.Audio.Capturer 421 * @since 20 422 */ 423 enum AudioLoopbackMode { 424 /** 425 * The hardware mode of audio loopback. 426 * @syscap SystemCapability.Multimedia.Audio.Capturer 427 * @since 20 428 */ 429 HARDWARE = 0, 430 } 431 432 /** 433 * Enumerates audio loopback status. 434 * @enum { number } 435 * @syscap SystemCapability.Multimedia.Audio.Capturer 436 * @since 20 437 */ 438 enum AudioLoopbackStatus { 439 /** 440 * Audio loopback unavailable by the output or input device. For example, the device change. 441 * @syscap SystemCapability.Multimedia.Audio.Capturer 442 * @since 20 443 */ 444 UNAVAILABLE_DEVICE = -2, 445 /** 446 * Audio loopback unavailable by the audio scene. For example, the audio interrupt. 447 * @syscap SystemCapability.Multimedia.Audio.Capturer 448 * @since 20 449 */ 450 UNAVAILABLE_SCENE = -1, 451 /** 452 * Audio loopback available and idle. 453 * @syscap SystemCapability.Multimedia.Audio.Capturer 454 * @since 20 455 */ 456 AVAILABLE_IDLE = 0, 457 /** 458 * Audio loopback available and running. 459 * @syscap SystemCapability.Multimedia.Audio.Capturer 460 * @since 20 461 */ 462 AVAILABLE_RUNNING = 1, 463 } 464 465 /** 466 * Enumerates audio stream types. 467 * @enum { number } 468 * @syscap SystemCapability.Multimedia.Audio.Volume 469 * @since 7 470 */ 471 /** 472 * Enumerates audio stream types. 473 * @enum { number } 474 * @syscap SystemCapability.Multimedia.Audio.Volume 475 * @crossplatform 476 * @since 12 477 */ 478 enum AudioVolumeType { 479 /** 480 * Audio streams for voice calls. 481 * @syscap SystemCapability.Multimedia.Audio.Volume 482 * @since 8 483 */ 484 /** 485 * Audio volume type for voice calls. 486 * @syscap SystemCapability.Multimedia.Audio.Volume 487 * @crossplatform 488 * @since 12 489 */ 490 VOICE_CALL = 0, 491 /** 492 * Audio streams for ringtones. 493 * @syscap SystemCapability.Multimedia.Audio.Volume 494 * @since 7 495 */ 496 /** 497 * Audio volume type for ringtones. 498 * @syscap SystemCapability.Multimedia.Audio.Volume 499 * @crossplatform 500 * @since 12 501 */ 502 RINGTONE = 2, 503 /** 504 * Audio streams for media purpose. 505 * @syscap SystemCapability.Multimedia.Audio.Volume 506 * @since 7 507 */ 508 /** 509 * Audio volume type for media purpose. 510 * @syscap SystemCapability.Multimedia.Audio.Volume 511 * @crossplatform 512 * @since 12 513 */ 514 MEDIA = 3, 515 /** 516 * Audio volume for alarm purpose. 517 * @syscap SystemCapability.Multimedia.Audio.Volume 518 * @since 10 519 */ 520 /** 521 * Audio volume type for alarm purpose. 522 * @syscap SystemCapability.Multimedia.Audio.Volume 523 * @crossplatform 524 * @since 12 525 */ 526 ALARM = 4, 527 /** 528 * Audio volume for accessibility purpose. 529 * @syscap SystemCapability.Multimedia.Audio.Volume 530 * @since 10 531 */ 532 /** 533 * Audio volume type for accessibility purpose. 534 * @syscap SystemCapability.Multimedia.Audio.Volume 535 * @crossplatform 536 * @since 12 537 */ 538 ACCESSIBILITY = 5, 539 /** 540 * Audio volume for system sound. 541 * @syscap SystemCapability.Multimedia.Audio.Volume 542 * @systemapi 543 * @since 20 544 */ 545 SYSTEM = 6, 546 /** 547 * Audio volume type for voice assistant. 548 * @syscap SystemCapability.Multimedia.Audio.Volume 549 * @since 8 550 */ 551 VOICE_ASSISTANT = 9, 552 /** 553 * Audio volume type for ultrasonic. 554 * @syscap SystemCapability.Multimedia.Audio.Volume 555 * @systemapi 556 * @since 10 557 */ 558 ULTRASONIC = 10, 559 /** 560 * Audio volume type for notification. 561 * @syscap SystemCapability.Multimedia.Audio.Volume 562 * @systemapi 563 * @since 20 564 */ 565 NOTIFICATION = 11, 566 /** 567 * Audio volume type for navigation. 568 * @syscap SystemCapability.Multimedia.Audio.Volume 569 * @systemapi 570 * @since 20 571 */ 572 NAVIGATION = 12, 573 /** 574 * Audio volume type for all common. 575 * @syscap SystemCapability.Multimedia.Audio.Volume 576 * @systemapi 577 * @since 9 578 */ 579 ALL = 100, 580 } 581 582 /** 583 * Enumerates audio device flags. 584 * @enum { number } 585 * @syscap SystemCapability.Multimedia.Audio.Device 586 * @since 7 587 */ 588 /** 589 * Enumerates audio device flags. 590 * @enum { number } 591 * @syscap SystemCapability.Multimedia.Audio.Device 592 * @crossplatform 593 * @since 12 594 */ 595 enum DeviceFlag { 596 /** 597 * None devices. 598 * @syscap SystemCapability.Multimedia.Audio.Device 599 * @systemapi 600 * @since 9 601 */ 602 NONE_DEVICES_FLAG = 0, 603 /** 604 * Output devices. 605 * @syscap SystemCapability.Multimedia.Audio.Device 606 * @since 7 607 */ 608 /** 609 * Output devices. 610 * @syscap SystemCapability.Multimedia.Audio.Device 611 * @crossplatform 612 * @since 12 613 */ 614 OUTPUT_DEVICES_FLAG = 1, 615 /** 616 * Input devices. 617 * @syscap SystemCapability.Multimedia.Audio.Device 618 * @since 7 619 */ 620 /** 621 * Input devices. 622 * @syscap SystemCapability.Multimedia.Audio.Device 623 * @crossplatform 624 * @since 12 625 */ 626 INPUT_DEVICES_FLAG = 2, 627 /** 628 * All devices. 629 * @syscap SystemCapability.Multimedia.Audio.Device 630 * @since 7 631 */ 632 /** 633 * All devices. 634 * @syscap SystemCapability.Multimedia.Audio.Device 635 * @crossplatform 636 * @since 12 637 */ 638 ALL_DEVICES_FLAG = 3, 639 /** 640 * Distributed output devices. 641 * @syscap SystemCapability.Multimedia.Audio.Device 642 * @systemapi 643 * @since 9 644 */ 645 DISTRIBUTED_OUTPUT_DEVICES_FLAG = 4, 646 /** 647 * Distributed input devices. 648 * @syscap SystemCapability.Multimedia.Audio.Device 649 * @systemapi 650 * @since 9 651 */ 652 DISTRIBUTED_INPUT_DEVICES_FLAG = 8, 653 /** 654 * All Distributed devices. 655 * @syscap SystemCapability.Multimedia.Audio.Device 656 * @systemapi 657 * @since 9 658 */ 659 ALL_DISTRIBUTED_DEVICES_FLAG = 12, 660 } 661 662 /** 663 * Enumerates audio device for usage. 664 * @enum { number } 665 * @syscap SystemCapability.Multimedia.Audio.Device 666 * @since 12 667 */ 668 enum DeviceUsage { 669 /** 670 * Media output devices. 671 * @syscap SystemCapability.Multimedia.Audio.Device 672 * @since 12 673 */ 674 MEDIA_OUTPUT_DEVICES = 1, 675 /** 676 * Media input devices. 677 * @syscap SystemCapability.Multimedia.Audio.Device 678 * @since 12 679 */ 680 MEDIA_INPUT_DEVICES = 2, 681 /** 682 * All media devices. 683 * @syscap SystemCapability.Multimedia.Audio.Device 684 * @since 12 685 */ 686 ALL_MEDIA_DEVICES = 3, 687 /** 688 * Call output devices. 689 * @syscap SystemCapability.Multimedia.Audio.Device 690 * @since 12 691 */ 692 CALL_OUTPUT_DEVICES = 4, 693 /** 694 * Call input devices. 695 * @syscap SystemCapability.Multimedia.Audio.Device 696 * @since 12 697 */ 698 CALL_INPUT_DEVICES = 8, 699 /** 700 * All call devices. 701 * @syscap SystemCapability.Multimedia.Audio.Device 702 * @since 12 703 */ 704 ALL_CALL_DEVICES = 12, 705 } 706 707 /** 708 * Enumerates device roles. 709 * @enum { number } 710 * @syscap SystemCapability.Multimedia.Audio.Device 711 * @since 7 712 */ 713 /** 714 * Enumerates device roles. 715 * @enum { number } 716 * @syscap SystemCapability.Multimedia.Audio.Device 717 * @crossplatform 718 * @atomicservice 719 * @since 12 720 */ 721 enum DeviceRole { 722 /** 723 * Input role. 724 * @syscap SystemCapability.Multimedia.Audio.Device 725 * @since 7 726 */ 727 /** 728 * Input role. 729 * @syscap SystemCapability.Multimedia.Audio.Device 730 * @crossplatform 731 * @atomicservice 732 * @since 12 733 */ 734 INPUT_DEVICE = 1, 735 /** 736 * Output role. 737 * @syscap SystemCapability.Multimedia.Audio.Device 738 * @since 7 739 */ 740 /** 741 * Output role. 742 * @syscap SystemCapability.Multimedia.Audio.Device 743 * @crossplatform 744 * @atomicservice 745 * @since 12 746 */ 747 OUTPUT_DEVICE = 2, 748 } 749 750 /** 751 * Enumerates device types. 752 * @enum { number } 753 * @syscap SystemCapability.Multimedia.Audio.Device 754 * @since 7 755 */ 756 /** 757 * Enumerates device types. 758 * @enum { number } 759 * @syscap SystemCapability.Multimedia.Audio.Device 760 * @crossplatform 761 * @atomicservice 762 * @since 12 763 */ 764 enum DeviceType { 765 /** 766 * Invalid device. 767 * @syscap SystemCapability.Multimedia.Audio.Device 768 * @since 7 769 */ 770 /** 771 * Invalid device. 772 * @syscap SystemCapability.Multimedia.Audio.Device 773 * @crossplatform 774 * @atomicservice 775 * @since 12 776 */ 777 INVALID = 0, 778 /** 779 * Built-in earpiece. 780 * @syscap SystemCapability.Multimedia.Audio.Device 781 * @since 7 782 */ 783 /** 784 * Built-in earpiece. 785 * @syscap SystemCapability.Multimedia.Audio.Device 786 * @crossplatform 787 * @atomicservice 788 * @since 12 789 */ 790 EARPIECE = 1, 791 /** 792 * Built-in speaker. 793 * @syscap SystemCapability.Multimedia.Audio.Device 794 * @since 7 795 */ 796 /** 797 * Built-in speaker. 798 * @syscap SystemCapability.Multimedia.Audio.Device 799 * @crossplatform 800 * @atomicservice 801 * @since 12 802 */ 803 SPEAKER = 2, 804 /** 805 * Wired headset, which is a combination of a pair of earpieces and a microphone. 806 * @syscap SystemCapability.Multimedia.Audio.Device 807 * @since 7 808 */ 809 /** 810 * Wired headset, which is a combination of a pair of earpieces and a microphone. 811 * @syscap SystemCapability.Multimedia.Audio.Device 812 * @crossplatform 813 * @atomicservice 814 * @since 12 815 */ 816 WIRED_HEADSET = 3, 817 /** 818 * A pair of wired headphones. 819 * @syscap SystemCapability.Multimedia.Audio.Device 820 * @since 7 821 */ 822 /** 823 * A pair of wired headphones. 824 * @syscap SystemCapability.Multimedia.Audio.Device 825 * @crossplatform 826 * @atomicservice 827 * @since 12 828 */ 829 WIRED_HEADPHONES = 4, 830 /** 831 * Bluetooth device using the synchronous connection oriented link (SCO). 832 * @syscap SystemCapability.Multimedia.Audio.Device 833 * @since 7 834 */ 835 /** 836 * Bluetooth device using the synchronous connection oriented link (SCO). 837 * @syscap SystemCapability.Multimedia.Audio.Device 838 * @crossplatform 839 * @atomicservice 840 * @since 12 841 */ 842 BLUETOOTH_SCO = 7, 843 /** 844 * Bluetooth device using advanced audio distribution profile (A2DP). 845 * @syscap SystemCapability.Multimedia.Audio.Device 846 * @since 7 847 */ 848 /** 849 * Bluetooth device using advanced audio distribution profile (A2DP). 850 * @syscap SystemCapability.Multimedia.Audio.Device 851 * @crossplatform 852 * @atomicservice 853 * @since 12 854 */ 855 BLUETOOTH_A2DP = 8, 856 /** 857 * Built-in microphone. 858 * @syscap SystemCapability.Multimedia.Audio.Device 859 * @since 7 860 */ 861 /** 862 * Built-in microphone. 863 * @syscap SystemCapability.Multimedia.Audio.Device 864 * @crossplatform 865 * @atomicservice 866 * @since 12 867 */ 868 MIC = 15, 869 /** 870 * USB audio headset. 871 * @syscap SystemCapability.Multimedia.Audio.Device 872 * @since 7 873 */ 874 /** 875 * USB audio headset. 876 * @syscap SystemCapability.Multimedia.Audio.Device 877 * @crossplatform 878 * @atomicservice 879 * @since 12 880 */ 881 USB_HEADSET = 22, 882 /** 883 * Display port device. 884 * @syscap SystemCapability.Multimedia.Audio.Device 885 * @atomicservice 886 * @since 12 887 */ 888 DISPLAY_PORT = 23, 889 /** 890 * Device type for rerouting audio to other remote devices by system application 891 * @syscap SystemCapability.Multimedia.Audio.Device 892 * @atomicservice 893 * @since 12 894 */ 895 REMOTE_CAST = 24, 896 /** 897 * USB audio device. 898 * @syscap SystemCapability.Multimedia.Audio.Device 899 * @since 18 900 */ 901 USB_DEVICE = 25, 902 /** 903 * Accessory devices, such as the mic on remote control. 904 * @syscap SystemCapability.Multimedia.Audio.Device 905 * @systemapi 906 * @since 19 907 */ 908 ACCESSORY = 26, 909 910 /** 911 * HDMI device, such as HDMI, ARC, eARC 912 * @syscap SystemCapability.Multimedia.Audio.Device 913 * @since 19 914 */ 915 HDMI = 27, 916 /** 917 * Line connected digital output device, such as s/pdif 918 * @syscap SystemCapability.Multimedia.Audio.Device 919 * @since 19 920 */ 921 LINE_DIGITAL = 28, 922 /** 923 * Distributed virtualization audio device. 924 * @syscap SystemCapability.Multimedia.Audio.Device 925 * @atomicservice 926 * @since 18 927 */ 928 REMOTE_DAUDIO = 29, 929 /** 930 * Hearing aid audio device. 931 * @syscap SystemCapability.Multimedia.Audio.Device 932 * @since 20 933 */ 934 HEARING_AID = 30, 935 /** 936 * Nearlink Device. 937 * @syscap SystemCapability.Multimedia.Audio.Device 938 * @since 20 939 */ 940 NEARLINK = 31, 941 /** 942 * Default device type. 943 * @syscap SystemCapability.Multimedia.Audio.Device 944 * @since 9 945 */ 946 /** 947 * Default device type. 948 * @syscap SystemCapability.Multimedia.Audio.Device 949 * @crossplatform 950 * @atomicservice 951 * @since 12 952 */ 953 DEFAULT = 1000, 954 } 955 956 /** 957 * Enumerates the active device types. 958 * @enum { number } 959 * @syscap SystemCapability.Multimedia.Audio.Device 960 * @since 7 961 * @deprecated since 9 962 * @useinstead ohos.multimedia.audio.CommunicationDeviceType 963 */ 964 enum ActiveDeviceType { 965 /** 966 * Speaker. 967 * @syscap SystemCapability.Multimedia.Audio.Device 968 * @since 7 969 * @deprecated since 9 970 * @useinstead ohos.multimedia.audio.CommunicationDeviceType.SPEAKER 971 */ 972 SPEAKER = 2, 973 /** 974 * Bluetooth device using the SCO link. 975 * @syscap SystemCapability.Multimedia.Audio.Device 976 * @since 7 977 * @deprecated since 9 978 */ 979 BLUETOOTH_SCO = 7, 980 } 981 982 /** 983 * Enumerates the available device types for communication. 984 * @enum { number } 985 * @syscap SystemCapability.Multimedia.Audio.Communication 986 * @since 9 987 */ 988 /** 989 * Enumerates the available device types for communication. 990 * @enum { number } 991 * @syscap SystemCapability.Multimedia.Audio.Communication 992 * @crossplatform 993 * @since 12 994 */ 995 enum CommunicationDeviceType { 996 /** 997 * Speaker. 998 * @syscap SystemCapability.Multimedia.Audio.Communication 999 * @since 9 1000 */ 1001 /** 1002 * Speaker. 1003 * @syscap SystemCapability.Multimedia.Audio.Communication 1004 * @crossplatform 1005 * @since 12 1006 */ 1007 SPEAKER = 2 1008 } 1009 1010 /** 1011 * Enumerates ringer modes. 1012 * @enum { number } 1013 * @syscap SystemCapability.Multimedia.Audio.Communication 1014 * @since 7 1015 */ 1016 /** 1017 * Enumerates ringer modes. 1018 * @enum { number } 1019 * @syscap SystemCapability.Multimedia.Audio.Communication 1020 * @crossplatform 1021 * @since 12 1022 */ 1023 enum AudioRingMode { 1024 /** 1025 * Silent mode. 1026 * @syscap SystemCapability.Multimedia.Audio.Communication 1027 * @since 7 1028 */ 1029 /** 1030 * Silent mode. 1031 * @syscap SystemCapability.Multimedia.Audio.Communication 1032 * @crossplatform 1033 * @since 12 1034 */ 1035 RINGER_MODE_SILENT = 0, 1036 /** 1037 * Vibration mode. 1038 * @syscap SystemCapability.Multimedia.Audio.Communication 1039 * @since 7 1040 */ 1041 /** 1042 * Vibration mode. 1043 * @syscap SystemCapability.Multimedia.Audio.Communication 1044 * @crossplatform 1045 * @since 12 1046 */ 1047 RINGER_MODE_VIBRATE = 1, 1048 /** 1049 * Normal mode. 1050 * @syscap SystemCapability.Multimedia.Audio.Communication 1051 * @since 7 1052 */ 1053 /** 1054 * Normal mode. 1055 * @syscap SystemCapability.Multimedia.Audio.Communication 1056 * @crossplatform 1057 * @since 12 1058 */ 1059 RINGER_MODE_NORMAL = 2, 1060 } 1061 1062 /** 1063 * Enumerates type. 1064 * @enum { number } 1065 * @syscap SystemCapability.Multimedia.Audio.Volume 1066 * @systemapi 1067 * @since 12 1068 */ 1069 enum PolicyType { 1070 /** 1071 * EDM type. 1072 * @syscap SystemCapability.Multimedia.Audio.Volume 1073 * @systemapi 1074 * @since 12 1075 */ 1076 EDM = 0, 1077 /** 1078 * PRIVACY type. 1079 * @syscap SystemCapability.Multimedia.Audio.Volume 1080 * @systemapi 1081 * @since 12 1082 */ 1083 PRIVACY = 1, 1084 } 1085 1086 /** 1087 * Enumerates the audio sample formats. 1088 * @enum { number } 1089 * @syscap SystemCapability.Multimedia.Audio.Core 1090 * @since 8 1091 */ 1092 /** 1093 * Enumerates the audio sample formats. 1094 * @enum { number } 1095 * @syscap SystemCapability.Multimedia.Audio.Core 1096 * @crossplatform 1097 * @since 12 1098 */ 1099 enum AudioSampleFormat { 1100 /** 1101 * Invalid format. 1102 * @syscap SystemCapability.Multimedia.Audio.Core 1103 * @since 8 1104 */ 1105 /** 1106 * Invalid format. 1107 * @syscap SystemCapability.Multimedia.Audio.Core 1108 * @crossplatform 1109 * @since 12 1110 */ 1111 SAMPLE_FORMAT_INVALID = -1, 1112 /** 1113 * Unsigned 8 format. 1114 * @syscap SystemCapability.Multimedia.Audio.Core 1115 * @since 8 1116 */ 1117 /** 1118 * Unsigned 8 format. 1119 * @syscap SystemCapability.Multimedia.Audio.Core 1120 * @crossplatform 1121 * @since 12 1122 */ 1123 SAMPLE_FORMAT_U8 = 0, 1124 /** 1125 * Signed 16 bit integer, little endian. 1126 * @syscap SystemCapability.Multimedia.Audio.Core 1127 * @since 8 1128 */ 1129 /** 1130 * Signed 16 bit integer, little endian. 1131 * @syscap SystemCapability.Multimedia.Audio.Core 1132 * @crossplatform 1133 * @since 12 1134 */ 1135 SAMPLE_FORMAT_S16LE = 1, 1136 /** 1137 * Signed 24 bit integer, little endian. 1138 * @syscap SystemCapability.Multimedia.Audio.Core 1139 * @since 8 1140 */ 1141 /** 1142 * Signed 24 bit integer, little endian. 1143 * @syscap SystemCapability.Multimedia.Audio.Core 1144 * @crossplatform 1145 * @since 12 1146 */ 1147 SAMPLE_FORMAT_S24LE = 2, 1148 /** 1149 * Signed 32 bit integer, little endian. 1150 * @syscap SystemCapability.Multimedia.Audio.Core 1151 * @since 8 1152 */ 1153 /** 1154 * Signed 32 bit integer, little endian. 1155 * @syscap SystemCapability.Multimedia.Audio.Core 1156 * @crossplatform 1157 * @since 12 1158 */ 1159 SAMPLE_FORMAT_S32LE = 3, 1160 /** 1161 * Signed 32 bit float, little endian. 1162 * @syscap SystemCapability.Multimedia.Audio.Core 1163 * @since 9 1164 */ 1165 /** 1166 * Signed 32 bit float, little endian. 1167 * @syscap SystemCapability.Multimedia.Audio.Core 1168 * @crossplatform 1169 * @since 12 1170 */ 1171 SAMPLE_FORMAT_F32LE = 4, 1172 } 1173 1174 /** 1175 * Enumerates the audio channel. 1176 * @enum { number } 1177 * @syscap SystemCapability.Multimedia.Audio.Core 1178 * @since 8 1179 */ 1180 /** 1181 * Enumerates the audio channel. 1182 * @enum { number } 1183 * @syscap SystemCapability.Multimedia.Audio.Core 1184 * @crossplatform 1185 * @since 12 1186 */ 1187 enum AudioChannel { 1188 /** 1189 * Channel 1. 1190 * @syscap SystemCapability.Multimedia.Audio.Core 1191 * @since 8 1192 */ 1193 /** 1194 * Channel 1. 1195 * @syscap SystemCapability.Multimedia.Audio.Core 1196 * @crossplatform 1197 * @since 12 1198 */ 1199 CHANNEL_1 = 1, 1200 /** 1201 * Channel 2. 1202 * @syscap SystemCapability.Multimedia.Audio.Core 1203 * @since 8 1204 */ 1205 /** 1206 * Channel 2. 1207 * @syscap SystemCapability.Multimedia.Audio.Core 1208 * @crossplatform 1209 * @since 12 1210 */ 1211 CHANNEL_2 = 2, 1212 /** 1213 * Channel 3. 1214 * @syscap SystemCapability.Multimedia.Audio.Core 1215 * @since 11 1216 */ 1217 /** 1218 * Channel 3. 1219 * @syscap SystemCapability.Multimedia.Audio.Core 1220 * @crossplatform 1221 * @since 12 1222 */ 1223 CHANNEL_3 = 3, 1224 /** 1225 * Channel 4. 1226 * @syscap SystemCapability.Multimedia.Audio.Core 1227 * @since 11 1228 */ 1229 /** 1230 * Channel 4. 1231 * @syscap SystemCapability.Multimedia.Audio.Core 1232 * @crossplatform 1233 * @since 12 1234 */ 1235 CHANNEL_4 = 4, 1236 /** 1237 * Channel 5. 1238 * @syscap SystemCapability.Multimedia.Audio.Core 1239 * @since 11 1240 */ 1241 /** 1242 * Channel 5. 1243 * @syscap SystemCapability.Multimedia.Audio.Core 1244 * @crossplatform 1245 * @since 12 1246 */ 1247 CHANNEL_5 = 5, 1248 /** 1249 * Channel 6. 1250 * @syscap SystemCapability.Multimedia.Audio.Core 1251 * @since 11 1252 */ 1253 /** 1254 * Channel 6. 1255 * @syscap SystemCapability.Multimedia.Audio.Core 1256 * @crossplatform 1257 * @since 12 1258 */ 1259 CHANNEL_6 = 6, 1260 /** 1261 * Channel 7. 1262 * @syscap SystemCapability.Multimedia.Audio.Core 1263 * @since 11 1264 */ 1265 /** 1266 * Channel 7. 1267 * @syscap SystemCapability.Multimedia.Audio.Core 1268 * @crossplatform 1269 * @since 12 1270 */ 1271 CHANNEL_7 = 7, 1272 /** 1273 * Channel 8. 1274 * @syscap SystemCapability.Multimedia.Audio.Core 1275 * @since 11 1276 */ 1277 /** 1278 * Channel 8. 1279 * @syscap SystemCapability.Multimedia.Audio.Core 1280 * @crossplatform 1281 * @since 12 1282 */ 1283 CHANNEL_8 = 8, 1284 /** 1285 * Channel 9. 1286 * @syscap SystemCapability.Multimedia.Audio.Core 1287 * @since 11 1288 */ 1289 /** 1290 * Channel 9. 1291 * @syscap SystemCapability.Multimedia.Audio.Core 1292 * @crossplatform 1293 * @since 12 1294 */ 1295 CHANNEL_9 = 9, 1296 /** 1297 * Channel 10. 1298 * @syscap SystemCapability.Multimedia.Audio.Core 1299 * @since 11 1300 */ 1301 /** 1302 * Channel 10. 1303 * @syscap SystemCapability.Multimedia.Audio.Core 1304 * @crossplatform 1305 * @since 12 1306 */ 1307 CHANNEL_10 = 10, 1308 /** 1309 * Channel 12. 1310 * @syscap SystemCapability.Multimedia.Audio.Core 1311 * @since 11 1312 */ 1313 /** 1314 * Channel 12. 1315 * @syscap SystemCapability.Multimedia.Audio.Core 1316 * @crossplatform 1317 * @since 12 1318 */ 1319 CHANNEL_12 = 12, 1320 /** 1321 * Channel 14. 1322 * @syscap SystemCapability.Multimedia.Audio.Core 1323 * @since 11 1324 */ 1325 /** 1326 * Channel 14. 1327 * @syscap SystemCapability.Multimedia.Audio.Core 1328 * @crossplatform 1329 * @since 12 1330 */ 1331 CHANNEL_14 = 14, 1332 /** 1333 * Channel 16. 1334 * @syscap SystemCapability.Multimedia.Audio.Core 1335 * @since 11 1336 */ 1337 /** 1338 * Channel 16. 1339 * @syscap SystemCapability.Multimedia.Audio.Core 1340 * @crossplatform 1341 * @since 12 1342 */ 1343 CHANNEL_16 = 16 1344 } 1345 1346 /** 1347 * Enumerates the audio sampling rate. 1348 * @enum { number } 1349 * @syscap SystemCapability.Multimedia.Audio.Core 1350 * @since 8 1351 */ 1352 /** 1353 * Enumerates the audio sampling rate. 1354 * @enum { number } 1355 * @syscap SystemCapability.Multimedia.Audio.Core 1356 * @crossplatform 1357 * @since 12 1358 */ 1359 enum AudioSamplingRate { 1360 /** 1361 * 8kHz sample rate. 1362 * @syscap SystemCapability.Multimedia.Audio.Core 1363 * @since 8 1364 */ 1365 /** 1366 * 8kHz sample rate. 1367 * @syscap SystemCapability.Multimedia.Audio.Core 1368 * @crossplatform 1369 * @since 12 1370 */ 1371 SAMPLE_RATE_8000 = 8000, 1372 /** 1373 * 11.025kHz sample rate. 1374 * @syscap SystemCapability.Multimedia.Audio.Core 1375 * @since 8 1376 */ 1377 /** 1378 * 11.025kHz sample rate. 1379 * @syscap SystemCapability.Multimedia.Audio.Core 1380 * @crossplatform 1381 * @since 12 1382 */ 1383 SAMPLE_RATE_11025 = 11025, 1384 /** 1385 * 12kHz sample rate. 1386 * @syscap SystemCapability.Multimedia.Audio.Core 1387 * @since 8 1388 */ 1389 /** 1390 * 12kHz sample rate. 1391 * @syscap SystemCapability.Multimedia.Audio.Core 1392 * @crossplatform 1393 * @since 12 1394 */ 1395 SAMPLE_RATE_12000 = 12000, 1396 /** 1397 * 16kHz sample rate. 1398 * @syscap SystemCapability.Multimedia.Audio.Core 1399 * @since 8 1400 */ 1401 /** 1402 * 16kHz sample rate. 1403 * @syscap SystemCapability.Multimedia.Audio.Core 1404 * @crossplatform 1405 * @since 12 1406 */ 1407 SAMPLE_RATE_16000 = 16000, 1408 /** 1409 * 22.05kHz sample rate. 1410 * @syscap SystemCapability.Multimedia.Audio.Core 1411 * @since 8 1412 */ 1413 /** 1414 * 22.05kHz sample rate. 1415 * @syscap SystemCapability.Multimedia.Audio.Core 1416 * @crossplatform 1417 * @since 12 1418 */ 1419 SAMPLE_RATE_22050 = 22050, 1420 /** 1421 * 24kHz sample rate. 1422 * @syscap SystemCapability.Multimedia.Audio.Core 1423 * @since 8 1424 */ 1425 /** 1426 * 24kHz sample rate. 1427 * @syscap SystemCapability.Multimedia.Audio.Core 1428 * @crossplatform 1429 * @since 12 1430 */ 1431 SAMPLE_RATE_24000 = 24000, 1432 /** 1433 * 32kHz sample rate. 1434 * @syscap SystemCapability.Multimedia.Audio.Core 1435 * @since 8 1436 */ 1437 /** 1438 * 32kHz sample rate. 1439 * @syscap SystemCapability.Multimedia.Audio.Core 1440 * @crossplatform 1441 * @since 12 1442 */ 1443 SAMPLE_RATE_32000 = 32000, 1444 /** 1445 * 44.1kHz sample rate. 1446 * @syscap SystemCapability.Multimedia.Audio.Core 1447 * @since 8 1448 */ 1449 /** 1450 * 44.1kHz sample rate. 1451 * @syscap SystemCapability.Multimedia.Audio.Core 1452 * @crossplatform 1453 * @since 12 1454 */ 1455 SAMPLE_RATE_44100 = 44100, 1456 /** 1457 * 48kHz sample rate. 1458 * @syscap SystemCapability.Multimedia.Audio.Core 1459 * @since 8 1460 */ 1461 /** 1462 * 48kHz sample rate. 1463 * @syscap SystemCapability.Multimedia.Audio.Core 1464 * @crossplatform 1465 * @since 12 1466 */ 1467 SAMPLE_RATE_48000 = 48000, 1468 /** 1469 * 64kHz sample rate. 1470 * @syscap SystemCapability.Multimedia.Audio.Core 1471 * @since 8 1472 */ 1473 /** 1474 * 64kHz sample rate. 1475 * @syscap SystemCapability.Multimedia.Audio.Core 1476 * @crossplatform 1477 * @since 12 1478 */ 1479 SAMPLE_RATE_64000 = 64000, 1480 /** 1481 * 88.2kHz sample rate. 1482 * @syscap SystemCapability.Multimedia.Audio.Core 1483 * @since 12 1484 */ 1485 SAMPLE_RATE_88200 = 88200, 1486 /** 1487 * 96kHz sample rate. 1488 * @syscap SystemCapability.Multimedia.Audio.Core 1489 * @since 8 1490 */ 1491 /** 1492 * 96kHz sample rate. 1493 * @syscap SystemCapability.Multimedia.Audio.Core 1494 * @crossplatform 1495 * @since 12 1496 */ 1497 SAMPLE_RATE_96000 = 96000, 1498 /** 1499 * 176.4kHz sample rate. 1500 * @syscap SystemCapability.Multimedia.Audio.Core 1501 * @since 12 1502 */ 1503 SAMPLE_RATE_176400 = 176400, 1504 /** 1505 * 192kHz sample rate. 1506 * @syscap SystemCapability.Multimedia.Audio.Core 1507 * @since 12 1508 */ 1509 SAMPLE_RATE_192000 = 192000 1510 } 1511 1512 /** 1513 * Enumerates the audio encoding type. 1514 * @enum { number } 1515 * @syscap SystemCapability.Multimedia.Audio.Core 1516 * @since 8 1517 */ 1518 /** 1519 * Enumerates the audio encoding type. 1520 * @enum { number } 1521 * @syscap SystemCapability.Multimedia.Audio.Core 1522 * @crossplatform 1523 * @atomicservice 1524 * @since 12 1525 */ 1526 enum AudioEncodingType { 1527 /** 1528 * Invalid type. 1529 * @syscap SystemCapability.Multimedia.Audio.Core 1530 * @since 8 1531 */ 1532 /** 1533 * Invalid type. 1534 * @syscap SystemCapability.Multimedia.Audio.Core 1535 * @crossplatform 1536 * @atomicservice 1537 * @since 12 1538 */ 1539 ENCODING_TYPE_INVALID = -1, 1540 /** 1541 * PCM encoding. 1542 * @syscap SystemCapability.Multimedia.Audio.Core 1543 * @since 8 1544 */ 1545 /** 1546 * PCM encoding. 1547 * @syscap SystemCapability.Multimedia.Audio.Core 1548 * @crossplatform 1549 * @atomicservice 1550 * @since 12 1551 */ 1552 ENCODING_TYPE_RAW = 0 1553 } 1554 1555 /** 1556 * Enumerates the audio content type. 1557 * @enum { number } 1558 * @syscap SystemCapability.Multimedia.Audio.Core 1559 * @since 7 1560 * @deprecated since 10 1561 * @useinstead ohos.multimedia.audio.StreamUsage 1562 */ 1563 enum ContentType { 1564 /** 1565 * Unknown content. 1566 * @syscap SystemCapability.Multimedia.Audio.Core 1567 * @since 7 1568 * @deprecated since 10 1569 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_UNKNOWN 1570 */ 1571 CONTENT_TYPE_UNKNOWN = 0, 1572 /** 1573 * Speech content. 1574 * @syscap SystemCapability.Multimedia.Audio.Core 1575 * @since 7 1576 * @deprecated since 10 1577 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION 1578 */ 1579 CONTENT_TYPE_SPEECH = 1, 1580 /** 1581 * Music content. 1582 * @syscap SystemCapability.Multimedia.Audio.Core 1583 * @since 7 1584 * @deprecated since 10 1585 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MUSIC 1586 */ 1587 CONTENT_TYPE_MUSIC = 2, 1588 /** 1589 * Movie content. 1590 * @syscap SystemCapability.Multimedia.Audio.Core 1591 * @since 7 1592 * @deprecated since 10 1593 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MOVIE 1594 */ 1595 CONTENT_TYPE_MOVIE = 3, 1596 /** 1597 * Notification content. 1598 * @syscap SystemCapability.Multimedia.Audio.Core 1599 * @since 7 1600 * @deprecated since 10 1601 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_NOTIFICATION 1602 */ 1603 CONTENT_TYPE_SONIFICATION = 4, 1604 /** 1605 * Ringtone content. 1606 * @syscap SystemCapability.Multimedia.Audio.Core 1607 * @since 8 1608 * @deprecated since 10 1609 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_RINGTONE 1610 */ 1611 CONTENT_TYPE_RINGTONE = 5, 1612 } 1613 1614 /** 1615 * Enumerates the stream usage. 1616 * @enum { number } 1617 * @syscap SystemCapability.Multimedia.Audio.Core 1618 * @since 7 1619 */ 1620 /** 1621 * Enumerates the stream usage. 1622 * @enum { number } 1623 * @syscap SystemCapability.Multimedia.Audio.Core 1624 * @crossplatform 1625 * @atomicservice 1626 * @since 12 1627 */ 1628 enum StreamUsage { 1629 /** 1630 * Unknown usage. 1631 * @syscap SystemCapability.Multimedia.Audio.Core 1632 * @since 7 1633 */ 1634 /** 1635 * Unknown usage. 1636 * @syscap SystemCapability.Multimedia.Audio.Core 1637 * @crossplatform 1638 * @atomicservice 1639 * @since 12 1640 */ 1641 STREAM_USAGE_UNKNOWN = 0, 1642 /** 1643 * Media usage. 1644 * @syscap SystemCapability.Multimedia.Audio.Core 1645 * @since 7 1646 * @deprecated since 10 1647 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MUSIC or 1648 * ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MOVIE or 1649 * ohos.multimedia.audio.StreamUsage.STREAM_USAGE_GAME or 1650 * ohos.multimedia.audio.StreamUsage.STREAM_USAGE_AUDIOBOOK 1651 */ 1652 STREAM_USAGE_MEDIA = 1, 1653 /** 1654 * Music usage. 1655 * @syscap SystemCapability.Multimedia.Audio.Core 1656 * @since 10 1657 */ 1658 /** 1659 * Music usage. 1660 * @syscap SystemCapability.Multimedia.Audio.Core 1661 * @crossplatform 1662 * @atomicservice 1663 * @since 12 1664 */ 1665 STREAM_USAGE_MUSIC = 1, 1666 /** 1667 * Voice communication usage. 1668 * @syscap SystemCapability.Multimedia.Audio.Core 1669 * @since 7 1670 */ 1671 /** 1672 * Voice communication usage. 1673 * @syscap SystemCapability.Multimedia.Audio.Core 1674 * @crossplatform 1675 * @atomicservice 1676 * @since 12 1677 */ 1678 STREAM_USAGE_VOICE_COMMUNICATION = 2, 1679 /** 1680 * Voice assistant broadcast usage. 1681 * @syscap SystemCapability.Multimedia.Audio.Core 1682 * @since 9 1683 */ 1684 /** 1685 * Voice assistant broadcast usage. 1686 * @syscap SystemCapability.Multimedia.Audio.Core 1687 * @crossplatform 1688 * @atomicservice 1689 * @since 12 1690 */ 1691 STREAM_USAGE_VOICE_ASSISTANT = 3, 1692 /** 1693 * Alarm usage. 1694 * @syscap SystemCapability.Multimedia.Audio.Core 1695 * @since 10 1696 */ 1697 /** 1698 * Alarm usage. 1699 * @syscap SystemCapability.Multimedia.Audio.Core 1700 * @crossplatform 1701 * @atomicservice 1702 * @since 12 1703 */ 1704 STREAM_USAGE_ALARM = 4, 1705 /** 1706 * Voice message usage. 1707 * @syscap SystemCapability.Multimedia.Audio.Core 1708 * @since 10 1709 */ 1710 /** 1711 * Voice message usage. 1712 * @syscap SystemCapability.Multimedia.Audio.Core 1713 * @atomicservice 1714 * @since 12 1715 */ 1716 STREAM_USAGE_VOICE_MESSAGE = 5, 1717 /** 1718 * Notification or ringtone usage. 1719 * @syscap SystemCapability.Multimedia.Audio.Core 1720 * @since 7 1721 * @deprecated since 10 1722 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_RINGTONE 1723 */ 1724 STREAM_USAGE_NOTIFICATION_RINGTONE = 6, 1725 /** 1726 * Ringtone usage. 1727 * @syscap SystemCapability.Multimedia.Audio.Core 1728 * @since 10 1729 */ 1730 /** 1731 * Ringtone usage. 1732 * @syscap SystemCapability.Multimedia.Audio.Core 1733 * @crossplatform 1734 * @atomicservice 1735 * @since 12 1736 */ 1737 STREAM_USAGE_RINGTONE = 6, 1738 /** 1739 * Notification usage. 1740 * @syscap SystemCapability.Multimedia.Audio.Core 1741 * @since 10 1742 */ 1743 /** 1744 * Notification usage. 1745 * @syscap SystemCapability.Multimedia.Audio.Core 1746 * @crossplatform 1747 * @atomicservice 1748 * @since 12 1749 */ 1750 STREAM_USAGE_NOTIFICATION = 7, 1751 /** 1752 * Accessibility usage, such as screen reader. 1753 * @syscap SystemCapability.Multimedia.Audio.Core 1754 * @since 10 1755 */ 1756 /** 1757 * Accessibility usage, such as screen reader. 1758 * @syscap SystemCapability.Multimedia.Audio.Core 1759 * @crossplatform 1760 * @atomicservice 1761 * @since 12 1762 */ 1763 STREAM_USAGE_ACCESSIBILITY = 8, 1764 /** 1765 * System usage, such as screen lock or key click. 1766 * @syscap SystemCapability.Multimedia.Audio.Core 1767 * @systemapi 1768 * @since 10 1769 */ 1770 STREAM_USAGE_SYSTEM = 9, 1771 /** 1772 * Movie or video usage. 1773 * @syscap SystemCapability.Multimedia.Audio.Core 1774 * @since 10 1775 */ 1776 /** 1777 * Movie or video usage. 1778 * @syscap SystemCapability.Multimedia.Audio.Core 1779 * @crossplatform 1780 * @atomicservice 1781 * @since 12 1782 */ 1783 STREAM_USAGE_MOVIE = 10, 1784 /** 1785 * Game sound effect usage. 1786 * @syscap SystemCapability.Multimedia.Audio.Core 1787 * @since 10 1788 */ 1789 /** 1790 * Game sound effect usage. 1791 * @syscap SystemCapability.Multimedia.Audio.Core 1792 * @crossplatform 1793 * @atomicservice 1794 * @since 12 1795 */ 1796 STREAM_USAGE_GAME = 11, 1797 /** 1798 * Audiobook usage. 1799 * @syscap SystemCapability.Multimedia.Audio.Core 1800 * @since 10 1801 */ 1802 /** 1803 * Audiobook usage. 1804 * @syscap SystemCapability.Multimedia.Audio.Core 1805 * @crossplatform 1806 * @atomicservice 1807 * @since 12 1808 */ 1809 STREAM_USAGE_AUDIOBOOK = 12, 1810 /** 1811 * Navigation usage. 1812 * @syscap SystemCapability.Multimedia.Audio.Core 1813 * @since 10 1814 */ 1815 /** 1816 * Navigation usage. 1817 * @syscap SystemCapability.Multimedia.Audio.Core 1818 * @crossplatform 1819 * @atomicservice 1820 * @since 12 1821 */ 1822 STREAM_USAGE_NAVIGATION = 13, 1823 /** 1824 * DTMF dial tone usage. 1825 * @syscap SystemCapability.Multimedia.Audio.Core 1826 * @systemapi 1827 * @since 10 1828 */ 1829 STREAM_USAGE_DTMF = 14, 1830 /** 1831 * Enforced tone usage, such as camera shutter. 1832 * @syscap SystemCapability.Multimedia.Audio.Core 1833 * @systemapi 1834 * @since 10 1835 */ 1836 STREAM_USAGE_ENFORCED_TONE = 15, 1837 /** 1838 * Ultrasonic playing usage. This type is only used for msdp condition. 1839 * @syscap SystemCapability.Multimedia.Audio.Core 1840 * @systemapi 1841 * @since 10 1842 */ 1843 STREAM_USAGE_ULTRASONIC = 16, 1844 /** 1845 * Video communication or video conference usage. 1846 * @syscap SystemCapability.Multimedia.Audio.Core 1847 * @atomicservice 1848 * @since 12 1849 */ 1850 STREAM_USAGE_VIDEO_COMMUNICATION = 17, 1851 /** 1852 * Voice call assistant type. This type is only used for call assistant functionalities. 1853 * @syscap SystemCapability.Multimedia.Audio.Core 1854 * @systemapi 1855 * @since 12 1856 */ 1857 STREAM_USAGE_VOICE_CALL_ASSISTANT = 21, 1858 } 1859 1860 /** 1861 * Enumerates the audio interrupt request type. 1862 * @enum { number } 1863 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1864 * @systemapi 1865 * @since 9 1866 */ 1867 enum InterruptRequestType { 1868 /** 1869 * Default type to request audio interrupt. 1870 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1871 * @systemapi 1872 * @since 9 1873 */ 1874 INTERRUPT_REQUEST_TYPE_DEFAULT = 0, 1875 } 1876 1877 /** 1878 * Enumerates volume related operations. 1879 * Flags should be powers of 2! 1880 * @enum { number } 1881 * @syscap SystemCapability.Multimedia.Audio.Volume 1882 * @systemapi 1883 * @since 12 1884 */ 1885 enum VolumeFlag { 1886 /** 1887 * Show system volume bar. 1888 * @syscap SystemCapability.Multimedia.Audio.Volume 1889 * @systemapi 1890 * @since 12 1891 */ 1892 FLAG_SHOW_SYSTEM_UI = 1, 1893 } 1894 1895 /** 1896 * Describes audio stream information. 1897 * @typedef AudioStreamInfo 1898 * @syscap SystemCapability.Multimedia.Audio.Core 1899 * @since 8 1900 */ 1901 /** 1902 * Describes audio stream information. 1903 * @typedef AudioStreamInfo 1904 * @syscap SystemCapability.Multimedia.Audio.Core 1905 * @crossplatform 1906 * @since 12 1907 */ 1908 interface AudioStreamInfo { 1909 /** 1910 * Sampling rate. 1911 * @type { AudioSamplingRate } 1912 * @syscap SystemCapability.Multimedia.Audio.Core 1913 * @since 8 1914 */ 1915 /** 1916 * Sampling rate. 1917 * @type { AudioSamplingRate } 1918 * @syscap SystemCapability.Multimedia.Audio.Core 1919 * @crossplatform 1920 * @since 12 1921 */ 1922 samplingRate: AudioSamplingRate; 1923 /** 1924 * Audio channels. 1925 * @type { AudioChannel } 1926 * @syscap SystemCapability.Multimedia.Audio.Core 1927 * @since 8 1928 */ 1929 /** 1930 * Audio channels. 1931 * @type { AudioChannel } 1932 * @syscap SystemCapability.Multimedia.Audio.Core 1933 * @crossplatform 1934 * @since 12 1935 */ 1936 channels: AudioChannel; 1937 /** 1938 * Audio sample format. 1939 * @type { AudioSampleFormat } 1940 * @syscap SystemCapability.Multimedia.Audio.Core 1941 * @since 8 1942 */ 1943 /** 1944 * Audio sample format. 1945 * @type { AudioSampleFormat } 1946 * @syscap SystemCapability.Multimedia.Audio.Core 1947 * @crossplatform 1948 * @since 12 1949 */ 1950 sampleFormat: AudioSampleFormat; 1951 /** 1952 * Audio encoding type. 1953 * @type { AudioEncodingType } 1954 * @syscap SystemCapability.Multimedia.Audio.Core 1955 * @since 8 1956 */ 1957 /** 1958 * Audio encoding type. 1959 * @type { AudioEncodingType } 1960 * @syscap SystemCapability.Multimedia.Audio.Core 1961 * @crossplatform 1962 * @since 12 1963 */ 1964 encodingType: AudioEncodingType; 1965 /** 1966 * Audio channel layout. 1967 * @type { ?AudioChannelLayout } 1968 * @syscap SystemCapability.Multimedia.Audio.Core 1969 * @since 11 1970 */ 1971 /** 1972 * Audio channel layout. 1973 * @type { ?AudioChannelLayout } 1974 * @syscap SystemCapability.Multimedia.Audio.Core 1975 * @crossplatform 1976 * @since 12 1977 */ 1978 channelLayout?: AudioChannelLayout; 1979 } 1980 1981 /** 1982 * Describes audio renderer information. 1983 * @typedef AudioRendererInfo 1984 * @syscap SystemCapability.Multimedia.Audio.Core 1985 * @since 8 1986 */ 1987 /** 1988 * Describes audio renderer information. 1989 * @typedef AudioRendererInfo 1990 * @syscap SystemCapability.Multimedia.Audio.Core 1991 * @crossplatform 1992 * @atomicservice 1993 * @since 12 1994 */ 1995 interface AudioRendererInfo { 1996 /** 1997 * Content type. 1998 * @type { ContentType } 1999 * @syscap SystemCapability.Multimedia.Audio.Core 2000 * @since 8 2001 * @deprecated since 10 2002 * @useinstead ohos.multimedia.audio.AudioRendererInfo#usage 2003 */ 2004 /** 2005 * Content type. 2006 * @type { ?ContentType } 2007 * @syscap SystemCapability.Multimedia.Audio.Core 2008 * @since 10 2009 */ 2010 content?: ContentType; 2011 /** 2012 * Stream usage. 2013 * @type { StreamUsage } 2014 * @syscap SystemCapability.Multimedia.Audio.Core 2015 * @since 8 2016 */ 2017 /** 2018 * Stream usage. 2019 * @type { StreamUsage } 2020 * @syscap SystemCapability.Multimedia.Audio.Core 2021 * @crossplatform 2022 * @atomicservice 2023 * @since 12 2024 */ 2025 usage: StreamUsage; 2026 /** 2027 * Audio renderer flags. 2028 * @type { number } 2029 * @syscap SystemCapability.Multimedia.Audio.Core 2030 * @since 8 2031 */ 2032 /** 2033 * Audio renderer flags. This method is currently reserved, suggest setting the default value to 0. 2034 * @type { number } 2035 * @syscap SystemCapability.Multimedia.Audio.Core 2036 * @crossplatform 2037 * @atomicservice 2038 * @since 12 2039 */ 2040 rendererFlags: number; 2041 /** 2042 * Audio volume mode config. If volumeMode is set to {@link AudioVolumeMode.APP_INDIVIDUAL}, this audio renderer 2043 * will be affeted by app volume percentage setted by {@link setAppVolumePercentage} 2044 * @type { ?AudioVolumeMode } 2045 * @syscap SystemCapability.Multimedia.Audio.Volume 2046 * @since 19 2047 */ 2048 volumeMode?: AudioVolumeMode; 2049 } 2050 2051 /** 2052 * Describes audio renderer filter. 2053 * @typedef AudioRendererFilter 2054 * @syscap SystemCapability.Multimedia.Audio.Core 2055 * @systemapi 2056 * @since 9 2057 */ 2058 interface AudioRendererFilter { 2059 /** 2060 * Application uid. 2061 * @type { ?number } 2062 * @syscap SystemCapability.Multimedia.Audio.Core 2063 * @systemapi 2064 * @since 9 2065 */ 2066 uid?: number; 2067 /** 2068 * Renderer information. 2069 * @type { ?AudioRendererInfo } 2070 * @syscap SystemCapability.Multimedia.Audio.Renderer 2071 * @systemapi 2072 * @since 9 2073 */ 2074 rendererInfo?: AudioRendererInfo; 2075 /** 2076 * AudioRenderer id. 2077 * @type { ?number } 2078 * @syscap SystemCapability.Multimedia.Audio.Renderer 2079 * @systemapi 2080 * @since 9 2081 */ 2082 rendererId?: number; 2083 } 2084 2085 /** 2086 * Describe audio capturer filter. 2087 * @typedef AudioCapturerFilter 2088 * @syscap SystemCapability.Multimedia.Audio.Core 2089 * @systemapi 2090 * @since 18 2091 */ 2092 interface AudioCapturerFilter { 2093 /** 2094 * Application uid. 2095 * @type { ?number } 2096 * @syscap SystemCapability.Multimedia.Audio.Core 2097 * @systemapi 2098 * @since 18 2099 */ 2100 uid?: number; 2101 /** 2102 * Capturer information. 2103 * @type { ?AudioCapturerInfo } 2104 * @syscap SystemCapability.Multimedia.Audio.Capturer 2105 * @systemapi 2106 * @since 18 2107 */ 2108 capturerInfo?: AudioCapturerInfo; 2109 } 2110 2111 /** 2112 * Describes audio renderer configuration options. 2113 * @typedef AudioRendererOptions 2114 * @syscap SystemCapability.Multimedia.Audio.Renderer 2115 * @since 8 2116 */ 2117 /** 2118 * Describes audio renderer configuration options. 2119 * @typedef AudioRendererOptions 2120 * @syscap SystemCapability.Multimedia.Audio.Renderer 2121 * @crossplatform 2122 * @since 12 2123 */ 2124 interface AudioRendererOptions { 2125 /** 2126 * Stream information. 2127 * @type { AudioStreamInfo } 2128 * @syscap SystemCapability.Multimedia.Audio.Renderer 2129 * @since 8 2130 */ 2131 /** 2132 * Stream information. 2133 * @type { AudioStreamInfo } 2134 * @syscap SystemCapability.Multimedia.Audio.Renderer 2135 * @crossplatform 2136 * @since 12 2137 */ 2138 streamInfo: AudioStreamInfo; 2139 /** 2140 * Renderer information. 2141 * @type { AudioRendererInfo } 2142 * @syscap SystemCapability.Multimedia.Audio.Renderer 2143 * @since 8 2144 */ 2145 /** 2146 * Renderer information. 2147 * @type { AudioRendererInfo } 2148 * @syscap SystemCapability.Multimedia.Audio.Renderer 2149 * @crossplatform 2150 * @since 12 2151 */ 2152 rendererInfo: AudioRendererInfo; 2153 /** 2154 * Privacy configuration. 2155 * @type { ?AudioPrivacyType } 2156 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2157 * @since 10 2158 */ 2159 /** 2160 * Privacy configuration. 2161 * @type { ?AudioPrivacyType } 2162 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2163 * @crossplatform 2164 * @since 12 2165 */ 2166 privacyType?: AudioPrivacyType; 2167 } 2168 2169 /** 2170 * Enumerates audio stream privacy type for playback capture. 2171 * @enum { number } 2172 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2173 * @since 10 2174 */ 2175 /** 2176 * Enumerates audio stream privacy type for playback capture. 2177 * @enum { number } 2178 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2179 * @crossplatform 2180 * @since 12 2181 */ 2182 enum AudioPrivacyType { 2183 /** 2184 * Privacy type that stream can be captured by third party applications. 2185 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2186 * @since 10 2187 */ 2188 /** 2189 * Privacy type that stream can be captured by third party applications. 2190 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2191 * @crossplatform 2192 * @since 12 2193 */ 2194 PRIVACY_TYPE_PUBLIC = 0, 2195 2196 /** 2197 * Privacy type that stream can not be captured. 2198 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2199 * @since 10 2200 */ 2201 /** 2202 * Privacy type that stream can not be captured. 2203 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 2204 * @crossplatform 2205 * @since 12 2206 */ 2207 PRIVACY_TYPE_PRIVATE = 1, 2208 } 2209 2210 /** 2211 * Enumerates the interrupt modes. 2212 * @enum { number } 2213 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2214 * @since 9 2215 */ 2216 /** 2217 * Enumerates the interrupt modes. 2218 * @enum { number } 2219 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2220 * @crossplatform 2221 * @atomicservice 2222 * @since 12 2223 */ 2224 enum InterruptMode { 2225 /** 2226 * Mode that different stream share one interrupt unit. 2227 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2228 * @since 9 2229 */ 2230 /** 2231 * Mode that different stream share one interrupt unit. 2232 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2233 * @crossplatform 2234 * @atomicservice 2235 * @since 12 2236 */ 2237 SHARE_MODE = 0, 2238 /** 2239 * Mode that each stream has independent interrupt unit. 2240 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2241 * @since 9 2242 */ 2243 /** 2244 * Mode that each stream has independent interrupt unit. 2245 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2246 * @crossplatform 2247 * @atomicservice 2248 * @since 12 2249 */ 2250 INDEPENDENT_MODE = 1 2251 } 2252 2253 /** 2254 * Enumerates the audio renderer rates. 2255 * @enum { number } 2256 * @syscap SystemCapability.Multimedia.Audio.Renderer 2257 * @since 8 2258 */ 2259 enum AudioRendererRate { 2260 /** 2261 * Normal playback render rate. 2262 * @syscap SystemCapability.Multimedia.Audio.Renderer 2263 * @since 8 2264 */ 2265 RENDER_RATE_NORMAL = 0, 2266 /** 2267 * Double playback render rate. 2268 * @syscap SystemCapability.Multimedia.Audio.Renderer 2269 * @since 8 2270 */ 2271 RENDER_RATE_DOUBLE = 1, 2272 /** 2273 * Half playback render rate. 2274 * @syscap SystemCapability.Multimedia.Audio.Renderer 2275 * @since 8 2276 */ 2277 RENDER_RATE_HALF = 2 2278 } 2279 2280 /** 2281 * Enumerates the interrupt types. 2282 * @enum { number } 2283 * @syscap SystemCapability.Multimedia.Audio.Renderer 2284 * @since 7 2285 */ 2286 /** 2287 * Enumerates the interrupt types. 2288 * @enum { number } 2289 * @syscap SystemCapability.Multimedia.Audio.Renderer 2290 * @crossplatform 2291 * @atomicservice 2292 * @since 12 2293 */ 2294 enum InterruptType { 2295 /** 2296 * Audio playback interruption started. 2297 * @syscap SystemCapability.Multimedia.Audio.Renderer 2298 * @since 7 2299 */ 2300 /** 2301 * Audio playback interruption started. 2302 * @syscap SystemCapability.Multimedia.Audio.Renderer 2303 * @crossplatform 2304 * @atomicservice 2305 * @since 12 2306 */ 2307 INTERRUPT_TYPE_BEGIN = 1, 2308 2309 /** 2310 * Audio playback interruption ended. 2311 * @syscap SystemCapability.Multimedia.Audio.Renderer 2312 * @since 7 2313 */ 2314 /** 2315 * Audio playback interruption ended. 2316 * @syscap SystemCapability.Multimedia.Audio.Renderer 2317 * @crossplatform 2318 * @atomicservice 2319 * @since 12 2320 */ 2321 INTERRUPT_TYPE_END = 2 2322 } 2323 2324 /** 2325 * Enumerates the interrupt hints. 2326 * @enum { number } 2327 * @syscap SystemCapability.Multimedia.Audio.Renderer 2328 * @since 7 2329 */ 2330 /** 2331 * Enumerates the interrupt hints. 2332 * @enum { number } 2333 * @syscap SystemCapability.Multimedia.Audio.Renderer 2334 * @crossplatform 2335 * @atomicservice 2336 * @since 12 2337 */ 2338 enum InterruptHint { 2339 /** 2340 * None. 2341 * @syscap SystemCapability.Multimedia.Audio.Renderer 2342 * @since 8 2343 */ 2344 /** 2345 * None. 2346 * @syscap SystemCapability.Multimedia.Audio.Renderer 2347 * @atomicservice 2348 * @since 12 2349 */ 2350 INTERRUPT_HINT_NONE = 0, 2351 /** 2352 * Resume the playback. 2353 * @syscap SystemCapability.Multimedia.Audio.Renderer 2354 * @since 7 2355 */ 2356 /** 2357 * Resume the playback. 2358 * @syscap SystemCapability.Multimedia.Audio.Renderer 2359 * @crossplatform 2360 * @atomicservice 2361 * @since 12 2362 */ 2363 INTERRUPT_HINT_RESUME = 1, 2364 2365 /** 2366 * Paused/Pause the playback. 2367 * @syscap SystemCapability.Multimedia.Audio.Renderer 2368 * @since 7 2369 */ 2370 /** 2371 * Paused/Pause the playback. 2372 * @syscap SystemCapability.Multimedia.Audio.Renderer 2373 * @atomicservice 2374 * @since 12 2375 */ 2376 INTERRUPT_HINT_PAUSE = 2, 2377 2378 /** 2379 * Stopped/Stop the playback. 2380 * @syscap SystemCapability.Multimedia.Audio.Renderer 2381 * @since 7 2382 */ 2383 /** 2384 * Stopped/Stop the playback. 2385 * @syscap SystemCapability.Multimedia.Audio.Renderer 2386 * @atomicservice 2387 * @since 12 2388 */ 2389 INTERRUPT_HINT_STOP = 3, 2390 2391 /** 2392 * Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.) 2393 * @syscap SystemCapability.Multimedia.Audio.Renderer 2394 * @since 7 2395 */ 2396 /** 2397 * Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.) 2398 * @syscap SystemCapability.Multimedia.Audio.Renderer 2399 * @atomicservice 2400 * @since 12 2401 */ 2402 INTERRUPT_HINT_DUCK = 4, 2403 2404 /** 2405 * Unducked the playback. 2406 * @syscap SystemCapability.Multimedia.Audio.Renderer 2407 * @since 8 2408 */ 2409 /** 2410 * Unducked the playback. 2411 * @syscap SystemCapability.Multimedia.Audio.Renderer 2412 * @atomicservice 2413 * @since 12 2414 */ 2415 INTERRUPT_HINT_UNDUCK = 5, 2416 2417 /** 2418 * Mute the stream. 2419 * @syscap SystemCapability.Multimedia.Audio.Renderer 2420 * @since 20 2421 */ 2422 INTERRUPT_HINT_MUTE = 6, 2423 2424 /** 2425 * Unmute the stream. 2426 * @syscap SystemCapability.Multimedia.Audio.Renderer 2427 * @since 20 2428 */ 2429 INTERRUPT_HINT_UNMUTE = 7, 2430 } 2431 2432 /** 2433 * Enumerates the interrupt force types. 2434 * @enum { number } 2435 * @syscap SystemCapability.Multimedia.Audio.Renderer 2436 * @since 9 2437 */ 2438 /** 2439 * Enumerates the interrupt force types. 2440 * @enum { number } 2441 * @syscap SystemCapability.Multimedia.Audio.Renderer 2442 * @crossplatform 2443 * @atomicservice 2444 * @since 12 2445 */ 2446 enum InterruptForceType { 2447 /** 2448 * Forced action taken by system. 2449 * @syscap SystemCapability.Multimedia.Audio.Renderer 2450 * @since 9 2451 */ 2452 /** 2453 * Forced action taken by system. 2454 * @syscap SystemCapability.Multimedia.Audio.Renderer 2455 * @crossplatform 2456 * @atomicservice 2457 * @since 12 2458 */ 2459 INTERRUPT_FORCE = 0, 2460 /** 2461 * Share type, application can choose to take action or ignore. 2462 * @syscap SystemCapability.Multimedia.Audio.Renderer 2463 * @since 9 2464 */ 2465 /** 2466 * Share type, application can choose to take action or ignore. 2467 * @syscap SystemCapability.Multimedia.Audio.Renderer 2468 * @atomicservice 2469 * @since 12 2470 */ 2471 INTERRUPT_SHARE = 1 2472 } 2473 2474 /** 2475 * Describes the interrupt event received by the app when playback is interrupted. 2476 * @typedef InterruptEvent 2477 * @syscap SystemCapability.Multimedia.Audio.Renderer 2478 * @since 9 2479 */ 2480 /** 2481 * Describes the interrupt event received by the app when playback is interrupted. 2482 * @typedef InterruptEvent 2483 * @syscap SystemCapability.Multimedia.Audio.Renderer 2484 * @crossplatform 2485 * @atomicservice 2486 * @since 12 2487 */ 2488 interface InterruptEvent { 2489 /** 2490 * Indicates whether the interruption has started or finished. 2491 * @type { InterruptType } 2492 * @syscap SystemCapability.Multimedia.Audio.Renderer 2493 * @since 9 2494 */ 2495 /** 2496 * Indicates whether the interruption has started or finished. 2497 * @type { InterruptType } 2498 * @syscap SystemCapability.Multimedia.Audio.Renderer 2499 * @crossplatform 2500 * @atomicservice 2501 * @since 12 2502 */ 2503 eventType: InterruptType; 2504 2505 /** 2506 * Indicates whether the action is taken by system or to be taken by the app. 2507 * @type { InterruptForceType } 2508 * @syscap SystemCapability.Multimedia.Audio.Renderer 2509 * @since 9 2510 */ 2511 /** 2512 * Indicates whether the action is taken by system or to be taken by the app. 2513 * @type { InterruptForceType } 2514 * @syscap SystemCapability.Multimedia.Audio.Renderer 2515 * @crossplatform 2516 * @atomicservice 2517 * @since 12 2518 */ 2519 forceType: InterruptForceType; 2520 2521 /** 2522 * Indicates the kind of action. 2523 * @type { InterruptHint } 2524 * @syscap SystemCapability.Multimedia.Audio.Renderer 2525 * @since 9 2526 */ 2527 /** 2528 * Indicates the kind of action. 2529 * @type { InterruptHint } 2530 * @syscap SystemCapability.Multimedia.Audio.Renderer 2531 * @crossplatform 2532 * @atomicservice 2533 * @since 12 2534 */ 2535 hintType: InterruptHint; 2536 } 2537 2538 /** 2539 * Enumerates interrupt action types. 2540 * @enum { number } 2541 * @syscap SystemCapability.Multimedia.Audio.Renderer 2542 * @since 7 2543 * @deprecated since 9 2544 */ 2545 enum InterruptActionType { 2546 2547 /** 2548 * Focus gain event. 2549 * @syscap SystemCapability.Multimedia.Audio.Renderer 2550 * @since 7 2551 * @deprecated since 9 2552 */ 2553 TYPE_ACTIVATED = 0, 2554 2555 /** 2556 * Audio interruption event. 2557 * @syscap SystemCapability.Multimedia.Audio.Renderer 2558 * @since 7 2559 * @deprecated since 9 2560 */ 2561 TYPE_INTERRUPT = 1 2562 } 2563 2564 /** 2565 * Enumerates device change types. 2566 * @enum { number } 2567 * @syscap SystemCapability.Multimedia.Audio.Device 2568 * @since 7 2569 */ 2570 /** 2571 * Enumerates device change types. 2572 * @enum { number } 2573 * @syscap SystemCapability.Multimedia.Audio.Device 2574 * @crossplatform 2575 * @since 12 2576 */ 2577 enum DeviceChangeType { 2578 /** 2579 * Device connection. 2580 * @syscap SystemCapability.Multimedia.Audio.Device 2581 * @since 7 2582 */ 2583 /** 2584 * Device connection. 2585 * @syscap SystemCapability.Multimedia.Audio.Device 2586 * @crossplatform 2587 * @since 12 2588 */ 2589 CONNECT = 0, 2590 2591 /** 2592 * Device disconnection. 2593 * @syscap SystemCapability.Multimedia.Audio.Device 2594 * @since 7 2595 */ 2596 /** 2597 * Device disconnection. 2598 * @syscap SystemCapability.Multimedia.Audio.Device 2599 * @crossplatform 2600 * @since 12 2601 */ 2602 DISCONNECT = 1, 2603 } 2604 2605 /** 2606 * Enumerates audio scenes. 2607 * @enum { number } 2608 * @syscap SystemCapability.Multimedia.Audio.Communication 2609 * @since 8 2610 */ 2611 /** 2612 * Enumerates audio scenes. 2613 * @enum { number } 2614 * @syscap SystemCapability.Multimedia.Audio.Communication 2615 * @crossplatform 2616 * @since 12 2617 */ 2618 enum AudioScene { 2619 /** 2620 * Default audio scene 2621 * @syscap SystemCapability.Multimedia.Audio.Communication 2622 * @since 8 2623 */ 2624 /** 2625 * Default audio scene 2626 * @syscap SystemCapability.Multimedia.Audio.Communication 2627 * @crossplatform 2628 * @since 12 2629 */ 2630 AUDIO_SCENE_DEFAULT = 0, 2631 /** 2632 * Ringing audio scene 2633 * @syscap SystemCapability.Multimedia.Audio.Communication 2634 * @since 12 2635 */ 2636 AUDIO_SCENE_RINGING = 1, 2637 /** 2638 * Phone call audio scene 2639 * @syscap SystemCapability.Multimedia.Audio.Communication 2640 * @since 12 2641 */ 2642 AUDIO_SCENE_PHONE_CALL = 2, 2643 /** 2644 * Voice chat audio scene 2645 * @syscap SystemCapability.Multimedia.Audio.Communication 2646 * @since 8 2647 */ 2648 /** 2649 * Voice chat audio scene 2650 * @syscap SystemCapability.Multimedia.Audio.Communication 2651 * @crossplatform 2652 * @since 12 2653 */ 2654 AUDIO_SCENE_VOICE_CHAT = 3 2655 } 2656 2657 /** 2658 * Enumerates volume adjustment types. 2659 * @enum { number } 2660 * @syscap SystemCapability.Multimedia.Audio.Volume 2661 * @systemapi 2662 * @since 10 2663 */ 2664 enum VolumeAdjustType { 2665 /** 2666 * Adjust volume up. 2667 * @syscap SystemCapability.Multimedia.Audio.Volume 2668 * @systemapi 2669 * @since 10 2670 */ 2671 VOLUME_UP = 0, 2672 /** 2673 * Adjust volume down. 2674 * @syscap SystemCapability.Multimedia.Audio.Volume 2675 * @systemapi 2676 * @since 10 2677 */ 2678 VOLUME_DOWN = 1, 2679 } 2680 2681 /** 2682 * Implements audio volume and audio device management. 2683 * @typedef AudioManager 2684 * @syscap SystemCapability.Multimedia.Audio.Core 2685 * @since 7 2686 */ 2687 /** 2688 * Implements audio stream, volume, device, effect and many other management functions. 2689 * @typedef AudioManager 2690 * @syscap SystemCapability.Multimedia.Audio.Core 2691 * @crossplatform 2692 * @since 12 2693 */ 2694 interface AudioManager { 2695 /** 2696 * Sets the volume for a volume type. This method uses an asynchronous callback to return the result. 2697 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2698 * @param { AudioVolumeType } volumeType - Audio volume type. 2699 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 2700 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2701 * @syscap SystemCapability.Multimedia.Audio.Volume 2702 * @since 7 2703 * @deprecated since 9 2704 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume 2705 */ 2706 setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void; 2707 /** 2708 * Sets the volume for a volume type. This method uses a promise to return the result. 2709 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2710 * @param { AudioVolumeType } volumeType - Audio volume type. 2711 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 2712 * @returns { Promise<void> } Promise used to return the result. 2713 * @syscap SystemCapability.Multimedia.Audio.Volume 2714 * @since 7 2715 * @deprecated since 9 2716 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume 2717 */ 2718 setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>; 2719 /** 2720 * Obtains the volume of a volume type. This method uses an asynchronous callback to return the query result. 2721 * @param { AudioVolumeType } volumeType - Audio volume type. 2722 * @param { AsyncCallback<number> } callback - Callback used to return the volume. 2723 * @syscap SystemCapability.Multimedia.Audio.Volume 2724 * @since 7 2725 * @deprecated since 9 2726 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume 2727 */ 2728 getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 2729 /** 2730 * Obtains the volume of a volume type. This method uses a promise to return the query result. 2731 * @param { AudioVolumeType } volumeType - Audio volume type. 2732 * @returns { Promise<number> } Promise used to return the volume. 2733 * @syscap SystemCapability.Multimedia.Audio.Volume 2734 * @since 7 2735 * @deprecated since 9 2736 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume 2737 */ 2738 getVolume(volumeType: AudioVolumeType): Promise<number>; 2739 /** 2740 * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 2741 * @param { AudioVolumeType } volumeType - Audio stream type. 2742 * @param { AsyncCallback<number> } callback - Callback used to return the minimum volume. 2743 * @syscap SystemCapability.Multimedia.Audio.Volume 2744 * @since 7 2745 * @deprecated since 9 2746 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume 2747 */ 2748 getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 2749 /** 2750 * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. 2751 * @param { AudioVolumeType } volumeType - Audio stream type. 2752 * @returns { Promise<number> } Promise used to return the minimum volume. 2753 * @syscap SystemCapability.Multimedia.Audio.Volume 2754 * @since 7 2755 * @deprecated since 9 2756 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume 2757 */ 2758 getMinVolume(volumeType: AudioVolumeType): Promise<number>; 2759 /** 2760 * Obtains the maximum volume allowed for a volume type. This method uses an asynchronous callback to return the query result. 2761 * @param { AudioVolumeType } volumeType - Audio volume type. 2762 * @param { AsyncCallback<number> } callback - Callback used to return the maximum volume. 2763 * @syscap SystemCapability.Multimedia.Audio.Volume 2764 * @since 7 2765 * @deprecated since 9 2766 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume 2767 */ 2768 getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 2769 /** 2770 * Obtains the maximum volume allowed for a volume type. This method uses a promise to return the query result. 2771 * @param { AudioVolumeType } volumeType - Audio volume type. 2772 * @returns { Promise<number> } Promise used to return the maximum volume. 2773 * @syscap SystemCapability.Multimedia.Audio.Volume 2774 * @since 7 2775 * @deprecated since 9 2776 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume 2777 */ 2778 getMaxVolume(volumeType: AudioVolumeType): Promise<number>; 2779 /** 2780 * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. 2781 * @param { DeviceFlag } deviceFlag - Audio device flag. 2782 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the device list. 2783 * @syscap SystemCapability.Multimedia.Audio.Device 2784 * @since 7 2785 * @deprecated since 9 2786 * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices 2787 */ 2788 getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void; 2789 /** 2790 * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. 2791 * @param { DeviceFlag } deviceFlag - Audio device flag. 2792 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the device list. 2793 * @syscap SystemCapability.Multimedia.Audio.Device 2794 * @since 7 2795 * @deprecated since 9 2796 * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices 2797 */ 2798 getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>; 2799 /** 2800 * Mutes a volume type. This method uses an asynchronous callback to return the result. 2801 * @param { AudioVolumeType } volumeType - Audio volume type. 2802 * @param { boolean } mute - Mute status to set. The value true means to mute the volume type, and false means the opposite. 2803 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2804 * @syscap SystemCapability.Multimedia.Audio.Volume 2805 * @since 7 2806 * @deprecated since 9 2807 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute 2808 */ 2809 mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void; 2810 /** 2811 * Mutes a volume type. This method uses a promise to return the result. 2812 * @param { AudioVolumeType } volumeType - Audio volume type. 2813 * @param { boolean } mute - Mute status to set. The value true means to mute the volume type, and false means the opposite. 2814 * @returns { Promise<void> } Promise used to return the result. 2815 * @syscap SystemCapability.Multimedia.Audio.Volume 2816 * @since 7 2817 * @deprecated since 9 2818 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute 2819 */ 2820 mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>; 2821 /** 2822 * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. 2823 * @param { AudioVolumeType } volumeType - Audio stream type. 2824 * @param { AsyncCallback<boolean> } callback - Callback used to return the mute status of the stream. 2825 * The value true means that the stream is muted, and false means the opposite. 2826 * @syscap SystemCapability.Multimedia.Audio.Volume 2827 * @since 7 2828 * @deprecated since 9 2829 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute 2830 */ 2831 isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 2832 /** 2833 * Checks whether a stream is muted. This method uses a promise to return the result. 2834 * @param { AudioVolumeType } volumeType - Audio stream type. 2835 * @returns { Promise<boolean> } Promise used to return the mute status of the stream. The value true means 2836 * that the stream is muted, and false means the opposite. 2837 * @syscap SystemCapability.Multimedia.Audio.Volume 2838 * @since 7 2839 * @deprecated since 9 2840 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute 2841 */ 2842 isMute(volumeType: AudioVolumeType): Promise<boolean>; 2843 /** 2844 * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. 2845 * @param { AudioVolumeType } volumeType - Audio stream type. 2846 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the stream. 2847 * The value true means that the stream is active, and false means the opposite. 2848 * @syscap SystemCapability.Multimedia.Audio.Volume 2849 * @since 7 2850 * @deprecated since 9 2851 * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive 2852 */ 2853 isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 2854 /** 2855 * Checks whether a stream is active. This method uses a promise to return the query result. 2856 * @param { AudioVolumeType } volumeType - Audio stream type. 2857 * @returns { Promise<boolean> } Promise used to return the active status of the stream. The value true means 2858 * that the stream is active, and false means the opposite. 2859 * @syscap SystemCapability.Multimedia.Audio.Volume 2860 * @since 7 2861 * @deprecated since 9 2862 * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive 2863 */ 2864 isActive(volumeType: AudioVolumeType): Promise<boolean>; 2865 /** 2866 * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. 2867 * @permission ohos.permission.MICROPHONE 2868 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 2869 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2870 * @syscap SystemCapability.Multimedia.Audio.Device 2871 * @since 7 2872 * @deprecated since 9 2873 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute 2874 */ 2875 setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void; 2876 /** 2877 * Mutes or unmutes the microphone. This method uses a promise to return the result. 2878 * @permission ohos.permission.MICROPHONE 2879 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 2880 * @returns { Promise<void> } Promise used to return the result. 2881 * @syscap SystemCapability.Multimedia.Audio.Device 2882 * @since 7 2883 * @deprecated since 9 2884 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute 2885 */ 2886 setMicrophoneMute(mute: boolean): Promise<void>; 2887 /** 2888 * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. 2889 * @permission ohos.permission.MICROPHONE 2890 * @param { AsyncCallback<boolean> } callback - used to return the mute status of the microphone. The value 2891 * true means that the microphone is muted, and false means the opposite. 2892 * @syscap SystemCapability.Multimedia.Audio.Device 2893 * @since 7 2894 * @deprecated since 9 2895 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute 2896 */ 2897 isMicrophoneMute(callback: AsyncCallback<boolean>): void; 2898 /** 2899 * Checks whether the microphone is muted. This method uses a promise to return the query result. 2900 * @permission ohos.permission.MICROPHONE 2901 * @returns { Promise<boolean> } Promise used to return the mute status of the microphone. The value 2902 * true means that the microphone is muted, and false means the opposite. 2903 * @syscap SystemCapability.Multimedia.Audio.Device 2904 * @since 7 2905 * @deprecated since 9 2906 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute 2907 */ 2908 isMicrophoneMute(): Promise<boolean>; 2909 /** 2910 * Sets the ringer mode. This method uses an asynchronous callback to return the result. 2911 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2912 * @param { AudioRingMode } mode - Ringer mode. 2913 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2914 * @syscap SystemCapability.Multimedia.Audio.Communication 2915 * @since 7 2916 * @deprecated since 9 2917 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode 2918 */ 2919 setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void; 2920 /** 2921 * Sets the ringer mode. This method uses a promise to return the result. 2922 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2923 * @param { AudioRingMode } mode - Ringer mode. 2924 * @returns { Promise<void> } Promise used to return the result. 2925 * @syscap SystemCapability.Multimedia.Audio.Communication 2926 * @since 7 2927 * @deprecated since 9 2928 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode 2929 */ 2930 setRingerMode(mode: AudioRingMode): Promise<void>; 2931 /** 2932 * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. 2933 * @param { AsyncCallback<AudioRingMode> } callback - Callback used to return the ringer mode. 2934 * @syscap SystemCapability.Multimedia.Audio.Communication 2935 * @since 7 2936 * @deprecated since 9 2937 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode 2938 */ 2939 getRingerMode(callback: AsyncCallback<AudioRingMode>): void; 2940 /** 2941 * Obtains the ringer mode. This method uses a promise to return the query result. 2942 * @returns { Promise<AudioRingMode> } Promise used to return the ringer mode. 2943 * @syscap SystemCapability.Multimedia.Audio.Communication 2944 * @since 7 2945 * @deprecated since 9 2946 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode 2947 */ 2948 getRingerMode(): Promise<AudioRingMode>; 2949 /** 2950 * Sets an audio parameter. This method uses an asynchronous callback to return the result. 2951 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 2952 * @param { string } key - Key of the audio parameter to set. 2953 * @param { string } value - Value of the audio parameter to set. 2954 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2955 * @syscap SystemCapability.Multimedia.Audio.Core 2956 * @since 7 2957 * @deprecated since 11 2958 * @useinstead ohos.multimedia.audio.AudioManager#setExtraParameters 2959 */ 2960 setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void; 2961 /** 2962 * Sets an audio parameter. This method uses a promise to return the result. 2963 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 2964 * @param { string } key - Key of the audio parameter to set. 2965 * @param { string } value - Value of the audio parameter to set. 2966 * @returns { Promise<void> } Promise used to return the result. 2967 * @syscap SystemCapability.Multimedia.Audio.Core 2968 * @since 7 2969 * @deprecated since 11 2970 * @useinstead ohos.multimedia.audio.AudioManager#setExtraParameters 2971 */ 2972 setAudioParameter(key: string, value: string): Promise<void>; 2973 2974 /** 2975 * Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. 2976 * @param { string } key - Key of the audio parameter whose value is to be obtained. 2977 * @param { AsyncCallback<string> } callback - Callback used to return the value of the audio parameter. 2978 * @syscap SystemCapability.Multimedia.Audio.Core 2979 * @since 7 2980 * @deprecated since 11 2981 * @useinstead ohos.multimedia.audio.AudioManager#getExtraParameters 2982 */ 2983 getAudioParameter(key: string, callback: AsyncCallback<string>): void; 2984 /** 2985 * Obtains the value of an audio parameter. This method uses a promise to return the query result. 2986 * @param { string } key - Key of the audio parameter whose value is to be obtained. 2987 * @returns { Promise<string> } Promise used to return the value of the audio parameter. 2988 * @syscap SystemCapability.Multimedia.Audio.Core 2989 * @since 7 2990 * @deprecated since 11 2991 * @useinstead ohos.multimedia.audio.AudioManager#getExtraParameters 2992 */ 2993 getAudioParameter(key: string): Promise<string>; 2994 2995 /** 2996 * Sets extra audio parameters. This method uses a promise to return the result. 2997 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 2998 * @param { string } mainKey - Main key of the audio parameters to set. 2999 * @param { Record<string, string> } kvpairs - Key-value pairs with subkeys and values to set. 3000 * @returns { Promise<void> } Promise used to return the result. 3001 * @throws { BusinessError } 201 - Permission denied. 3002 * @throws { BusinessError } 202 - Not system App. 3003 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3004 * 1.Mandatory parameters are left unspecified; 3005 * 2.Incorrect parameter types. 3006 * @throws { BusinessError } 6800101 - Parameter verification failed. 3007 * @syscap SystemCapability.Multimedia.Audio.Core 3008 * @systemapi 3009 * @since 11 3010 */ 3011 setExtraParameters(mainKey: string, kvpairs: Record<string, string>): Promise<void>; 3012 3013 /** 3014 * Obtains the values of a certain key. This method uses a promise to return the query result. 3015 * @param { string } mainKey - Main key of the audio parameters to get. 3016 * @param { Array<string> } subKeys - Sub keys of the audio parameters to get. 3017 * @returns { Promise<Record<string, string>> } Promise used to return the key-value pairs. 3018 * @throws { BusinessError } 202 - Not system App. 3019 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3020 * 1.Mandatory parameters are left unspecified; 3021 * 2.Incorrect parameter types. 3022 * @throws { BusinessError } 6800101 - Parameter verification failed. 3023 * @syscap SystemCapability.Multimedia.Audio.Core 3024 * @systemapi 3025 * @since 11 3026 */ 3027 getExtraParameters(mainKey: string, subKeys?: Array<string>): Promise<Record<string, string>>; 3028 3029 /** 3030 * Sets a device to the active state. Applications that are not in a call state cannot modify the calling device by this method. 3031 * This method uses an asynchronous callback to return the result. 3032 * @param { ActiveDeviceType } deviceType - Audio device type. 3033 * @param { boolean } active - Active status to set. The value true means to set the device to the active 3034 * status, and false means the opposite. 3035 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3036 * @syscap SystemCapability.Multimedia.Audio.Device 3037 * @since 7 3038 * @deprecated since 9 3039 * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice 3040 */ 3041 setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback<void>): void; 3042 /** 3043 * Sets a device to the active state. Applications that are not in a call state cannot modify the calling device by this method. 3044 * This method uses a promise to return the result. 3045 * @param { ActiveDeviceType } deviceType - Audio device type. 3046 * @param { boolean } active - Active status to set. The value true means to set the device to the active 3047 * status, and false means the opposite. 3048 * @returns { Promise<void> } Promise used to return the result. 3049 * @syscap SystemCapability.Multimedia.Audio.Device 3050 * @since 7 3051 * @deprecated since 9 3052 * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice 3053 */ 3054 setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void>; 3055 /** 3056 * Checks whether a device is active. This method uses an asynchronous callback to return the query result. 3057 * @param { ActiveDeviceType } deviceType - Audio device type. 3058 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the device. 3059 * @syscap SystemCapability.Multimedia.Audio.Device 3060 * @since 7 3061 * @deprecated since 9 3062 * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive 3063 */ 3064 isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean>): void; 3065 /** 3066 * Checks whether a device is active. This method uses a promise to return the query result. 3067 * @param { ActiveDeviceType } deviceType - Audio device type. 3068 * @returns { Promise<boolean> } Promise used to return the active status of the device. 3069 * @syscap SystemCapability.Multimedia.Audio.Device 3070 * @since 7 3071 * @deprecated since 9 3072 * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive 3073 */ 3074 isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean>; 3075 /** 3076 * Listens for system volume change events. This method uses a callback to get volume change events. 3077 * @param { 'volumeChange' } type - Type of the event to listen for. Only the volumeChange event is supported. 3078 * @param { Callback<VolumeEvent> } callback - Callback used to get the system volume change event. 3079 * @syscap SystemCapability.Multimedia.Audio.Volume 3080 * @systemapi 3081 * @since 8 3082 * @deprecated since 9 3083 * @useinstead ohos.multimedia.audio.AudioVolumeManager#event:volumeChange 3084 */ 3085 on(type: 'volumeChange', callback: Callback<VolumeEvent>): void; 3086 /** 3087 * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. 3088 * @param { 'ringerModeChange' } type - Type of the event to listen for. Only the ringerModeChange event is supported. 3089 * @param { Callback<AudioRingMode> } callback - Callback used to get the updated ringer mode. 3090 * @syscap SystemCapability.Multimedia.Audio.Communication 3091 * @systemapi 3092 * @since 8 3093 * @deprecated since 9 3094 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#event:ringerModeChange 3095 */ 3096 on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void; 3097 /** 3098 * Sets the audio scene mode to change audio strategies. This method uses an asynchronous callback to return the 3099 * result. 3100 * @param { AudioScene } scene - Audio scene mode. 3101 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3102 * @syscap SystemCapability.Multimedia.Audio.Communication 3103 * @systemapi 3104 * @since 8 3105 */ 3106 setAudioScene(scene: AudioScene, callback: AsyncCallback<void>): void; 3107 /** 3108 * Sets the audio scene mode to change audio strategies. This method uses a promise to return the result. 3109 * @param { AudioScene } scene - Audio scene mode. 3110 * @returns { Promise<void> } Promise used to return the result. 3111 * @syscap SystemCapability.Multimedia.Audio.Communication 3112 * @systemapi 3113 * @since 8 3114 */ 3115 setAudioScene(scene: AudioScene): Promise<void>; 3116 /** 3117 * Obtains the audio scene mode. This method uses an asynchronous callback to return the query result. 3118 * @param { AsyncCallback<AudioScene> } callback - Callback used to return the audio scene mode. 3119 * @syscap SystemCapability.Multimedia.Audio.Communication 3120 * @since 8 3121 */ 3122 /** 3123 * Obtains the audio scene mode. This method uses an asynchronous callback to return the query result. 3124 * @param { AsyncCallback<AudioScene> } callback - Callback used to return the audio scene mode. 3125 * @syscap SystemCapability.Multimedia.Audio.Communication 3126 * @crossplatform 3127 * @since 12 3128 */ 3129 getAudioScene(callback: AsyncCallback<AudioScene>): void; 3130 /** 3131 * Obtains the audio scene mode. This method uses a promise to return the query result. 3132 * @returns { Promise<AudioScene> } Promise used to return the audio scene mode. 3133 * @syscap SystemCapability.Multimedia.Audio.Communication 3134 * @since 8 3135 */ 3136 /** 3137 * Obtains the audio scene mode. This method uses a promise to return the query result. 3138 * @returns { Promise<AudioScene> } Promise used to return the audio scene mode. 3139 * @syscap SystemCapability.Multimedia.Audio.Communication 3140 * @crossplatform 3141 * @since 12 3142 */ 3143 getAudioScene(): Promise<AudioScene>; 3144 /** 3145 * Obtains the audio scene mode. 3146 * @returns { AudioScene } Current audio scene mode. 3147 * @syscap SystemCapability.Multimedia.Audio.Communication 3148 * @since 10 3149 */ 3150 /** 3151 * Obtains the audio scene mode. 3152 * @returns { AudioScene } Current audio scene mode. 3153 * @syscap SystemCapability.Multimedia.Audio.Communication 3154 * @crossplatform 3155 * @since 12 3156 */ 3157 getAudioSceneSync(): AudioScene; 3158 3159 /** 3160 * Subscribes to audio scene change events. When system changes to communication status, registered clients 3161 * will receive the callback. 3162 * @param { 'audioSceneChange' } type - Type of the event to listen for. Only the audioSceneChange event is 3163 * supported. 3164 * @param { Callback<AudioScene> } callback - Callback used to obtain the latest audio scene. 3165 * @syscap SystemCapability.Multimedia.Audio.Communication 3166 * @since 20 3167 */ 3168 on(type: 'audioSceneChange', callback: Callback<AudioScene>): void; 3169 3170 /** 3171 * Unsubscribes to audio scene change events. 3172 * @param { 'audioSceneChange' } type - Type of the event to listen for. Only the audioSceneChange event is 3173 * supported. 3174 * @param { Callback<AudioScene> } callback - Callback used in subscription. 3175 * @syscap SystemCapability.Multimedia.Audio.Communication 3176 * @since 20 3177 */ 3178 off(type: 'audioSceneChange', callback?: Callback<AudioScene>): void; 3179 3180 /** 3181 * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive 3182 * the callback. 3183 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 3184 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3185 * @syscap SystemCapability.Multimedia.Audio.Device 3186 * @since 7 3187 * @deprecated since 9 3188 * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange 3189 */ 3190 on(type: 'deviceChange', callback: Callback<DeviceChangeAction>): void; 3191 3192 /** 3193 * UnSubscribes to device change events. 3194 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 3195 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3196 * @syscap SystemCapability.Multimedia.Audio.Device 3197 * @since 7 3198 * @deprecated since 9 3199 * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange 3200 */ 3201 off(type: 'deviceChange', callback?: Callback<DeviceChangeAction>): void; 3202 3203 /** 3204 * Listens for audio interruption events. When the audio of an application is interrupted by another application, 3205 * the callback is invoked to notify the former application. 3206 * @param { 'interrupt' } type - Type of the event to listen for. Only the interrupt event is supported. 3207 * @param { AudioInterrupt } interrupt - Parameters of the audio interruption event type. 3208 * @param { Callback<InterruptAction> } callback - Callback invoked for the audio interruption event. 3209 * @syscap SystemCapability.Multimedia.Audio.Renderer 3210 * @since 7 3211 * @deprecated since 11 3212 * @useinstead ohos.multimedia.audio.AudioRenderer#event:audioInterrupt 3213 */ 3214 on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback<InterruptAction>): void; 3215 3216 /** 3217 * Cancels the listening of audio interruption events. 3218 * @param { 'interrupt' } type - Type of the event to listen for. Only the interrupt event is supported. 3219 * @param { AudioInterrupt } interrupt - Input parameters of the audio interruption event. 3220 * @param { Callback<InterruptAction> } callback - Callback invoked for the audio interruption event. 3221 * @syscap SystemCapability.Multimedia.Audio.Renderer 3222 * @since 7 3223 * @deprecated since 11 3224 * @useinstead ohos.multimedia.audio.AudioRenderer#event:audioInterrupt 3225 */ 3226 off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback<InterruptAction>): void; 3227 3228 /** 3229 * Obtains an {@link AudioVolumeManager} instance. 3230 * @returns { AudioVolumeManager } AudioVolumeManager instance. 3231 * @syscap SystemCapability.Multimedia.Audio.Volume 3232 * @since 9 3233 */ 3234 /** 3235 * Obtains an {@link AudioVolumeManager} instance. 3236 * @returns { AudioVolumeManager } AudioVolumeManager instance. 3237 * @syscap SystemCapability.Multimedia.Audio.Volume 3238 * @crossplatform 3239 * @since 12 3240 */ 3241 getVolumeManager(): AudioVolumeManager; 3242 3243 /** 3244 * Obtains an {@link AudioStreamManager} instance. 3245 * @returns { AudioStreamManager } AudioStreamManager instance. 3246 * @syscap SystemCapability.Multimedia.Audio.Core 3247 * @since 9 3248 */ 3249 /** 3250 * Obtains an {@link AudioStreamManager} instance. 3251 * @returns { AudioStreamManager } AudioStreamManager instance. 3252 * @syscap SystemCapability.Multimedia.Audio.Core 3253 * @crossplatform 3254 * @since 12 3255 */ 3256 getStreamManager(): AudioStreamManager; 3257 3258 /** 3259 * Obtains an {@link AudioRoutingManager} instance. 3260 * @returns { AudioRoutingManager } AudioRoutingManager instance. 3261 * @syscap SystemCapability.Multimedia.Audio.Device 3262 * @since 9 3263 */ 3264 /** 3265 * Obtains an {@link AudioRoutingManager} instance. 3266 * @returns { AudioRoutingManager } AudioRoutingManager instance. 3267 * @syscap SystemCapability.Multimedia.Audio.Device 3268 * @crossplatform 3269 * @since 12 3270 */ 3271 getRoutingManager(): AudioRoutingManager; 3272 3273 /** 3274 * Obtains an {@link AudioSessionManager} instance. 3275 * @returns { AudioSessionManager } AudioSessionManager instance. 3276 * @syscap SystemCapability.Multimedia.Audio.Core 3277 * @crossplatform 3278 * @since 12 3279 */ 3280 getSessionManager(): AudioSessionManager; 3281 3282 /** 3283 * Obtains an {@link AudioSpatializationManager} instance. 3284 * @returns { AudioSpatializationManager } AudioSpatializationManager instance. 3285 * @syscap SystemCapability.Multimedia.Audio.Spatialization 3286 * @since 18 3287 */ 3288 getSpatializationManager(): AudioSpatializationManager; 3289 3290 /** 3291 * Obtains an {@link AudioEffectManager} instance. 3292 * @returns { AudioEffectManager } AudioEffectManager instance. 3293 * @throws { BusinessError } 202 - Not system App. 3294 * @syscap SystemCapability.Multimedia.Audio.Core 3295 * @systemapi 3296 * @since 18 3297 */ 3298 getEffectManager(): AudioEffectManager; 3299 3300 /** 3301 * Obtains a collaborative playback management instance. 3302 * @returns { AudioCollaborativeManager } Returns a collaborative playback management instance. 3303 * @throws { BusinessError } 202 - Not system App. 3304 * @syscap SystemCapability.Multimedia.Audio.Core 3305 * @systemapi 3306 * @since 20 3307 */ 3308 getCollaborativeManager(): AudioCollaborativeManager; 3309 3310 /** 3311 * user disable the safe media volume state. 3312 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 3313 * @returns { Promise<void> } Promise used to return the result. 3314 * @throws { BusinessError } 201 - Permission denied. 3315 * @throws { BusinessError } 202 - Not system App. 3316 * @syscap SystemCapability.Multimedia.Audio.Core 3317 * @systemapi 3318 * @since 12 3319 */ 3320 disableSafeMediaVolume(): Promise<void>; 3321 } 3322 3323 /** 3324 * Enumerates audio interrupt request result type. 3325 * @enum { number } 3326 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3327 * @systemapi 3328 * @since 9 3329 */ 3330 enum InterruptRequestResultType { 3331 /** 3332 * Request audio interrupt success 3333 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3334 * @systemapi 3335 * @since 9 3336 */ 3337 INTERRUPT_REQUEST_GRANT = 0, 3338 /** 3339 * Request audio interrupt fail, may have higher priority type 3340 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3341 * @systemapi 3342 * @since 9 3343 */ 3344 INTERRUPT_REQUEST_REJECT = 1 3345 } 3346 3347 /** 3348 * Describes audio interrupt operation results. 3349 * @typedef InterruptResult 3350 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3351 * @systemapi 3352 * @since 9 3353 */ 3354 interface InterruptResult { 3355 /** 3356 * Interrupt request or abandon result. 3357 * @type { InterruptRequestResultType } 3358 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3359 * @systemapi 3360 * @since 9 3361 */ 3362 requestResult: InterruptRequestResultType; 3363 /** 3364 * Interrupt node as a unit to receive interrupt change event. 3365 * @type { number } 3366 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3367 * @systemapi 3368 * @since 9 3369 */ 3370 interruptNode: number; 3371 } 3372 3373 /** 3374 * Desribes audio device block status. By default, the device is consider as unblocked. 3375 * @enum { number } 3376 * @syscap SystemCapability.Multimedia.Audio.Device 3377 * @since 13 3378 */ 3379 enum DeviceBlockStatus { 3380 /** 3381 * Device is unblocked. 3382 * @syscap SystemCapability.Multimedia.Audio.Device 3383 * @since 13 3384 */ 3385 UNBLOCKED = 0, 3386 /** 3387 * Device is blocked. 3388 * @syscap SystemCapability.Multimedia.Audio.Device 3389 * @since 13 3390 */ 3391 BLOCKED = 1, 3392 } 3393 3394 /** 3395 * Desribes audio device block status info. 3396 * @typedef DeviceBlockStatusInfo 3397 * @syscap SystemCapability.Multimedia.Audio.Device 3398 * @since 13 3399 */ 3400 interface DeviceBlockStatusInfo { 3401 /** 3402 * Device block status. 3403 * @type {DeviceBlockStatus} 3404 * @syscap SystemCapability.Multimedia.Audio.Device 3405 * @since 13 3406 */ 3407 blockStatus: DeviceBlockStatus; 3408 3409 /** 3410 * Audio device descriptors whose block status has changed. 3411 * @type {AudioDeviceDescriptors} 3412 * @syscap SystemCapability.Multimedia.Audio.Device 3413 * @since 13 3414 */ 3415 devices: AudioDeviceDescriptors; 3416 } 3417 3418 /** 3419 * Implements audio router management. 3420 * @typedef AudioRoutingManager 3421 * @syscap SystemCapability.Multimedia.Audio.Device 3422 * @since 9 3423 */ 3424 /** 3425 * Implements audio router management. 3426 * @typedef AudioRoutingManager 3427 * @syscap SystemCapability.Multimedia.Audio.Device 3428 * @crossplatform 3429 * @since 12 3430 */ 3431 interface AudioRoutingManager { 3432 /** 3433 * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. 3434 * @param { DeviceFlag } deviceFlag - Audio device flag. 3435 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the device list. 3436 * @syscap SystemCapability.Multimedia.Audio.Device 3437 * @since 9 3438 */ 3439 /** 3440 * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. 3441 * @param { DeviceFlag } deviceFlag - Audio device flag. 3442 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the device list. 3443 * @syscap SystemCapability.Multimedia.Audio.Device 3444 * @crossplatform 3445 * @since 12 3446 */ 3447 getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void; 3448 /** 3449 * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. 3450 * @param { DeviceFlag } deviceFlag - Audio device flag. 3451 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the device list. 3452 * @syscap SystemCapability.Multimedia.Audio.Device 3453 * @since 9 3454 */ 3455 /** 3456 * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. 3457 * @param { DeviceFlag } deviceFlag - Audio device flag. 3458 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the device list. 3459 * @syscap SystemCapability.Multimedia.Audio.Device 3460 * @crossplatform 3461 * @since 12 3462 */ 3463 getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>; 3464 /** 3465 * Obtains the audio devices with a specific flag. 3466 * @param { DeviceFlag } deviceFlag - Audio device flag. 3467 * @returns { AudioDeviceDescriptors } The device list. 3468 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3469 * 1.Mandatory parameters are left unspecified; 3470 * 2.Incorrect parameter types. 3471 * @throws { BusinessError } 6800101 - Parameter verification failed. 3472 * @syscap SystemCapability.Multimedia.Audio.Device 3473 * @since 10 3474 */ 3475 /** 3476 * Obtains the audio devices with a specific flag. 3477 * @param { DeviceFlag } deviceFlag - Audio device flag. 3478 * @returns { AudioDeviceDescriptors } The device list. 3479 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3480 * 1.Mandatory parameters are left unspecified; 3481 * 2.Incorrect parameter types. 3482 * @throws { BusinessError } 6800101 - Parameter verification failed. 3483 * @syscap SystemCapability.Multimedia.Audio.Device 3484 * @crossplatform 3485 * @since 12 3486 */ 3487 getDevicesSync(deviceFlag: DeviceFlag): AudioDeviceDescriptors; 3488 3489 /** 3490 * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive 3491 * the callback. 3492 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 3493 * @param { DeviceFlag } deviceFlag - Audio device flag. 3494 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3495 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3496 * 1.Mandatory parameters are left unspecified; 3497 * 2.Incorrect parameter types. 3498 * @throws { BusinessError } 6800101 - Parameter verification failed. 3499 * @syscap SystemCapability.Multimedia.Audio.Device 3500 * @since 9 3501 */ 3502 /** 3503 * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive 3504 * the callback. 3505 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 3506 * @param { DeviceFlag } deviceFlag - Audio device flag. 3507 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3508 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3509 * 1.Mandatory parameters are left unspecified; 3510 * 2.Incorrect parameter types. 3511 * @throws { BusinessError } 6800101 - Parameter verification failed. 3512 * @syscap SystemCapability.Multimedia.Audio.Device 3513 * @crossplatform 3514 * @since 12 3515 */ 3516 on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback<DeviceChangeAction>): void; 3517 3518 /** 3519 * UnSubscribes to device change events. 3520 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 3521 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3522 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3523 * 1.Mandatory parameters are left unspecified; 3524 * 2.Incorrect parameter types. 3525 * @throws { BusinessError } 6800101 - Parameter verification failed. 3526 * @syscap SystemCapability.Multimedia.Audio.Device 3527 * @since 9 3528 */ 3529 /** 3530 * UnSubscribes to device change events. 3531 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 3532 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3533 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3534 * 1.Mandatory parameters are left unspecified; 3535 * 2.Incorrect parameter types. 3536 * @throws { BusinessError } 6800101 - Parameter verification failed. 3537 * @syscap SystemCapability.Multimedia.Audio.Device 3538 * @crossplatform 3539 * @since 12 3540 */ 3541 off(type: 'deviceChange', callback?: Callback<DeviceChangeAction>): void; 3542 3543 /** 3544 * Obtains all the available audio devices with a specific device usage. 3545 * @param { DeviceUsage } deviceUsage - Audio device usage. 3546 * @returns { AudioDeviceDescriptors } The device list. 3547 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3548 * 1.Mandatory parameters are left unspecified; 3549 * 2.Incorrect parameter types. 3550 * @throws { BusinessError } 6800101 - Parameter verification failed. 3551 * @syscap SystemCapability.Multimedia.Audio.Device 3552 * @since 12 3553 */ 3554 getAvailableDevices(deviceUsage: DeviceUsage): AudioDeviceDescriptors; 3555 3556 /** 3557 * Subscribes to available device change events. When a device is connected/disconnected, registered clients will receive 3558 * the callback. 3559 * @param { 'availableDeviceChange' } type - Type of the event to listen for. Only the availableDeviceChange event is supported. 3560 * @param { DeviceUsage } deviceUsage - Audio device usage. 3561 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3562 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3563 * 1.Mandatory parameters are left unspecified; 3564 * 2.Incorrect parameter types. 3565 * @throws { BusinessError } 6800101 - Parameter verification failed. 3566 * @syscap SystemCapability.Multimedia.Audio.Device 3567 * @since 12 3568 */ 3569 on(type: 'availableDeviceChange', deviceUsage: DeviceUsage, callback: Callback<DeviceChangeAction>): void; 3570 3571 /** 3572 * UnSubscribes to available device change events. 3573 * @param { 'availableDeviceChange' } type - Type of the event to listen for. Only the availableDeviceChange event is supported. 3574 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 3575 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3576 * 1.Mandatory parameters are left unspecified; 3577 * 2.Incorrect parameter types. 3578 * @throws { BusinessError } 6800101 - Parameter verification failed. 3579 * @syscap SystemCapability.Multimedia.Audio.Device 3580 * @since 12 3581 */ 3582 off(type: 'availableDeviceChange', callback?: Callback<DeviceChangeAction>): void; 3583 3584 /** 3585 * Sets a device to the active state. This method uses an asynchronous callback to return the result. 3586 * @param { CommunicationDeviceType } deviceType - Audio device type. 3587 * @param { boolean } active - Active status to set. The value true means to set the device to 3588 * the active status, and false means the opposite. 3589 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3590 * @syscap SystemCapability.Multimedia.Audio.Communication 3591 * @since 9 3592 */ 3593 /** 3594 * Sets a device to the active state. Only the current calling application can be set to take effect. 3595 * This method uses an asynchronous callback to return the result. 3596 * @param { CommunicationDeviceType } deviceType - Audio device type. 3597 * @param { boolean } active - Active status to set. The value true means to set the device to 3598 * the active status, and false means the opposite. 3599 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3600 * @syscap SystemCapability.Multimedia.Audio.Communication 3601 * @crossplatform 3602 * @since 12 3603 */ 3604 setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean, callback: AsyncCallback<void>): void; 3605 /** 3606 * Sets a device to the active state. This method uses a promise to return the result. 3607 * @param { CommunicationDeviceType } deviceType - Audio device type. 3608 * @param { boolean } active - Active status to set. The value true means to set the device to the active status, 3609 * and false means the opposite. 3610 * @returns { Promise<void> } Promise used to return the result. 3611 * @syscap SystemCapability.Multimedia.Audio.Communication 3612 * @since 9 3613 */ 3614 /** 3615 * Sets a device to the active state. Only the current calling application can be set to take effect. 3616 * This method uses a promise to return the result. 3617 * @param { CommunicationDeviceType } deviceType - Audio device type. 3618 * @param { boolean } active - Active status to set. The value true means to set the device to the active status, 3619 * and false means the opposite. 3620 * @returns { Promise<void> } Promise used to return the result. 3621 * @syscap SystemCapability.Multimedia.Audio.Communication 3622 * @crossplatform 3623 * @since 12 3624 */ 3625 setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean): Promise<void>; 3626 3627 /** 3628 * Checks whether a device is active. This method uses an asynchronous callback to return the query result. 3629 * @param { CommunicationDeviceType } deviceType - Audio device type. 3630 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the device. 3631 * @syscap SystemCapability.Multimedia.Audio.Communication 3632 * @since 9 3633 */ 3634 /** 3635 * Checks whether a device is active. This method uses an asynchronous callback to return the query result. 3636 * @param { CommunicationDeviceType } deviceType - Audio device type. 3637 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the device. 3638 * @syscap SystemCapability.Multimedia.Audio.Communication 3639 * @crossplatform 3640 * @since 12 3641 */ 3642 isCommunicationDeviceActive(deviceType: CommunicationDeviceType, callback: AsyncCallback<boolean>): void; 3643 /** 3644 * Checks whether a device is active. This method uses a promise to return the query result. 3645 * @param { CommunicationDeviceType } deviceType - Audio device type. 3646 * @returns { Promise<boolean> } Promise used to return the active status of the device. 3647 * @syscap SystemCapability.Multimedia.Audio.Communication 3648 * @since 9 3649 */ 3650 /** 3651 * Checks whether a device is active. This method uses a promise to return the query result. 3652 * @param { CommunicationDeviceType } deviceType - Audio device type. 3653 * @returns { Promise<boolean> } Promise used to return the active status of the device. 3654 * @syscap SystemCapability.Multimedia.Audio.Communication 3655 * @crossplatform 3656 * @since 12 3657 */ 3658 isCommunicationDeviceActive(deviceType: CommunicationDeviceType): Promise<boolean>; 3659 /** 3660 * Checks whether a device is active. 3661 * @param { CommunicationDeviceType } deviceType - Audio device type. 3662 * @returns { boolean } The active status of the device. 3663 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3664 * 1.Mandatory parameters are left unspecified; 3665 * 2.Incorrect parameter types. 3666 * @throws { BusinessError } 6800101 - Parameter verification failed. 3667 * @syscap SystemCapability.Multimedia.Audio.Communication 3668 * @since 10 3669 */ 3670 /** 3671 * Checks whether a device is active. 3672 * @param { CommunicationDeviceType } deviceType - Audio device type. 3673 * @returns { boolean } The active status of the device. 3674 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3675 * 1.Mandatory parameters are left unspecified; 3676 * 2.Incorrect parameter types. 3677 * @throws { BusinessError } 6800101 - Parameter verification failed. 3678 * @syscap SystemCapability.Multimedia.Audio.Communication 3679 * @crossplatform 3680 * @since 12 3681 */ 3682 isCommunicationDeviceActiveSync(deviceType: CommunicationDeviceType): boolean; 3683 3684 /** 3685 * Select the output device. This method uses an asynchronous callback to return the result. 3686 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description 3687 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3688 * @syscap SystemCapability.Multimedia.Audio.Device 3689 * @systemapi 3690 * @since 9 3691 */ 3692 selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 3693 /** 3694 * Select the output device. This method uses a promise to return the result. 3695 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description 3696 * @returns { Promise<void> } Promise used to return the result. 3697 * @syscap SystemCapability.Multimedia.Audio.Device 3698 * @systemapi 3699 * @since 9 3700 */ 3701 selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void>; 3702 3703 /** 3704 * Select the output device with desired AudioRenderer. This method uses an asynchronous callback to return the result. 3705 * @param { AudioRendererFilter } filter - Filter for AudioRenderer. 3706 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description. 3707 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3708 * @syscap SystemCapability.Multimedia.Audio.Device 3709 * @systemapi 3710 * @since 9 3711 */ 3712 selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 3713 /** 3714 * Select the output device with desired AudioRenderer. This method uses a promise to return the result. 3715 * @param { AudioRendererFilter } filter - Filter for AudioRenderer. 3716 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description 3717 * @returns { Promise<void> } Promise used to return the result. 3718 * @syscap SystemCapability.Multimedia.Audio.Device 3719 * @systemapi 3720 * @since 9 3721 */ 3722 selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise<void>; 3723 3724 /** 3725 * Select the input device. This method uses an asynchronous callback to return the result. 3726 * @param { AudioDeviceDescriptors } inputAudioDevices - Audio device description 3727 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3728 * @syscap SystemCapability.Multimedia.Audio.Device 3729 * @systemapi 3730 * @since 9 3731 */ 3732 selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 3733 /** 3734 * Select the input device. This method uses a promise to return the result. 3735 * @param { AudioDeviceDescriptors } inputAudioDevices - Audio device description 3736 * @returns { Promise<void> } Promise used to return the result. 3737 * @syscap SystemCapability.Multimedia.Audio.Device 3738 * @systemapi 3739 * @since 9 3740 */ 3741 selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void>; 3742 3743 /** 3744 * Select the input device with desired AudioCapturer. This method uses a promise to return the result. 3745 * @param { AudioCapturerFilter } filter - Filter for AudioCapturer. 3746 * @param { AudioDeviceDescriptors } inputAudioDevices - Audio device descriptions 3747 * @returns { Promise<void> } Promise used to return the result. 3748 * @throws { BusinessError } 202 - Not system App. 3749 * @throws { BusinessError } 6800101 - Parameter verification failed. 3750 * @syscap SystemCapability.Multimedia.Audio.Device 3751 * @systemapi 3752 * @since 18 3753 */ 3754 selectInputDeviceByFilter(filter: AudioCapturerFilter, inputAudioDevices: AudioDeviceDescriptors): Promise<void>; 3755 3756 /** 3757 * Get output device for target audio renderer info. 3758 * @param { AudioRendererInfo } rendererInfo - Audio renderer information 3759 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 3760 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3761 * 1.Mandatory parameters are left unspecified; 3762 * 2.Incorrect parameter types. 3763 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 3764 * @throws { BusinessError } 6800301 - System error. Return by callback. 3765 * @syscap SystemCapability.Multimedia.Audio.Device 3766 * @since 10 3767 */ 3768 /** 3769 * Get output device for target audio renderer info. 3770 * @param { AudioRendererInfo } rendererInfo - Audio renderer information 3771 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 3772 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3773 * 1.Mandatory parameters are left unspecified; 3774 * 2.Incorrect parameter types. 3775 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 3776 * @throws { BusinessError } 6800301 - System error. Return by callback. 3777 * @syscap SystemCapability.Multimedia.Audio.Device 3778 * @crossplatform 3779 * @since 12 3780 */ 3781 getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo, callback: AsyncCallback<AudioDeviceDescriptors>): void; 3782 /** 3783 * Get output device for target audio renderer info. 3784 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 3785 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 3786 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3787 * 1.Mandatory parameters are left unspecified; 3788 * 2.Incorrect parameter types. 3789 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 3790 * @throws { BusinessError } 6800301 - System error. Return by promise. 3791 * @syscap SystemCapability.Multimedia.Audio.Device 3792 * @since 10 3793 */ 3794 /** 3795 * Get output device for target audio renderer info. 3796 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 3797 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 3798 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3799 * 1.Mandatory parameters are left unspecified; 3800 * 2.Incorrect parameter types. 3801 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 3802 * @throws { BusinessError } 6800301 - System error. Return by promise. 3803 * @syscap SystemCapability.Multimedia.Audio.Device 3804 * @crossplatform 3805 * @since 12 3806 */ 3807 getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo): Promise<AudioDeviceDescriptors>; 3808 3809 /** 3810 * Gets preferred output device for target audio renderer info. 3811 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 3812 * @returns { AudioDeviceDescriptors } The preferred devices. 3813 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3814 * 1.Mandatory parameters are left unspecified; 3815 * 2.Incorrect parameter types. 3816 * @throws { BusinessError } 6800101 - Parameter verification failed. 3817 * @syscap SystemCapability.Multimedia.Audio.Device 3818 * @since 10 3819 */ 3820 /** 3821 * Gets preferred output device for target audio renderer info. 3822 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 3823 * @returns { AudioDeviceDescriptors } The preferred devices. 3824 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3825 * 1.Mandatory parameters are left unspecified; 3826 * 2.Incorrect parameter types. 3827 * @throws { BusinessError } 6800101 - Parameter verification failed. 3828 * @syscap SystemCapability.Multimedia.Audio.Device 3829 * @crossplatform 3830 * @since 12 3831 */ 3832 getPreferredOutputDeviceForRendererInfoSync(rendererInfo: AudioRendererInfo): AudioDeviceDescriptors; 3833 3834 /** 3835 * Get the preferred output devices by the target audio renderer filter. 3836 * @param { AudioRendererFilter } filter - Audio renderer filter. 3837 * @returns { AudioDeviceDescriptors } The preferred devices. 3838 * @throws { BusinessError } 202 - Not system App. 3839 * @throws { BusinessError } 6800101 - Parameter verification failed. 3840 * @syscap SystemCapability.Multimedia.Audio.Device 3841 * @systemapi 3842 * @since 18 3843 */ 3844 getPreferredOutputDeviceByFilter(filter: AudioRendererFilter): AudioDeviceDescriptors; 3845 3846 /** 3847 * Subscribes to prefer output device change events. When prefer device for target audio renderer info changes, 3848 * registered clients will receive the callback. 3849 * @param { 'preferOutputDeviceChangeForRendererInfo' } type - Type of the event to listen for. Only the 3850 * preferOutputDeviceChangeForRendererInfo event is supported. 3851 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 3852 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed prefer devices information. 3853 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3854 * 1.Mandatory parameters are left unspecified; 3855 * 2.Incorrect parameter types. 3856 * @throws { BusinessError } 6800101 - Parameter verification failed. 3857 * @syscap SystemCapability.Multimedia.Audio.Device 3858 * @since 10 3859 */ 3860 /** 3861 * Subscribes to prefer output device change events. When prefer device for target audio renderer info changes, 3862 * registered clients will receive the callback. 3863 * @param { 'preferOutputDeviceChangeForRendererInfo' } type - Type of the event to listen for. Only the 3864 * preferOutputDeviceChangeForRendererInfo event is supported. 3865 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 3866 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed prefer devices information. 3867 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3868 * 1.Mandatory parameters are left unspecified; 3869 * 2.Incorrect parameter types. 3870 * @throws { BusinessError } 6800101 - Parameter verification failed. 3871 * @syscap SystemCapability.Multimedia.Audio.Device 3872 * @crossplatform 3873 * @since 12 3874 */ 3875 on(type: 'preferOutputDeviceChangeForRendererInfo', rendererInfo: AudioRendererInfo, callback: Callback<AudioDeviceDescriptors>): void; 3876 /** 3877 * UnSubscribes to prefer output device change events. 3878 * @param { 'preferOutputDeviceChangeForRendererInfo' } type - Type of the event to listen for. Only the 3879 * preferOutputDeviceChangeForRendererInfo event is supported. 3880 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed prefer devices in subscribe. 3881 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3882 * 1.Mandatory parameters are left unspecified; 3883 * 2.Incorrect parameter types. 3884 * @throws { BusinessError } 6800101 - Parameter verification failed. 3885 * @syscap SystemCapability.Multimedia.Audio.Device 3886 * @since 10 3887 */ 3888 /** 3889 * UnSubscribes to prefer output device change events. 3890 * @param { 'preferOutputDeviceChangeForRendererInfo' } type - Type of the event to listen for. Only the 3891 * preferOutputDeviceChangeForRendererInfo event is supported. 3892 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed prefer devices in subscribe. 3893 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3894 * 1.Mandatory parameters are left unspecified; 3895 * 2.Incorrect parameter types. 3896 * @throws { BusinessError } 6800101 - Parameter verification failed. 3897 * @syscap SystemCapability.Multimedia.Audio.Device 3898 * @crossplatform 3899 * @since 12 3900 */ 3901 off(type: 'preferOutputDeviceChangeForRendererInfo', callback?: Callback<AudioDeviceDescriptors>): void; 3902 3903 /** 3904 * Get input device for target audio capturer info. 3905 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 3906 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 3907 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3908 * 1.Mandatory parameters are left unspecified; 3909 * 2.Incorrect parameter types. 3910 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 3911 * @throws { BusinessError } 6800301 - System error. Return by callback. 3912 * @syscap SystemCapability.Multimedia.Audio.Device 3913 * @since 10 3914 */ 3915 /** 3916 * Get input device for target audio capturer info. 3917 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 3918 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 3919 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3920 * 1.Mandatory parameters are left unspecified; 3921 * 2.Incorrect parameter types. 3922 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 3923 * @throws { BusinessError } 6800301 - System error. Return by callback. 3924 * @syscap SystemCapability.Multimedia.Audio.Device 3925 * @crossplatform 3926 * @since 12 3927 */ 3928 getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo, callback: AsyncCallback<AudioDeviceDescriptors>): void; 3929 /** 3930 * Get input device for target audio capturer info. 3931 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 3932 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 3933 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3934 * 1.Mandatory parameters are left unspecified; 3935 * 2.Incorrect parameter types. 3936 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 3937 * @throws { BusinessError } 6800301 - System error. Return by promise. 3938 * @syscap SystemCapability.Multimedia.Audio.Device 3939 * @since 10 3940 */ 3941 /** 3942 * Get input device for target audio capturer info. 3943 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 3944 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 3945 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3946 * 1.Mandatory parameters are left unspecified; 3947 * 2.Incorrect parameter types. 3948 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 3949 * @throws { BusinessError } 6800301 - System error. Return by promise. 3950 * @syscap SystemCapability.Multimedia.Audio.Device 3951 * @crossplatform 3952 * @since 12 3953 */ 3954 getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo): Promise<AudioDeviceDescriptors>; 3955 3956 /** 3957 * Get the preferred input device for the target audio capturer filter. 3958 * @param { AudioCapturerFilter } filter - Audio capturer filter. 3959 * @returns { AudioDeviceDescriptors } The preferred devices. 3960 * @throws { BusinessError } 202 - Not system App. 3961 * @throws { BusinessError } 6800101 - Parameter verification failed. 3962 * @syscap SystemCapability.Multimedia.Audio.Device 3963 * @systemapi 3964 * @since 18 3965 */ 3966 getPreferredInputDeviceByFilter(filter: AudioCapturerFilter): AudioDeviceDescriptors; 3967 3968 /** 3969 * Subscribes to preferred input device change events. When preferred device for target audio capturer info changes, 3970 * registered clients will receive the callback. 3971 * @param { 'preferredInputDeviceChangeForCapturerInfo' } type - Type of the event to listen for. 3972 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 3973 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed preferred devices information. 3974 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3975 * 1.Mandatory parameters are left unspecified; 3976 * 2.Incorrect parameter types. 3977 * @throws { BusinessError } 6800101 - Parameter verification failed. 3978 * @syscap SystemCapability.Multimedia.Audio.Device 3979 * @since 10 3980 */ 3981 /** 3982 * Subscribes to preferred input device change events. When preferred device for target audio capturer info changes, 3983 * registered clients will receive the callback. 3984 * @param { 'preferredInputDeviceChangeForCapturerInfo' } type - Type of the event to listen for. 3985 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 3986 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed preferred devices information. 3987 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3988 * 1.Mandatory parameters are left unspecified; 3989 * 2.Incorrect parameter types. 3990 * @throws { BusinessError } 6800101 - Parameter verification failed. 3991 * @syscap SystemCapability.Multimedia.Audio.Device 3992 * @crossplatform 3993 * @since 12 3994 */ 3995 on(type: 'preferredInputDeviceChangeForCapturerInfo', capturerInfo: AudioCapturerInfo, callback: Callback<AudioDeviceDescriptors>): void; 3996 /** 3997 * Unsubscribes to preferred input device change events. 3998 * @param { 'preferredInputDeviceChangeForCapturerInfo' } type - Type of the event to listen for. 3999 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed preferred devices in subscribe. 4000 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4001 * 1.Mandatory parameters are left unspecified; 4002 * 2.Incorrect parameter types. 4003 * @throws { BusinessError } 6800101 - Parameter verification failed. 4004 * @syscap SystemCapability.Multimedia.Audio.Device 4005 * @since 10 4006 */ 4007 /** 4008 * Unsubscribes to preferred input device change events. 4009 * @param { 'preferredInputDeviceChangeForCapturerInfo' } type - Type of the event to listen for. 4010 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed preferred devices in subscribe. 4011 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4012 * 1.Mandatory parameters are left unspecified; 4013 * 2.Incorrect parameter types. 4014 * @throws { BusinessError } 6800101 - Parameter verification failed. 4015 * @syscap SystemCapability.Multimedia.Audio.Device 4016 * @crossplatform 4017 * @since 12 4018 */ 4019 off(type: 'preferredInputDeviceChangeForCapturerInfo', callback?: Callback<AudioDeviceDescriptors>): void; 4020 4021 /** 4022 * Gets preferred input device for target audio capturer info. 4023 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 4024 * @returns { AudioDeviceDescriptors } The preferred devices. 4025 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4026 * 1.Mandatory parameters are left unspecified; 4027 * 2.Incorrect parameter types. 4028 * @throws { BusinessError } 6800101 - Parameter verification failed. 4029 * @syscap SystemCapability.Multimedia.Audio.Device 4030 * @since 10 4031 */ 4032 /** 4033 * Gets preferred input device for target audio capturer info. 4034 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 4035 * @returns { AudioDeviceDescriptors } The preferred devices. 4036 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4037 * 1.Mandatory parameters are left unspecified; 4038 * 2.Incorrect parameter types. 4039 * @throws { BusinessError } 6800101 - Parameter verification failed. 4040 * @syscap SystemCapability.Multimedia.Audio.Device 4041 * @crossplatform 4042 * @since 12 4043 */ 4044 getPreferredInputDeviceForCapturerInfoSync(capturerInfo: AudioCapturerInfo): AudioDeviceDescriptors; 4045 4046 /** 4047 * Query whether microphone block detection is supported on current device. 4048 * @returns { Promise<boolean> } Promise used to return the result. 4049 * @syscap SystemCapability.Multimedia.Audio.Device 4050 * @since 13 4051 */ 4052 isMicBlockDetectionSupported():Promise<boolean>; 4053 4054 /** 4055 * Subscribes microphone blocked events. Before subscribing, users should query whether block detection is supported 4056 * on current device. The caller will receive the callback only when it is recording and the used 4057 * microphones' block status have changed. Currently, block detecting is only support for microphones located on 4058 * the local device. 4059 * @param { 'micBlockStatusChanged' } type - Type of the event to listen for. 4060 * @param { Callback<DeviceBlockStatusInfo> } callback - Callback used to obtain the microphone block status. 4061 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4062 * 1.Mandatory parameters are left unspecified; 4063 * 2.Incorrect parameter types. 4064 * @throws { BusinessError } 6800101 - Parameter verification failed. 4065 * @syscap SystemCapability.Multimedia.Audio.Device 4066 * @since 13 4067 */ 4068 on(type: 'micBlockStatusChanged', callback: Callback<DeviceBlockStatusInfo>): void; 4069 4070 /** 4071 * Unsubscribes microphone blocked events. 4072 * @param { 'microphoneBlockStatusChanged' } type - Type of the event to listen for. 4073 * @param { Callback<DeviceBlockStatusInfo> } callback - Callback used to obtain the microphone block status. 4074 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4075 * 1.Mandatory parameters are left unspecified; 4076 * 2.Incorrect parameter types. 4077 * @throws { BusinessError } 6800101 - Parameter verification failed. 4078 * @syscap SystemCapability.Multimedia.Audio.Device 4079 * @since 13 4080 */ 4081 off(type: 'micBlockStatusChanged', callback?: Callback<DeviceBlockStatusInfo>): void; 4082 4083 /** 4084 * Exclude output devices. After calling this function successfully, audio will not be played on the specified 4085 * devices. Note that only the external ouput device can be excluded by this function. Local output devices is not 4086 * accepted. 4087 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 4088 * @param { DeviceUsage } usage - Device usage, only output device usages can be accepted. 4089 * @param { AudioDeviceDescriptors } devices - The devices to be excluded. 4090 * @returns { Promise<void> } Promise used to return result. 4091 * @throws { BusinessError } 201 - Permisson denied. 4092 * @throws { BusinessError } 202 - Not system application. 4093 * @throws { BusinessError } 6800101 - Parameter verification failed. 4094 * @syscap SystemCapability.Multimedia.Audio.Device 4095 * @systemapi 4096 * @since 18 4097 */ 4098 excludeOutputDevices(usage: DeviceUsage, devices: AudioDeviceDescriptors): Promise<void>; 4099 4100 /** 4101 * Unexclude output devices. 4102 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 4103 * @param { DeviceUsage } usage - Device usage, only output device usages can be accepted. 4104 * @param { AudioDeviceDescriptors } devices - The devices to be unexcluded. 4105 * @returns { Promise<void> } Promise used to return result. 4106 * @throws { BusinessError } 201 - Permisson denied. 4107 * @throws { BusinessError } 202 - Not system application. 4108 * @throws { BusinessError } 6800101 - Parameter verification failed. 4109 * @syscap SystemCapability.Multimedia.Audio.Device 4110 * @systemapi 4111 * @since 18 4112 */ 4113 unexcludeOutputDevices(usage: DeviceUsage, devices: AudioDeviceDescriptors): Promise<void>; 4114 4115 /** 4116 * Unexclude output devices. This function will unexclude all output devices belong to specific usage. 4117 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 4118 * @param { DeviceUsage } usage - Device usage, only output device usages can be accepted. 4119 * @returns { Promise<void> } Promise used to return result. 4120 * @throws { BusinessError } 201 - Permisson denied. 4121 * @throws { BusinessError } 202 - Not system application. 4122 * @throws { BusinessError } 6800101 - Parameter verification failed. 4123 * @syscap SystemCapability.Multimedia.Audio.Device 4124 * @systemapi 4125 * @since 18 4126 */ 4127 unexcludeOutputDevices(usage: DeviceUsage): Promise<void>; 4128 4129 /** 4130 * Get excluded devices by filter. 4131 * @param { DeviceUsage } usage - Device usage, only output device usages can be accepted. 4132 * @returns { AudioDeviceDescriptors } Exclueded devices. 4133 * @throws { BusinessError } 202 - Not system application. 4134 * @throws { BusinessError } 6800101 - Parameter verification failed. 4135 * @syscap SystemCapability.Multimedia.Audio.Device 4136 * @systemapi 4137 * @since 18 4138 */ 4139 getExcludedDevices(usage: DeviceUsage): AudioDeviceDescriptors; 4140 } 4141 4142 /** 4143 * Implements audio stream management. 4144 * @typedef AudioStreamManager 4145 * @syscap SystemCapability.Multimedia.Audio.Core 4146 * @since 9 4147 */ 4148 /** 4149 * Implements audio stream management. 4150 * @typedef AudioStreamManager 4151 * @syscap SystemCapability.Multimedia.Audio.Core 4152 * @crossplatform 4153 * @since 12 4154 */ 4155 interface AudioStreamManager { 4156 /** 4157 * Get information of current existing audio renderers. 4158 * @param { AsyncCallback<AudioRendererChangeInfoArray> } callback - Callback used to return the information 4159 * of current existing audio renderers. 4160 * @syscap SystemCapability.Multimedia.Audio.Renderer 4161 * @since 9 4162 */ 4163 /** 4164 * Get information of current existing audio renderers. 4165 * @param { AsyncCallback<AudioRendererChangeInfoArray> } callback - Callback used to return the information 4166 * of current existing audio renderers. 4167 * @syscap SystemCapability.Multimedia.Audio.Renderer 4168 * @crossplatform 4169 * @since 12 4170 */ 4171 getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeInfoArray>): void; 4172 4173 /** 4174 * Get information of current existing audio renderers. 4175 * @returns { Promise<AudioRendererChangeInfoArray> } Promise used to return the information of current 4176 * existing audio renderers. 4177 * @syscap SystemCapability.Multimedia.Audio.Renderer 4178 * @since 9 4179 */ 4180 /** 4181 * Get information of current existing audio renderers. 4182 * @returns { Promise<AudioRendererChangeInfoArray> } Promise used to return the information of current 4183 * existing audio renderers. 4184 * @syscap SystemCapability.Multimedia.Audio.Renderer 4185 * @crossplatform 4186 * @since 12 4187 */ 4188 getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray>; 4189 4190 /** 4191 * Get information of current existing audio renderers. 4192 * @returns { AudioRendererChangeInfoArray } The information of current existing audio renderers. 4193 * @syscap SystemCapability.Multimedia.Audio.Renderer 4194 * @since 10 4195 */ 4196 /** 4197 * Get information of current existing audio renderers. 4198 * @returns { AudioRendererChangeInfoArray } The information of current existing audio renderers. 4199 * @syscap SystemCapability.Multimedia.Audio.Renderer 4200 * @crossplatform 4201 * @since 12 4202 */ 4203 getCurrentAudioRendererInfoArraySync(): AudioRendererChangeInfoArray; 4204 4205 /** 4206 * Get information of current existing audio capturers. 4207 * @param { AsyncCallback<AudioCapturerChangeInfoArray> } callback - Callback used to return the information 4208 * of current existing audio capturers. 4209 * @syscap SystemCapability.Multimedia.Audio.Renderer 4210 * @since 9 4211 */ 4212 /** 4213 * Get information of current existing audio capturers. 4214 * @param { AsyncCallback<AudioCapturerChangeInfoArray> } callback - Callback used to return the information 4215 * of current existing audio capturers. 4216 * @syscap SystemCapability.Multimedia.Audio.Renderer 4217 * @crossplatform 4218 * @since 12 4219 */ 4220 getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeInfoArray>): void; 4221 4222 /** 4223 * Get information of current existing audio capturers. 4224 * @returns { Promise<AudioCapturerChangeInfoArray> } Promise used to return the information of current existing 4225 * audio capturers. 4226 * @syscap SystemCapability.Multimedia.Audio.Renderer 4227 * @since 9 4228 */ 4229 /** 4230 * Get information of current existing audio capturers. 4231 * @returns { Promise<AudioCapturerChangeInfoArray> } Promise used to return the information of current existing 4232 * audio capturers. 4233 * @syscap SystemCapability.Multimedia.Audio.Renderer 4234 * @crossplatform 4235 * @since 12 4236 */ 4237 getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray>; 4238 4239 /** 4240 * Get information of current existing audio capturers. 4241 * @returns { AudioCapturerChangeInfoArray } The information of current existing audio capturers. 4242 * @syscap SystemCapability.Multimedia.Audio.Capturer 4243 * @since 10 4244 */ 4245 /** 4246 * Get information of current existing audio capturers. 4247 * @returns { AudioCapturerChangeInfoArray } The information of current existing audio capturers. 4248 * @syscap SystemCapability.Multimedia.Audio.Capturer 4249 * @crossplatform 4250 * @since 12 4251 */ 4252 getCurrentAudioCapturerInfoArraySync(): AudioCapturerChangeInfoArray; 4253 4254 /** 4255 * Gets information of audio effects. 4256 * @param { StreamUsage } usage - Stream usage. 4257 * @param { AsyncCallback<AudioEffectInfoArray> } callback - Callback used to return the information of audio effects. 4258 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4259 * 1.Mandatory parameters are left unspecified; 4260 * 2.Incorrect parameter types. 4261 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 4262 * @syscap SystemCapability.Multimedia.Audio.Renderer 4263 * @since 10 4264 */ 4265 getAudioEffectInfoArray(usage: StreamUsage, callback: AsyncCallback<AudioEffectInfoArray>): void; 4266 4267 /** 4268 * Gets information of audio effects. 4269 * @param { StreamUsage } usage - Stream usage. 4270 * @returns { Promise<AudioEffectInfoArray> } Promise used to return the information of audio effects. 4271 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4272 * 1.Mandatory parameters are left unspecified; 4273 * 2.Incorrect parameter types. 4274 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 4275 * @syscap SystemCapability.Multimedia.Audio.Renderer 4276 * @since 10 4277 */ 4278 getAudioEffectInfoArray(usage: StreamUsage): Promise<AudioEffectInfoArray>; 4279 4280 /** 4281 * Gets information of audio effects. 4282 * @param { StreamUsage } usage - Stream usage. 4283 * @returns { AudioEffectInfoArray } The information of audio effects. 4284 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4285 * 1.Mandatory parameters are left unspecified; 4286 * 2.Incorrect parameter types. 4287 * @throws { BusinessError } 6800101 - Parameter verification failed. 4288 * @syscap SystemCapability.Multimedia.Audio.Renderer 4289 * @since 10 4290 */ 4291 getAudioEffectInfoArraySync(usage: StreamUsage): AudioEffectInfoArray; 4292 4293 /** 4294 * Listens for audio renderer change events. When there is any audio renderer change, 4295 * registered clients will receive the callback. 4296 * @param { 'audioRendererChange' } type - Type of the event to listen for. Only the audioRendererChange event is supported. 4297 * @param { Callback<AudioRendererChangeInfoArray> } callback - Callback invoked for the audio renderer change event. 4298 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4299 * 1.Mandatory parameters are left unspecified; 4300 * 2.Incorrect parameter types. 4301 * @throws { BusinessError } 6800101 - Parameter verification failed. 4302 * @syscap SystemCapability.Multimedia.Audio.Renderer 4303 * @since 9 4304 */ 4305 /** 4306 * Listens for audio renderer change events. When there is any audio renderer change, 4307 * registered clients will receive the callback. 4308 * @param { 'audioRendererChange' } type - Type of the event to listen for. Only the audioRendererChange event is supported. 4309 * @param { Callback<AudioRendererChangeInfoArray> } callback - Callback invoked for the audio renderer change event. 4310 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4311 * 1.Mandatory parameters are left unspecified; 4312 * 2.Incorrect parameter types. 4313 * @throws { BusinessError } 6800101 - Parameter verification failed. 4314 * @syscap SystemCapability.Multimedia.Audio.Renderer 4315 * @crossplatform 4316 * @since 12 4317 */ 4318 on(type: 'audioRendererChange', callback: Callback<AudioRendererChangeInfoArray>): void; 4319 4320 /** 4321 * UnSubscribes to audio renderer change events. 4322 * @param { 'audioRendererChange' } type - Type of the event to listen for. Only the audioRendererChange event is supported. 4323 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4324 * 1.Mandatory parameters are left unspecified; 4325 * 2.Incorrect parameter types. 4326 * @throws { BusinessError } 6800101 - Parameter verification failed. 4327 * @syscap SystemCapability.Multimedia.Audio.Renderer 4328 * @since 9 4329 */ 4330 /** 4331 * UnSubscribes to audio renderer change events. 4332 * @param { 'audioRendererChange' } type - Type of the event to listen for. Only the audioRendererChange event is supported. 4333 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4334 * 1.Mandatory parameters are left unspecified; 4335 * 2.Incorrect parameter types. 4336 * @throws { BusinessError } 6800101 - Parameter verification failed. 4337 * @syscap SystemCapability.Multimedia.Audio.Renderer 4338 * @crossplatform 4339 * @since 12 4340 */ 4341 /** 4342 * Unsubscribes to audio renderer change events. 4343 * @param { 'audioRendererChange' } type - Type of the event to listen for. Only the audioRendererChange event is supported. 4344 * @param { Callback<AudioRendererChangeInfoArray> } callback - Callback invoked for the audio renderer change event. 4345 * @throws { BusinessError } 6800101 - Parameter verification failed. 4346 * @syscap SystemCapability.Multimedia.Audio.Renderer 4347 * @crossplatform 4348 * @since 18 4349 */ 4350 off(type: 'audioRendererChange', callback?: Callback<AudioRendererChangeInfoArray>): void; 4351 4352 /** 4353 * Listens for audio capturer change events. When there is any audio capturer change, 4354 * registered clients will receive the callback. 4355 * @param { 'audioCapturerChange' } type - Type of the event to listen for. Only the audioCapturerChange event is supported. 4356 * @param { Callback<AudioCapturerChangeInfoArray> } callback - Callback invoked for the audio capturer change event. 4357 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4358 * 1.Mandatory parameters are left unspecified; 4359 * 2.Incorrect parameter types. 4360 * @throws { BusinessError } 6800101 - Parameter verification failed. 4361 * @syscap SystemCapability.Multimedia.Audio.Capturer 4362 * @since 9 4363 */ 4364 /** 4365 * Listens for audio capturer change events. When there is any audio capturer change, 4366 * registered clients will receive the callback. 4367 * @param { 'audioCapturerChange' } type - Type of the event to listen for. Only the audioCapturerChange event is supported. 4368 * @param { Callback<AudioCapturerChangeInfoArray> } callback - Callback invoked for the audio capturer change event. 4369 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4370 * 1.Mandatory parameters are left unspecified; 4371 * 2.Incorrect parameter types. 4372 * @throws { BusinessError } 6800101 - Parameter verification failed. 4373 * @syscap SystemCapability.Multimedia.Audio.Capturer 4374 * @crossplatform 4375 * @since 12 4376 */ 4377 on(type: 'audioCapturerChange', callback: Callback<AudioCapturerChangeInfoArray>): void; 4378 4379 /** 4380 * UnSubscribes to audio capturer change events. 4381 * @param { 'audioCapturerChange' } type - Type of the event to listen for. Only the audioCapturerChange event is supported. 4382 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4383 * 1.Mandatory parameters are left unspecified; 4384 * 2.Incorrect parameter types. 4385 * @throws { BusinessError } 6800101 - Parameter verification failed. 4386 * @syscap SystemCapability.Multimedia.Audio.Capturer 4387 * @since 9 4388 */ 4389 /** 4390 * UnSubscribes to audio capturer change events. 4391 * @param { 'audioCapturerChange' } type - Type of the event to listen for. Only the audioCapturerChange event is supported. 4392 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4393 * 1.Mandatory parameters are left unspecified; 4394 * 2.Incorrect parameter types. 4395 * @throws { BusinessError } 6800101 - Parameter verification failed. 4396 * @syscap SystemCapability.Multimedia.Audio.Capturer 4397 * @crossplatform 4398 * @since 12 4399 */ 4400 /** 4401 * Unsubscribes to audio capturer change events. 4402 * @param { 'audioCapturerChange' } type - Type of the event to listen for. Only the audioCapturerChange event is supported. 4403 * @param { Callback<AudioCapturerChangeInfoArray> } callback - Callback invoked for the audio capturer change event. 4404 * @throws { BusinessError } 6800101 - Parameter verification failed. 4405 * @syscap SystemCapability.Multimedia.Audio.Capturer 4406 * @crossplatform 4407 * @since 18 4408 */ 4409 off(type: 'audioCapturerChange', callback?: Callback<AudioCapturerChangeInfoArray>): void; 4410 4411 /** 4412 * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. 4413 * @param { AudioVolumeType } volumeType - Audio stream type. 4414 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the stream. 4415 * The value true means that the stream is active, and false means the opposite. 4416 * @syscap SystemCapability.Multimedia.Audio.Renderer 4417 * @since 9 4418 */ 4419 /** 4420 * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. 4421 * @param { AudioVolumeType } volumeType - Audio stream type. 4422 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the stream. 4423 * The value true means that the stream is active, and false means the opposite. 4424 * @syscap SystemCapability.Multimedia.Audio.Renderer 4425 * @crossplatform 4426 * @since 12 4427 * @deprecated since 20 4428 * @useinstead ohos.multimedia.audio.AudioStreamManager#isStreamActive 4429 */ 4430 isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 4431 /** 4432 * Checks whether a stream is active. This method uses a promise to return the query result. 4433 * @param { AudioVolumeType } volumeType - Audio stream type. 4434 * @returns { Promise<boolean> } Promise used to return the active status of the stream. The value 4435 * true means that the stream is active, and false means the opposite. 4436 * @syscap SystemCapability.Multimedia.Audio.Renderer 4437 * @since 9 4438 */ 4439 /** 4440 * Checks whether a stream is active. This method uses a promise to return the query result. 4441 * @param { AudioVolumeType } volumeType - Audio stream type. 4442 * @returns { Promise<boolean> } Promise used to return the active status of the stream. The value 4443 * true means that the stream is active, and false means the opposite. 4444 * @syscap SystemCapability.Multimedia.Audio.Renderer 4445 * @crossplatform 4446 * @since 12 4447 * @deprecated since 20 4448 * @useinstead ohos.multimedia.audio.AudioStreamManager#isStreamActive 4449 */ 4450 isActive(volumeType: AudioVolumeType): Promise<boolean>; 4451 /** 4452 * Checks whether a stream is active. 4453 * @param { AudioVolumeType } volumeType - Audio stream type. 4454 * @returns { boolean } The active status of the stream. 4455 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4456 * 1.Mandatory parameters are left unspecified; 4457 * 2.Incorrect parameter types. 4458 * @throws { BusinessError } 6800101 - Parameter verification failed. 4459 * @syscap SystemCapability.Multimedia.Audio.Renderer 4460 * @since 10 4461 */ 4462 /** 4463 * Checks whether a stream is active. 4464 * @param { AudioVolumeType } volumeType - Audio stream type. 4465 * @returns { boolean } The active status of the stream. 4466 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4467 * 1.Mandatory parameters are left unspecified; 4468 * 2.Incorrect parameter types. 4469 * @throws { BusinessError } 6800101 - Parameter verification failed. 4470 * @syscap SystemCapability.Multimedia.Audio.Renderer 4471 * @crossplatform 4472 * @since 12 4473 * @deprecated since 20 4474 * @useinstead ohos.multimedia.audio.AudioStreamManager#isStreamActive 4475 */ 4476 isActiveSync(volumeType: AudioVolumeType): boolean; 4477 4478 /** 4479 * Checks whether a stream is active. 4480 * @param { StreamUsage } streamUsage - Audio stream type. 4481 * @returns { boolean } The active status of the stream. 4482 * @throws { BusinessError } 6800101 - Parameter verification failed. 4483 * @syscap SystemCapability.Multimedia.Audio.Renderer 4484 * @since 20 4485 */ 4486 isStreamActive(streamUsage: StreamUsage): boolean; 4487 /** 4488 * Checks whether the specified audio source type supports echo cancellation 4489 * @param { SourceType } sourceType Type of audio source. 4490 * @returns { boolean } Check result. The value <b>true</b> means that the audio source type supports echo 4491 * cancellation, and <b>false</b> means the opposite. 4492 * @throws { BusinessError } 6800101 - Parameter verification failed. 4493 * @syscap SystemCapability.Multimedia.Audio.Capturer 4494 * @since 20 4495 */ 4496 isAcousticEchoCancelerSupported(sourceType: SourceType): boolean; 4497 4498 /** 4499 * Checks whether the current platform supports audio loopback. 4500 * @param { AudioLoopbackMode } mode Audio loopback mode. 4501 * @returns { boolean } Check result. The value <b>true</b> means that the current platform supports audio loopback, 4502 * and <b>false</b> means the opposite. 4503 * @throws { BusinessError } 6800101 - Parameter verification failed. 4504 * @syscap SystemCapability.Multimedia.Audio.Capturer 4505 * @since 20 4506 */ 4507 isAudioLoopbackSupported(mode: AudioLoopbackMode): boolean; 4508 4509 /** 4510 * Checks whether the audio recording for specific capturer info can start. 4511 * Usually this function will be used before audio recording start, because 4512 * other existing recording stream may deny it. 4513 * @param { AudioCapturerInfo } capturerInfo - Audio capturer infomation used in creation. 4514 * @returns { boolean } Value <true> means audio recording can start. 4515 * @throws { BusinessError } 6800101 - Parameter verification failed. 4516 * @syscap SystemCapability.Multimedia.Audio.Capturer 4517 * @since 20 4518 */ 4519 isRecordingAvailable(capturerInfo: AudioCapturerInfo): boolean; 4520 } 4521 4522 /** 4523 * Audio concurrency mode. 4524 * @enum { number } 4525 * @syscap SystemCapability.Multimedia.Audio.Core 4526 * @crossplatform 4527 * @since 12 4528 */ 4529 enum AudioConcurrencyMode { 4530 /** 4531 * Default concurrency mode. 4532 * @syscap SystemCapability.Multimedia.Audio.Core 4533 * @crossplatform 4534 * @since 12 4535 */ 4536 CONCURRENCY_DEFAULT = 0, 4537 /** 4538 * Mix with others mode. 4539 * @syscap SystemCapability.Multimedia.Audio.Core 4540 * @crossplatform 4541 * @since 12 4542 */ 4543 CONCURRENCY_MIX_WITH_OTHERS = 1, 4544 /** 4545 * Duck others mode. 4546 * @syscap SystemCapability.Multimedia.Audio.Core 4547 * @crossplatform 4548 * @since 12 4549 */ 4550 CONCURRENCY_DUCK_OTHERS = 2, 4551 /** 4552 * Pause others mode. 4553 * @syscap SystemCapability.Multimedia.Audio.Core 4554 * @crossplatform 4555 * @since 12 4556 */ 4557 CONCURRENCY_PAUSE_OTHERS = 3, 4558 } 4559 4560 /** 4561 * Audio session deactivated reason. 4562 * @enum { number } 4563 * @syscap SystemCapability.Multimedia.Audio.Core 4564 * @crossplatform 4565 * @since 12 4566 */ 4567 enum AudioSessionDeactivatedReason { 4568 /** 4569 * Lower priority. 4570 * @syscap SystemCapability.Multimedia.Audio.Core 4571 * @crossplatform 4572 * @since 12 4573 */ 4574 DEACTIVATED_LOWER_PRIORITY = 0, 4575 /** 4576 * Time out. 4577 * @syscap SystemCapability.Multimedia.Audio.Core 4578 * @crossplatform 4579 * @since 12 4580 */ 4581 DEACTIVATED_TIMEOUT = 1, 4582 } 4583 4584 /** 4585 * Audio session scene. 4586 * @enum { number } 4587 * @syscap SystemCapability.Multimedia.Audio.Core 4588 * @since 20 4589 */ 4590 enum AudioSessionScene { 4591 /** 4592 * Scene for media. 4593 * @syscap SystemCapability.Multimedia.Audio.Core 4594 * @since 20 4595 */ 4596 AUDIO_SESSION_SCENE_MEDIA = 0, 4597 /** 4598 * Scene for game. 4599 * @syscap SystemCapability.Multimedia.Audio.Core 4600 * @since 20 4601 */ 4602 AUDIO_SESSION_SCENE_GAME = 1, 4603 /** 4604 * Scene for voice communication. 4605 * @syscap SystemCapability.Multimedia.Audio.Core 4606 * @since 20 4607 */ 4608 AUDIO_SESSION_SCENE_VOICE_COMMUNICATION = 2, 4609 } 4610 4611 /** 4612 * Enumerates the session state change hints. 4613 * @enum { number } 4614 * @syscap SystemCapability.Multimedia.Audio.Core 4615 * @since 20 4616 */ 4617 enum AudioSessionStateChangeHint { 4618 /** 4619 * Resume the playback. 4620 * @syscap SystemCapability.Multimedia.Audio.Core 4621 * @since 20 4622 */ 4623 AUDIO_SESSION_STATE_CHANGE_HINT_RESUME = 0, 4624 4625 /** 4626 * Paused/Pause the playback. 4627 * @syscap SystemCapability.Multimedia.Audio.Core 4628 * @since 20 4629 */ 4630 AUDIO_SESSION_STATE_CHANGE_HINT_PAUSE = 1, 4631 4632 /** 4633 * Stopped/Stop the playback due to focus priority. 4634 * @syscap SystemCapability.Multimedia.Audio.Core 4635 * @since 20 4636 */ 4637 AUDIO_SESSION_STATE_CHANGE_HINT_STOP = 2, 4638 4639 /** 4640 * Stopped/Stop the playback due to no audio stream for a long time. 4641 * @syscap SystemCapability.Multimedia.Audio.Core 4642 * @since 20 4643 */ 4644 AUDIO_SESSION_STATE_CHANGE_HINT_TIME_OUT_STOP = 3, 4645 4646 /** 4647 * Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.) 4648 * @syscap SystemCapability.Multimedia.Audio.Core 4649 * @since 20 4650 */ 4651 AUDIO_SESSION_STATE_CHANGE_HINT_DUCK = 4, 4652 4653 /** 4654 * Unducked the playback. 4655 * @syscap SystemCapability.Multimedia.Audio.Core 4656 * @since 20 4657 */ 4658 AUDIO_SESSION_STATE_CHANGE_HINT_UNDUCK = 5, 4659 } 4660 4661 /** 4662 * Enumerates the recommend action when device change. 4663 * @enum { number } 4664 * @syscap SystemCapability.Multimedia.Audio.Core 4665 * @since 20 4666 */ 4667 enum OutputDeviceChangeRecommendedAction { 4668 /** 4669 * Recommend to continue the playback. 4670 * @syscap SystemCapability.Multimedia.Audio.Core 4671 * @since 20 4672 */ 4673 DEVICE_CHANGE_RECOMMEND_TO_CONTINUE = 0, 4674 /** 4675 * Recommend to stop the playback. 4676 * @syscap SystemCapability.Multimedia.Audio.Core 4677 * @since 20 4678 */ 4679 DEVICE_CHANGE_RECOMMEND_TO_STOP = 1, 4680 } 4681 4682 /** 4683 * Audio session strategy. 4684 * @typedef AudioSessionStrategy 4685 * @syscap SystemCapability.Multimedia.Audio.Core 4686 * @crossplatform 4687 * @since 12 4688 */ 4689 interface AudioSessionStrategy { 4690 /** 4691 * Audio concurrency mode. 4692 * @type { AudioConcurrencyMode } 4693 * @syscap SystemCapability.Multimedia.Audio.Core 4694 * @crossplatform 4695 * @since 12 4696 */ 4697 concurrencyMode: AudioConcurrencyMode; 4698 } 4699 4700 /** 4701 * Audio session deactivated event. 4702 * @typedef AudioSessionDeactivatedEvent 4703 * @syscap SystemCapability.Multimedia.Audio.Core 4704 * @crossplatform 4705 * @since 12 4706 */ 4707 interface AudioSessionDeactivatedEvent { 4708 /** 4709 * Audio session deactivated reason. 4710 * @type { AudioSessionDeactivatedReason } 4711 * @syscap SystemCapability.Multimedia.Audio.Core 4712 * @crossplatform 4713 * @since 12 4714 */ 4715 reason: AudioSessionDeactivatedReason; 4716 } 4717 4718 /** 4719 * Audio session state change event. 4720 * @typedef AudioSessionStateChangedEvent 4721 * @syscap SystemCapability.Multimedia.Audio.Core 4722 * @since 20 4723 */ 4724 interface AudioSessionStateChangedEvent { 4725 /** 4726 * Audio session state change hints. 4727 * @type { AudioSessionStateChangeHint } 4728 * @syscap SystemCapability.Multimedia.Audio.Core 4729 * @since 20 4730 */ 4731 stateChangeHint: AudioSessionStateChangeHint; 4732 } 4733 4734 /** 4735 * Audio session device change info. 4736 * @typedef CurrentOutputDeviceChangedEvent 4737 * @syscap SystemCapability.Multimedia.Audio.Core 4738 * @since 20 4739 */ 4740 interface CurrentOutputDeviceChangedEvent { 4741 /** 4742 * Audio device descriptors after change. 4743 * @type { AudioDeviceDescriptors } 4744 * @syscap SystemCapability.Multimedia.Audio.Core 4745 * @since 20 4746 */ 4747 devices: AudioDeviceDescriptors; 4748 /** 4749 * Audio device change reason. 4750 * @type { AudioStreamDeviceChangeReason } 4751 * @syscap SystemCapability.Multimedia.Audio.Core 4752 * @since 20 4753 */ 4754 changeReason: AudioStreamDeviceChangeReason; 4755 /** 4756 * Recommend action when device change. 4757 * @type { OutputDeviceChangeRecommendedAction } 4758 * @syscap SystemCapability.Multimedia.Audio.Core 4759 * @since 20 4760 */ 4761 recommendedAction: OutputDeviceChangeRecommendedAction; 4762 } 4763 4764 /** 4765 * Implements audio session management. 4766 * @typedef AudioSessionManager 4767 * @syscap SystemCapability.Multimedia.Audio.Core 4768 * @crossplatform 4769 * @since 12 4770 */ 4771 interface AudioSessionManager { 4772 /** 4773 * Activate the audio session for the current pid application. 4774 * If {@link setAudioSessionScene} is called, it will take focus when calling this method. 4775 * @param { AudioSessionStrategy } strategy - Audio session strategy. 4776 * @returns { Promise<void> } Promise used to return the result. 4777 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4778 * 1.Mandatory parameters unspecified. 4779 * 2.Incorrect parameter types. 4780 * @throws { BusinessError } 6800101 - Parameter verification failed. 4781 * @throws { BusinessError } 6800301 - System error. Returned by promise. 4782 * @syscap SystemCapability.Multimedia.Audio.Core 4783 * @crossplatform 4784 * @since 12 4785 */ 4786 activateAudioSession(strategy: AudioSessionStrategy): Promise<void>; 4787 4788 /** 4789 * Deactivate the audio session for the current pid application. 4790 * @returns { Promise<void> } Promise used to return the result. 4791 * @throws { BusinessError } 6800301 - System error. Returned by promise. 4792 * @syscap SystemCapability.Multimedia.Audio.Core 4793 * @crossplatform 4794 * @since 12 4795 */ 4796 deactivateAudioSession(): Promise<void>; 4797 4798 /** 4799 * Check whether the audio session is activated for the current pid application. 4800 * @returns { boolean } The active audio session status for the current pid application. 4801 * @syscap SystemCapability.Multimedia.Audio.Core 4802 * @crossplatform 4803 * @since 12 4804 */ 4805 isAudioSessionActivated(): boolean; 4806 4807 /** 4808 * Listens for audio session deactivated event. When the audio session is deactivated, 4809 * registered clients will receive the callback. 4810 * @param { 'audioSessionDeactivated' } type - Type of the event to listen for. Only the audioSessionDeactivated event is supported. 4811 * @param { Callback<AudioSessionDeactivatedEvent> } callback - Callback invoked for the audio session deactivated event. 4812 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4813 * 1.Mandatory parameters unspecified. 4814 * 2.Incorrect parameter types. 4815 * @throws { BusinessError } 6800101 - Parameter verification failed. 4816 * @syscap SystemCapability.Multimedia.Audio.Core 4817 * @crossplatform 4818 * @since 12 4819 */ 4820 on(type: 'audioSessionDeactivated', callback: Callback<AudioSessionDeactivatedEvent>): void; 4821 4822 /** 4823 * Unsubscribes to audio session deactivated event. 4824 * @param { 'audioSessionDeactivated' } type - Type of the event to listen for. Only the audioSessionDeactivated event is supported. 4825 * @param { Callback<AudioSessionDeactivatedEvent> } callback - Callback invoked for the audio session deactivated event. 4826 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4827 * 1.Mandatory parameters are left unspecified; 4828 * 2.Incorrect parameter types. 4829 * @throws { BusinessError } 6800101 - Parameter verification failed. 4830 * @syscap SystemCapability.Multimedia.Audio.Core 4831 * @crossplatform 4832 * @since 12 4833 */ 4834 off(type: 'audioSessionDeactivated', callback?: Callback<AudioSessionDeactivatedEvent>): void; 4835 4836 /** 4837 * Set scene for audio session. 4838 * @param { AudioSessionScene } scene - Audio session scene. 4839 * @throws { BusinessError } 6800101 - Parameter verification failed. 4840 * @throws { BusinessError } 6800103 - Operation not permit at current state. 4841 * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. 4842 * @syscap SystemCapability.Multimedia.Audio.Core 4843 * @since 20 4844 */ 4845 setAudioSessionScene(scene: AudioSessionScene): void; 4846 4847 /** 4848 * Listens for audio session state change event. When the audio session state change, 4849 * registered clients will receive the callback. 4850 * @param { 'audioSessionStateChanged' } type - Type of the event to listen for. 4851 * Only the audioSessionStateChanged event is supported. 4852 * @param { Callback<AudioSessionStateChangedEvent> } callback - Callback invoked for the audio session state change event. 4853 * @throws { BusinessError } 6800101 - Parameter verification failed. 4854 * @throws { BusinessError } 6800102 - Allocate memory failed. 4855 * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. 4856 * @syscap SystemCapability.Multimedia.Audio.Core 4857 * @since 20 4858 */ 4859 on(type: 'audioSessionStateChanged', callback: Callback<AudioSessionStateChangedEvent>): void; 4860 4861 /** 4862 * Unsubscribes to audio session deactivated event. 4863 * @param { 'audioSessionStateChanged' } type - Type of the event to listen for. 4864 * Only the audioSessionStateChanged event is supported. 4865 * @param { Callback<AudioSessionStateChangedEvent> } [callback] - Callback invoked for the audio session state change event. 4866 * @throws { BusinessError } 6800101 - Parameter verification failed. 4867 * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. 4868 * @syscap SystemCapability.Multimedia.Audio.Core 4869 * @since 20 4870 */ 4871 off(type: 'audioSessionStateChanged', callback?: Callback<AudioSessionStateChangedEvent>): void; 4872 4873 /** 4874 * Gets the default output device. 4875 * @returns { DeviceType } - the available deviceTypes are 4876 * EARPIECE: Built-in earpiece 4877 * SPEAKER: Built-in speaker 4878 * DEFAULT: System default output device 4879 * @throws { BusinessError } 6800101 - Parameter verification failed. 4880 * @throws { BusinessError } 6800103 - Operation not permit at current state. Return by promise. 4881 * @syscap SystemCapability.Multimedia.Audio.Device 4882 * @since 20 4883 */ 4884 getDefaultOutputDevice(): DeviceType; 4885 4886 /** 4887 * Temporarily changes the current audio device 4888 * This function applys on audiorenderers whose StreamUsage are 4889 * STREAM_USAGE_VOICE_COMMUNICATION/STREAM_USAGE_VIDEO_COMMUNICATION/STREAM_USAGE_VOICE_MESSAGE. 4890 * Setting the device will only takes effect if no other accessory such as headphones are in use 4891 * @param { DeviceType } deviceType - the available deviceTypes are 4892 * EARPIECE: Built-in earpiece 4893 * SPEAKER: Built-in speaker 4894 * DEFAULT: System default output device 4895 * @returns { Promise<void> } Promise used to return the result. 4896 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 4897 * @throws { BusinessError } 6800102 - Allocate memory failed. Return by promise. 4898 * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. 4899 * @syscap SystemCapability.Multimedia.Audio.Device 4900 * @since 20 4901 */ 4902 setDefaultOutputDevice(deviceType: DeviceType): Promise<void>; 4903 4904 /** 4905 * Subscribes output device change event callback. 4906 * The event is triggered when device change. 4907 * @param { 'currentOutputDeviceChanged' } type - Type of the event to listen for. 4908 * @param { Callback<CurrentOutputDeviceChangedEvent> } callback - Callback used to listen device change event. 4909 * @throws { BusinessError } 6800101 - Parameter verification failed. 4910 * @throws { BusinessError } 6800102 - Allocate memory failed. 4911 * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. 4912 * @syscap SystemCapability.Multimedia.Audio.Device 4913 * @since 20 4914 */ 4915 on(type: 'currentOutputDeviceChanged', callback: Callback<CurrentOutputDeviceChangedEvent>): void; 4916 4917 /** 4918 * UnSubscribes output device change event callback. 4919 * @param { 'currentOutputDeviceChanged' } type - Type of the event to listen for. 4920 * @param { Callback<CurrentOutputDeviceChangedEvent> } [callback] - Callback used to listen device change event. 4921 * @throws { BusinessError } 6800101 - Parameter verification failed. 4922 * @throws { BusinessError } 6800301 - Audio client call audio service error, System error. 4923 * @syscap SystemCapability.Multimedia.Audio.Device 4924 * @since 20 4925 */ 4926 off(type: 'currentOutputDeviceChanged', callback?: Callback<CurrentOutputDeviceChangedEvent>): void; 4927 } 4928 4929 /** 4930 * Array of StreamUsages. 4931 * @typedef { Array<StreamUsage> } StreamUsageArray 4932 * @syscap SystemCapability.Multimedia.Audio.Core 4933 * @systemapi 4934 * @since 20 4935 */ 4936 type StreamUsageArray = Array<StreamUsage>; 4937 4938 /** 4939 * Implements audio volume management. 4940 * @typedef AudioVolumeManager 4941 * @syscap SystemCapability.Multimedia.Audio.Volume 4942 * @since 9 4943 */ 4944 /** 4945 * Implements audio volume management. 4946 * @typedef AudioVolumeManager 4947 * @syscap SystemCapability.Multimedia.Audio.Volume 4948 * @crossplatform 4949 * @since 12 4950 */ 4951 interface AudioVolumeManager { 4952 /** 4953 * Get the volume group list for a networkId. This method uses an asynchronous callback to return the result. 4954 * @param { string } networkId - Distributed deice net work id 4955 * @param { AsyncCallback<VolumeGroupInfos> } callback - Callback used to return the result. 4956 * @syscap SystemCapability.Multimedia.Audio.Volume 4957 * @systemapi 4958 * @since 9 4959 */ 4960 getVolumeGroupInfos(networkId: string, callback: AsyncCallback<VolumeGroupInfos>): void; 4961 /** 4962 * Get the volume group list for a networkId. This method uses a promise to return the result. 4963 * @param { string } networkId - Distributed deice net work id 4964 * @returns { Promise<VolumeGroupInfos> } Promise used to return the result. 4965 * @syscap SystemCapability.Multimedia.Audio.Volume 4966 * @systemapi 4967 * @since 9 4968 */ 4969 getVolumeGroupInfos(networkId: string): Promise<VolumeGroupInfos>; 4970 /** 4971 * Get the volume group list for a networkId. 4972 * @param { string } networkId - Distributed deice net work id 4973 * @returns { VolumeGroupInfos } Volume group info list. 4974 * @throws { BusinessError } 401 - Parameter error. Possible causes: 4975 * 1.Mandatory parameters are left unspecified; 4976 * 2.Incorrect parameter types. 4977 * @throws { BusinessError } 6800101 - Parameter verification failed. 4978 * @syscap SystemCapability.Multimedia.Audio.Volume 4979 * @systemapi 4980 * @since 10 4981 */ 4982 getVolumeGroupInfosSync(networkId: string): VolumeGroupInfos; 4983 4984 /** 4985 * Obtains an AudioVolumeGroupManager instance. This method uses an asynchronous callback to return the result. 4986 * @param { number } groupId - volume group id, use LOCAL_VOLUME_GROUP_ID in default 4987 * @param { AsyncCallback<AudioVolumeGroupManager> } callback - Callback used to return the result. 4988 * @syscap SystemCapability.Multimedia.Audio.Volume 4989 * @since 9 4990 */ 4991 /** 4992 * Obtains an AudioVolumeGroupManager instance. This method uses an asynchronous callback to return the result. 4993 * @param { number } groupId - volume group id, use LOCAL_VOLUME_GROUP_ID in default 4994 * @param { AsyncCallback<AudioVolumeGroupManager> } callback - Callback used to return the result. 4995 * @syscap SystemCapability.Multimedia.Audio.Volume 4996 * @crossplatform 4997 * @since 12 4998 */ 4999 getVolumeGroupManager(groupId: number, callback: AsyncCallback<AudioVolumeGroupManager>): void; 5000 /** 5001 * Obtains an AudioVolumeGroupManager instance. This method uses a promise to return the result. 5002 * @param { number } groupId - volume group id, use LOCAL_VOLUME_GROUP_ID in default 5003 * @returns { Promise<AudioVolumeGroupManager> } Promise used to return the result. 5004 * @syscap SystemCapability.Multimedia.Audio.Volume 5005 * @since 9 5006 */ 5007 /** 5008 * Obtains an AudioVolumeGroupManager instance. This method uses a promise to return the result. 5009 * @param { number } groupId - volume group id, use {@link DEFAULT_VOLUME_GROUP_ID} in default 5010 * @returns { Promise<AudioVolumeGroupManager> } Promise used to return the result. 5011 * @syscap SystemCapability.Multimedia.Audio.Volume 5012 * @crossplatform 5013 * @since 12 5014 */ 5015 getVolumeGroupManager(groupId: number): Promise<AudioVolumeGroupManager>; 5016 /** 5017 * Obtains an AudioVolumeGroupManager instance. 5018 * @param { number } groupId - volume group id, use LOCAL_VOLUME_GROUP_ID in default 5019 * @returns { AudioVolumeGroupManager } The audio volume group manager instance. 5020 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5021 * 1.Mandatory parameters are left unspecified; 5022 * 2.Incorrect parameter types. 5023 * @throws { BusinessError } 6800101 - Parameter verification failed. 5024 * @syscap SystemCapability.Multimedia.Audio.Volume 5025 * @since 10 5026 */ 5027 /** 5028 * Obtains an AudioVolumeGroupManager instance. 5029 * @param { number } groupId - volume group id, use {@link DEFAULT_VOLUME_GROUP_ID} in default 5030 * @returns { AudioVolumeGroupManager } The audio volume group manager instance. 5031 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5032 * 1.Mandatory parameters are left unspecified; 5033 * 2.Incorrect parameter types. 5034 * @throws { BusinessError } 6800101 - Parameter verification failed. 5035 * @syscap SystemCapability.Multimedia.Audio.Volume 5036 * @crossplatform 5037 * @since 12 5038 */ 5039 getVolumeGroupManagerSync(groupId: number): AudioVolumeGroupManager; 5040 5041 /** 5042 * Get the volume for specified app with range from 0 to 100. Applications with same uid share the same volume. 5043 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5044 * @param { number } uid - App's uid. 5045 * @returns { Promise<number> } Promise used to return the result. 5046 * @throws { BusinessError } 201 - Permission denied. 5047 * @throws { BusinessError } 202 - Not system App. 5048 * @throws { BusinessError } 6800101 - Parameter verification failed. 5049 * @syscap SystemCapability.Multimedia.Audio.Volume 5050 * @systemapi 5051 * @since 19 5052 */ 5053 getAppVolumePercentageForUid(uid: number): Promise<number>; 5054 5055 /** 5056 * Sets the volume for specified app with range from 0 to 100. Applications with same uid share the same volume. 5057 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5058 * @param { number } uid - App's uid. 5059 * @param { number } volume - Volume to set. The value range is from 0 to 100. 5060 * @returns { Promise<void> } Promise used to return the result. 5061 * @throws { BusinessError } 201 - Permission denied. 5062 * @throws { BusinessError } 202 - Not system App. 5063 * @throws { BusinessError } 6800101 - Parameter verification failed. 5064 * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. 5065 * @syscap SystemCapability.Multimedia.Audio.Volume 5066 * @systemapi 5067 * @since 19 5068 */ 5069 setAppVolumePercentageForUid(uid: number, volume: number): Promise<void>; 5070 5071 /** 5072 * Checks whether the app volume is muted. If there are multiple callers setting muted states, 5073 * only when all callers cancel muted state the volume of this app will be truly unmuted. 5074 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5075 * @param { number } uid - App's uid. 5076 * @param { boolean } owned - If true is passed, the result will be indicated your owned muted state 5077 * settings to this app. Otherwise if false is passed, the result will be indicated the real muted state. 5078 * @returns { Promise<boolean> } Promise used to return the result. 5079 * @throws { BusinessError } 201 - Permission denied. 5080 * @throws { BusinessError } 202 - Not system App. 5081 * @throws { BusinessError } 6800101 - Parameter verification failed. 5082 * @syscap SystemCapability.Multimedia.Audio.Volume 5083 * @systemapi 5084 * @since 19 5085 */ 5086 isAppVolumeMutedForUid(uid: number, owned: boolean): Promise<boolean>; 5087 5088 /** 5089 * Change mute state of specified application volume. If there are multiple callers setting muted states, 5090 * only when all callers cancel muted state the volume of this app will be truly unmuted. 5091 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5092 * @param { number } uid - App's uid. 5093 * @param { boolean } muted - Muted state to set. 5094 * @returns { Promise<void> } Promise used to return the result. 5095 * @throws { BusinessError } 201 - Permission denied. 5096 * @throws { BusinessError } 202 - Not system App. 5097 * @throws { BusinessError } 6800101 - Parameter verification failed. 5098 * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. 5099 * @syscap SystemCapability.Multimedia.Audio.Volume 5100 * @systemapi 5101 * @since 19 5102 */ 5103 setAppVolumeMutedForUid(uid: number, muted: boolean): Promise<void>; 5104 5105 /** 5106 * Get the volume for your app with range from 0 to 100. Applications with the same uid share the same volume. 5107 * @returns { Promise<number> } The application's volume percentage. The value range is from 0 to 100. 5108 * @syscap SystemCapability.Multimedia.Audio.Volume 5109 * @since 19 5110 */ 5111 getAppVolumePercentage(): Promise<number>; 5112 5113 /** 5114 * Sets the volume for your app with range from 0 to 100. Applications with the same uid share the same volume. 5115 * Only AudioRenderers with {@link AudioRendererInfo.volumeMode} set to {@link AudioVolumeMode.APP_INDIVIDUAL} 5116 * will be affected by this volume. 5117 * When you change your app's volume, your will receive 'appVolumeChange' callback event. 5118 * Your app volume can be also changed by other system settings, and you can monitor the changes through 5119 * 'appVolumeChange' callback. 5120 * @param { number } volume - Volume to set. The value range is from 0 to 100. 5121 * @returns { Promise<void> } Promise used to return the result. 5122 * @throws { BusinessError } 6800101 - Parameter verification failed. 5123 * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. 5124 * @syscap SystemCapability.Multimedia.Audio.Volume 5125 * @since 19 5126 */ 5127 setAppVolumePercentage(volume: number): Promise<void>; 5128 5129 /** 5130 * Sets the volume for a stream. This method uses a promise to return the result. 5131 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5132 * @param { AudioVolumeType } volumeType - Audio stream type. 5133 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 5134 * @param { number } callingUid - Uid of the stream owner. 5135 * @returns { Promise<void> } Promise used to return the result. 5136 * @throws { BusinessError } 201 - Permission denied. 5137 * @throws { BusinessError } 202 - Not system App. 5138 * @throws { BusinessError } 6800101 - Parameter verification failed. 5139 * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. 5140 * @syscap SystemCapability.Multimedia.Audio.Volume 5141 * @systemapi 5142 * @since 20 5143 */ 5144 setSystemVolumeByUid(volumeType: AudioVolumeType, volume: number, callingUid: number): Promise<void>; 5145 5146 /** 5147 * Obtains the volume of a stream. 5148 * @param { AudioVolumeType } volumeType - Audio stream type. 5149 * @param { number } callingUid - Uid of the stream owner. 5150 * @returns { number } Current system volume level. 5151 * @throws { BusinessError } 202 - Not system App. 5152 * @throws { BusinessError } 6800101 - Parameter verification failed. 5153 * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. 5154 * @syscap SystemCapability.Multimedia.Audio.Volume 5155 * @systemapi 5156 * @since 20 5157 */ 5158 getSystemVolumeByUid(volumeType: AudioVolumeType, callingUid: number): number; 5159 5160 /** 5161 * Listens for system volume change events. This method uses a callback to get volume change events. 5162 * @param { 'volumeChange' } type - Type of the event to listen for. Only the volumeChange event is supported. 5163 * @param { Callback<VolumeEvent> } callback - Callback used to get the system volume change event. 5164 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5165 * 1.Mandatory parameters are left unspecified; 5166 * 2.Incorrect parameter types. 5167 * @throws { BusinessError } 6800101 - Parameter verification failed. 5168 * @syscap SystemCapability.Multimedia.Audio.Volume 5169 * @since 9 5170 */ 5171 /** 5172 * Listens for system volume change events. This method uses a callback to get volume change events. 5173 * @param { 'volumeChange' } type - Type of the event to listen for. Only the volumeChange event is supported. 5174 * @param { Callback<VolumeEvent> } callback - Callback used to get the system volume change event. 5175 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5176 * 1.Mandatory parameters are left unspecified; 5177 * 2.Incorrect parameter types. 5178 * @throws { BusinessError } 6800101 - Parameter verification failed. 5179 * @syscap SystemCapability.Multimedia.Audio.Volume 5180 * @crossplatform 5181 * @since 12 5182 * @deprecated since 20 5183 * @useinstead ohos.multimedia.audio.AudioVolumeManager#event:streamVolumeChange 5184 */ 5185 on(type: 'volumeChange', callback: Callback<VolumeEvent>): void; 5186 5187 /** 5188 * Unsubscribes to the volume change events.. 5189 * @param { 'volumeChange' } type - Type of the event to be unregistered. Only the volumeChange event is supported. 5190 * @param { Callback<VolumeEvent> } callback - Callback used to obtain the invoking volume change event. 5191 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5192 * 1.Mandatory parameters missing; 5193 * 2.Incorrect parameter types. 5194 * @throws { BusinessError } 6800101 - Parameter verification failed. 5195 * @syscap SystemCapability.Multimedia.Audio.Volume 5196 * @since 12 5197 * @deprecated since 20 5198 * @useinstead ohos.multimedia.audio.AudioVolumeManager#event:streamVolumeChange 5199 */ 5200 off(type: 'volumeChange', callback?: Callback<VolumeEvent>): void; 5201 5202 /** 5203 * Listens for specified app volume change events. 5204 * The app volume may changed by {@link setAppVolumePercentageForUid}. 5205 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5206 * @param { 'appVolumeChangeForUid' } type - Type of the event to listen for. Only the 5207 * appVolumeChangeForUid event is supported. 5208 * @param { number } uid - The app's uid. 5209 * @param { Callback<VolumeEvent> } callback - Callback used to get the app volume change event. 5210 * @throws { BusinessError } 201 - Permission denied. 5211 * @throws { BusinessError } 202 - Not system App. 5212 * @throws { BusinessError } 6800101 - Parameter verification failed. 5213 * @syscap SystemCapability.Multimedia.Audio.Volume 5214 * @systemapi 5215 * @since 19 5216 */ 5217 on(type: 'appVolumeChangeForUid', uid: number, callback: Callback<VolumeEvent>): void; 5218 5219 /** 5220 * Unsubscribes to the app volume change events.. 5221 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5222 * @param { 'appVolumeChangeForUid' } type - Type of the event to be unregistered. Only the appVolumeChangeForUid 5223 * event is supported. 5224 * @param { Callback<VolumeEvent> } callback - Callback used to obtain the invoking volume change event. 5225 * @throws { BusinessError } 201 - Permission denied. 5226 * @throws { BusinessError } 202 - Not system App. 5227 * @throws { BusinessError } 6800101 - Parameter verification failed. 5228 * @syscap SystemCapability.Multimedia.Audio.Volume 5229 * @systemapi 5230 * @since 19 5231 */ 5232 off(type: 'appVolumeChangeForUid', callback?: Callback<VolumeEvent>): void; 5233 5234 /** 5235 * Listens for app volume change events. The app volume may changed by your called {@link setAppVolumePercentage} 5236 * or other system settings. 5237 * @param { 'appVolumeChange' } type - Type of the event to listen for. Only the appVolumeChange event is supported. 5238 * @param { Callback<VolumeEvent> } callback - Callback used to get the app volume change event. 5239 * @throws { BusinessError } 6800101 - Parameter verification failed. 5240 * @syscap SystemCapability.Multimedia.Audio.Volume 5241 * @since 19 5242 */ 5243 on(type: 'appVolumeChange', callback: Callback<VolumeEvent>): void; 5244 5245 /** 5246 * Unsubscribes to the app volume change events.. 5247 * @param { 'appVolumeChange' } type - Type of the event to be unregistered. Only the appVolumeChange event 5248 * is supported. 5249 * @param { Callback<VolumeEvent> } callback - Callback used to obtain the invoking volume change event. 5250 * @throws { BusinessError } 6800101 - Parameter verification failed. 5251 * @syscap SystemCapability.Multimedia.Audio.Volume 5252 * @since 19 5253 */ 5254 off(type: 'appVolumeChange', callback?: Callback<VolumeEvent>): void; 5255 5256 /** 5257 * Subscribes to active volume type changes. 5258 * @param { 'activeVolumeTypeChange' } type - Type of the event to listen for. 5259 * Only the activeVolumeTypeChange event is supported. 5260 * @param { Callback<AudioVolumeType> } callback - Callback used to return the active volume type. 5261 * @throws { BusinessError } 202 - Not system App. 5262 * @throws { BusinessError } 6800101 - Parameter verification failed. 5263 * @syscap SystemCapability.Multimedia.Audio.Volume 5264 * @systemapi 5265 * @since 20 5266 */ 5267 on(type: 'activeVolumeTypeChange', callback: Callback<AudioVolumeType>): void; 5268 5269 /** 5270 * Unsubscribes from active volume type changes. 5271 * @param { 'activeVolumeTypeChange' } type - Type of the event to unregister. 5272 * Only the activeVolumeTypeChange event is supported. 5273 * @param { Callback<AudioVolumeType> } callback - Callback used to return the active volume type. 5274 * @throws { BusinessError } 202 - Not system App. 5275 * @throws { BusinessError } 6800101 - Parameter verification failed. 5276 * @syscap SystemCapability.Multimedia.Audio.Volume 5277 * @systemapi 5278 * @since 20 5279 */ 5280 off(type: 'activeVolumeTypeChange', callback?: Callback<AudioVolumeType>): void; 5281 5282 /** 5283 * Obtains the volume of a volume type. 5284 * @param { AudioVolumeType } volumeType - Audio volume type. 5285 * @returns { number } Current system volume level. 5286 * @throws { BusinessError } 202 - Not system App. 5287 * @throws { BusinessError } 6800101 - Parameter verification failed. 5288 * @syscap SystemCapability.Multimedia.Audio.Volume 5289 * @systemapi 5290 * @since 20 5291 */ 5292 getSystemVolume(volumeType: AudioVolumeType): number; 5293 5294 /** 5295 * Obtains the minimum volume allowed for a volume type. 5296 * @param { AudioVolumeType } volumeType - Audio volume type. 5297 * @returns { number } Min volume level. 5298 * @throws { BusinessError } 202 - Not system App. 5299 * @throws { BusinessError } 6800101 - Parameter verification failed. 5300 * @syscap SystemCapability.Multimedia.Audio.Volume 5301 * @systemapi 5302 * @since 20 5303 */ 5304 getMinSystemVolume(volumeType: AudioVolumeType): number; 5305 5306 /** 5307 * Obtains the maximum volume allowed for a volume type. 5308 * @param { AudioVolumeType } volumeType - Audio volume type. 5309 * @returns { number } Max volume level. 5310 * @throws { BusinessError } 202 - Not system App. 5311 * @throws { BusinessError } 6800101 - Parameter verification failed. 5312 * @syscap SystemCapability.Multimedia.Audio.Volume 5313 * @systemapi 5314 * @since 20 5315 */ 5316 getMaxSystemVolume(volumeType: AudioVolumeType): number; 5317 5318 /** 5319 * Checks whether a volume type is muted. 5320 * @param { AudioVolumeType } volumeType - Audio volume type. 5321 * @returns { boolean } The mute status of the volume type. The value true 5322 * means that the volume type is muted, and false means the opposite. 5323 * @throws { BusinessError } 202 - Not system App. 5324 * @throws { BusinessError } 6800101 - Parameter verification failed. 5325 * @syscap SystemCapability.Multimedia.Audio.Volume 5326 * @systemapi 5327 * @since 20 5328 */ 5329 isSystemMuted(volumeType: AudioVolumeType): boolean; 5330 5331 /** 5332 * Gets the volume db value that system calculate by volume type, volume level and device type. 5333 * @param { AudioVolumeType } volumeType - Audio volume type. 5334 * @param { number } volumeLevel - Volume level to set. 5335 * @param { DeviceType } device - Output device type. 5336 * @returns { number } The system volume in dB. 5337 * @throws { BusinessError } 202 - Not system App. 5338 * @throws { BusinessError } 6800101 - Parameter verification failed. 5339 * @syscap SystemCapability.Multimedia.Audio.Volume 5340 * @systemapi 5341 * @since 20 5342 */ 5343 getVolumeInUnitOfDb(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType): number; 5344 5345 /** 5346 * Listens for system volume change events. This method uses a callback to get volume change events. 5347 * @param { 'systemVolumeChange' } type - Type of the event to listen for. 5348 * Only the systemVolumeChange event is supported. 5349 * @param { Callback<VolumeEvent> } callback - Callback used to get the system volume change event. 5350 * @throws { BusinessError } 202 - Not system App. 5351 * @throws { BusinessError } 6800101 - Parameter verification failed. 5352 * @syscap SystemCapability.Multimedia.Audio.Volume 5353 * @systemapi 5354 * @since 20 5355 */ 5356 on(type: 'systemVolumeChange', callback: Callback<VolumeEvent>): void; 5357 5358 /** 5359 * Unsubscribes to the system volume change events. 5360 * @param { 'systemVolumeChange' } type - Type of the event to be unregistered. 5361 * Only the systemVolumeChange event is supported. 5362 * @param { Callback<VolumeEvent> } callback - Callback used to obtain the invoking volume change event. 5363 * @throws { BusinessError } 202 - Not system App. 5364 * @throws { BusinessError } 6800101 - Parameter verification failed. 5365 * @syscap SystemCapability.Multimedia.Audio.Volume 5366 * @systemapi 5367 * @since 20 5368 */ 5369 off(type: 'systemVolumeChange', callback?: Callback<VolumeEvent>): void; 5370 5371 /** 5372 * Obtains the volume of a stream. 5373 * @param { StreamUsage } streamUsage - Audio stream type. 5374 * @returns { number } Current system volume level. 5375 * @throws { BusinessError } 6800101 - Parameter verification failed. 5376 * @syscap SystemCapability.Multimedia.Audio.Volume 5377 * @since 20 5378 */ 5379 getVolumeByStream(streamUsage: StreamUsage): number; 5380 5381 /** 5382 * Obtains the minimum volume allowed for a stream. 5383 * @param { StreamUsage } streamUsage - Audio stream type. 5384 * @returns { number } Min volume level. 5385 * @throws { BusinessError } 6800101 - Parameter verification failed. 5386 * @syscap SystemCapability.Multimedia.Audio.Volume 5387 * @since 20 5388 */ 5389 getMinVolumeByStream(streamUsage: StreamUsage): number; 5390 5391 /** 5392 * Obtains the maximum volume allowed for a stream. 5393 * @param { StreamUsage } streamUsage - Audio stream type. 5394 * @returns { number } Max volume level. 5395 * @throws { BusinessError } 6800101 - Parameter verification failed. 5396 * @syscap SystemCapability.Multimedia.Audio.Volume 5397 * @since 20 5398 */ 5399 getMaxVolumeByStream(streamUsage: StreamUsage): number; 5400 5401 /** 5402 * Checks whether the system is muted based on the stream. 5403 * @param { StreamUsage } streamUsage - Audio stream type. 5404 * @returns { boolean } The mute status of the stream. The value true 5405 * means that the stream is muted, and false means the opposite. 5406 * @throws { BusinessError } 6800101 - Parameter verification failed. 5407 * @syscap SystemCapability.Multimedia.Audio.Volume 5408 * @since 20 5409 */ 5410 isSystemMutedForStream(streamUsage: StreamUsage): boolean; 5411 5412 /** 5413 * Gets the volume db value that system calculate by volume stream, volume level and device type. 5414 * @param { StreamUsage } streamUsage - Audio stream type. 5415 * @param { number } volumeLevel - Volume level to set. 5416 * @param { DeviceType } device - Output device type. 5417 * @returns { number } The system volume in dB. 5418 * @throws { BusinessError } 6800101 - Parameter verification failed. 5419 * @syscap SystemCapability.Multimedia.Audio.Volume 5420 * @since 20 5421 */ 5422 getVolumeInUnitOfDbByStream(streamUsage: StreamUsage, volumeLevel: number, device: DeviceType): number; 5423 5424 /** 5425 * Obtains system supported volume types. 5426 * @returns { Array<Readonly<AudioVolumeType>> } Return the system volume type array. 5427 * @throws { BusinessError } 202 - Not system App. 5428 * @syscap SystemCapability.Multimedia.Audio.Volume 5429 * @systemapi 5430 * @since 20 5431 */ 5432 getSupportedAudioVolumeTypes(): Array<Readonly<AudioVolumeType>>; 5433 5434 /** 5435 * Obtains volume type by stream type. 5436 * @param { StreamUsage } streamUsage - Audio stream type. 5437 * @returns { AudioVolumeType } Return the audio volume type. 5438 * @throws { BusinessError } 202 - Not system App. 5439 * @throws { BusinessError } 6800101 - Parameter verification failed. 5440 * @syscap SystemCapability.Multimedia.Audio.Volume 5441 * @systemapi 5442 * @since 20 5443 */ 5444 getAudioVolumeTypeByStreamUsage(streamUsage: StreamUsage): AudioVolumeType; 5445 5446 /** 5447 * Obtains stream types by volume type. 5448 * @param { AudioVolumeType } volumeType - Audio stream type. 5449 * @returns { StreamUsageArray } Return the audio stream types. 5450 * @throws { BusinessError } 202 - Not system App. 5451 * @throws { BusinessError } 6800101 - Parameter verification failed. 5452 * @syscap SystemCapability.Multimedia.Audio.Volume 5453 * @systemapi 5454 * @since 20 5455 */ 5456 getStreamUsagesByVolumeType(volumeType: AudioVolumeType): StreamUsageArray; 5457 5458 /** 5459 * Listens for stream volume change events. This method uses a callback to get volume change events. 5460 * @param { 'streamVolumeChange' } type - Type of the event to listen for. 5461 * Only the streamVolumeChange event is supported. 5462 * @param { StreamUsage } streamUsage - StreamUsage to be listened. 5463 * @param { Callback<StreamVolumeEvent> } callback - Callback used to get the stream volume change event. 5464 * @throws { BusinessError } 6800101 - Parameter verification failed. 5465 * @syscap SystemCapability.Multimedia.Audio.Volume 5466 * @since 20 5467 */ 5468 on(type: 'streamVolumeChange', streamUsage: StreamUsage, callback: Callback<StreamVolumeEvent>): void; 5469 5470 /** 5471 * Unsubscribes to the stream volume change events. 5472 * @param { 'streamVolumeChange' } type - Type of the event to be unregistered. 5473 * Only the streamVolumeChange event is supported. 5474 * @param { Callback<StreamVolumeEvent> } callback - Callback used to obtain the invoking volume change event. 5475 * If there is no callback parameter, all callbacks will be unregistered. 5476 * @syscap SystemCapability.Multimedia.Audio.Volume 5477 * @since 20 5478 */ 5479 off(type: 'streamVolumeChange', callback?: Callback<StreamVolumeEvent>): void; 5480 5481 /** 5482 * Interface for forcibly setting the volume type by pressing the volume key. 5483 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 5484 * @param { AudioVolumeType } volumeType - Audio volume type. 5485 * that the application expects to control using the volume key. 5486 * @param { number } duration - Duration for continuing to control the volume type when no key is pressed. 5487 * The forced volume type setting is released when the timer expires. The maximum duration is 10 seconds. 5488 * If the duration is set to -1, the setting is canceled. 5489 * @throws { BusinessError } 201 - Permission denied. 5490 * @throws { BusinessError } 202 - Not system App. 5491 * @throws { BusinessError } 6800101 - Parameter verification failed. 5492 * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. 5493 * @syscap SystemCapability.Multimedia.Audio.Volume 5494 * @systemapi 5495 * @since 20 5496 */ 5497 forceVolumeKeyControlType(volumeType: AudioVolumeType, duration: number): void; 5498 } 5499 5500 /** 5501 * Implements audio volume group management. 5502 * @typedef AudioVolumeGroupManager 5503 * @syscap SystemCapability.Multimedia.Audio.Volume 5504 * @since 9 5505 */ 5506 /** 5507 * Implements audio volume group management. 5508 * @typedef AudioVolumeGroupManager 5509 * @syscap SystemCapability.Multimedia.Audio.Volume 5510 * @crossplatform 5511 * @since 12 5512 */ 5513 interface AudioVolumeGroupManager { 5514 /** 5515 * Sets the volume for a stream. This method uses an asynchronous callback to return the result. 5516 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5517 * @param { AudioVolumeType } volumeType - Audio stream type. 5518 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 5519 * @param { AsyncCallback<void> } callback - Callback used to return the result. 5520 * @syscap SystemCapability.Multimedia.Audio.Volume 5521 * @systemapi 5522 * @since 9 5523 */ 5524 setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void; 5525 /** 5526 * Sets the volume for a stream. This method uses a promise to return the result. 5527 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5528 * @param { AudioVolumeType } volumeType - Audio stream type. 5529 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 5530 * @returns { Promise<void> } Promise used to return the result. 5531 * @syscap SystemCapability.Multimedia.Audio.Volume 5532 * @systemapi 5533 * @since 9 5534 */ 5535 setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>; 5536 5537 /** 5538 * Sets the volume for a stream. This method uses a promise to return the result. 5539 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5540 * @param { AudioVolumeType } volumeType - Audio stream type. 5541 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 5542 * @param { number } flags - volume flags used to enable different operations, can be union of {@link VolumeFlag} 5543 * @returns { Promise<void> } Promise used to return the result. 5544 * @throws { BusinessError } 201 - Permission denied. 5545 * @throws { BusinessError } 202 - Not system App. 5546 * @syscap SystemCapability.Multimedia.Audio.Volume 5547 * @systemapi 5548 * @since 12 5549 */ 5550 setVolumeWithFlag(volumeType: AudioVolumeType, volume: number, flags: number): Promise<void>; 5551 5552 /** 5553 * Obtains the active volume type in the calling moment. This method returns in sync mode. 5554 * @param { number } uid - The target uid's active volume type or 5555 * 0 which means the global active volume type. 5556 * @returns { AudioVolumeType } Current active volume type. 5557 * @throws { BusinessError } 202 - Not system App. 5558 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5559 * 1.Mandatory parameters unspecified. 5560 * 2.Incorrect parameter types. 5561 * @throws { BusinessError } 6800101 - Parameter verification failed. 5562 * @syscap SystemCapability.Multimedia.Audio.Volume 5563 * @systemapi 5564 * @since 13 5565 */ 5566 getActiveVolumeTypeSync(uid: number): AudioVolumeType; 5567 5568 /** 5569 * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. 5570 * @param { AudioVolumeType } volumeType - Audio stream type. 5571 * @param { AsyncCallback<number> } callback - Callback used to return the volume. 5572 * @syscap SystemCapability.Multimedia.Audio.Volume 5573 * @since 9 5574 */ 5575 /** 5576 * Obtains the volume of a volume type. This method uses an asynchronous callback to return the query result. 5577 * @param { AudioVolumeType } volumeType - Audio volume type. 5578 * @param { AsyncCallback<number> } callback - Callback used to return the volume. 5579 * @syscap SystemCapability.Multimedia.Audio.Volume 5580 * @crossplatform 5581 * @since 12 5582 * @deprecated since 20 5583 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getVolumeByStream 5584 */ 5585 getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 5586 /** 5587 * Obtains the volume of a stream. This method uses a promise to return the query result. 5588 * @param { AudioVolumeType } volumeType - Audio stream type. 5589 * @returns { Promise<number> } Promise used to return the volume. 5590 * @syscap SystemCapability.Multimedia.Audio.Volume 5591 * @since 9 5592 */ 5593 /** 5594 * Obtains the volume of a volume type. This method uses a promise to return the query result. 5595 * @param { AudioVolumeType } volumeType - Audio volume type. 5596 * @returns { Promise<number> } Promise used to return the volume. 5597 * @syscap SystemCapability.Multimedia.Audio.Volume 5598 * @crossplatform 5599 * @since 12 5600 * @deprecated since 20 5601 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getVolumeByStream 5602 */ 5603 getVolume(volumeType: AudioVolumeType): Promise<number>; 5604 /** 5605 * Obtains the volume of a stream. 5606 * @param { AudioVolumeType } volumeType - Audio stream type. 5607 * @returns { number } Current system volume level. 5608 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5609 * 1.Mandatory parameters are left unspecified; 5610 * 2.Incorrect parameter types. 5611 * @throws { BusinessError } 6800101 - Parameter verification failed. 5612 * @syscap SystemCapability.Multimedia.Audio.Volume 5613 * @since 10 5614 */ 5615 /** 5616 * Obtains the volume of a volume type. 5617 * @param { AudioVolumeType } volumeType - Audio volume type. 5618 * @returns { number } Current system volume level. 5619 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5620 * 1.Mandatory parameters are left unspecified; 5621 * 2.Incorrect parameter types. 5622 * @throws { BusinessError } 6800101 - Parameter verification failed. 5623 * @syscap SystemCapability.Multimedia.Audio.Volume 5624 * @crossplatform 5625 * @since 12 5626 * @deprecated since 20 5627 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getVolumeByStream 5628 */ 5629 getVolumeSync(volumeType: AudioVolumeType): number; 5630 5631 /** 5632 * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 5633 * @param { AudioVolumeType } volumeType - Audio stream type. 5634 * @param { AsyncCallback<number> } callback - Callback used to return the minimum volume. 5635 * @syscap SystemCapability.Multimedia.Audio.Volume 5636 * @since 9 5637 */ 5638 /** 5639 * Obtains the minimum volume allowed for a volume type. This method uses an asynchronous callback to return the query result. 5640 * @param { AudioVolumeType } volumeType - Audio volume type. 5641 * @param { AsyncCallback<number> } callback - Callback used to return the minimum volume. 5642 * @syscap SystemCapability.Multimedia.Audio.Volume 5643 * @crossplatform 5644 * @since 12 5645 * @deprecated since 20 5646 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getMinVolumeByStream 5647 */ 5648 getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 5649 /** 5650 * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. 5651 * @param { AudioVolumeType } volumeType - Audio stream type. 5652 * @returns { Promise<number> } Promise used to return the minimum volume. 5653 * @syscap SystemCapability.Multimedia.Audio.Volume 5654 * @since 9 5655 */ 5656 /** 5657 * Obtains the minimum volume allowed for a volume type. This method uses a promise to return the query result. 5658 * @param { AudioVolumeType } volumeType - Audio volume type. 5659 * @returns { Promise<number> } Promise used to return the minimum volume. 5660 * @syscap SystemCapability.Multimedia.Audio.Volume 5661 * @crossplatform 5662 * @since 12 5663 * @deprecated since 20 5664 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getMinVolumeByStream 5665 */ 5666 getMinVolume(volumeType: AudioVolumeType): Promise<number>; 5667 /** 5668 * Obtains the minimum volume allowed for a stream. 5669 * @param { AudioVolumeType } volumeType - Audio stream type. 5670 * @returns { number } Min volume level. 5671 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5672 * 1.Mandatory parameters are left unspecified; 5673 * 2.Incorrect parameter types. 5674 * @throws { BusinessError } 6800101 - Parameter verification failed. 5675 * @syscap SystemCapability.Multimedia.Audio.Volume 5676 * @since 10 5677 */ 5678 /** 5679 * Obtains the minimum volume allowed for a volume type. 5680 * @param { AudioVolumeType } volumeType - Audio volume type. 5681 * @returns { number } Min volume level. 5682 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5683 * 1.Mandatory parameters are left unspecified; 5684 * 2.Incorrect parameter types. 5685 * @throws { BusinessError } 6800101 - Parameter verification failed. 5686 * @syscap SystemCapability.Multimedia.Audio.Volume 5687 * @crossplatform 5688 * @since 12 5689 * @deprecated since 20 5690 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getMinVolumeByStream 5691 */ 5692 getMinVolumeSync(volumeType: AudioVolumeType): number; 5693 5694 /** 5695 * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 5696 * @param { AudioVolumeType } volumeType - Audio stream type. 5697 * @param { AsyncCallback<number> } callback - Callback used to return the maximum volume. 5698 * @syscap SystemCapability.Multimedia.Audio.Volume 5699 * @since 9 5700 */ 5701 /** 5702 * Obtains the maximum volume allowed for a volume type. This method uses an asynchronous callback to return the query result. 5703 * @param { AudioVolumeType } volumeType - Audio volume type. 5704 * @param { AsyncCallback<number> } callback - Callback used to return the maximum volume. 5705 * @syscap SystemCapability.Multimedia.Audio.Volume 5706 * @crossplatform 5707 * @since 12 5708 * @deprecated since 20 5709 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getMaxVolumeByStream 5710 */ 5711 getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 5712 /** 5713 * Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result. 5714 * @param { AudioVolumeType } volumeType - Audio stream type. 5715 * @returns { Promise<number> } Promise used to return the maximum volume. 5716 * @syscap SystemCapability.Multimedia.Audio.Volume 5717 * @since 9 5718 */ 5719 /** 5720 * Obtains the maximum volume allowed for a volume type. This method uses a promise to return the query result. 5721 * @param { AudioVolumeType } volumeType - Audio volume type. 5722 * @returns { Promise<number> } Promise used to return the maximum volume. 5723 * @syscap SystemCapability.Multimedia.Audio.Volume 5724 * @crossplatform 5725 * @since 12 5726 * @deprecated since 20 5727 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getMaxVolumeByStream 5728 */ 5729 getMaxVolume(volumeType: AudioVolumeType): Promise<number>; 5730 /** 5731 * Obtains the maximum volume allowed for a stream. 5732 * @param { AudioVolumeType } volumeType - Audio stream type. 5733 * @returns { number } Max volume level. 5734 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5735 * 1.Mandatory parameters are left unspecified; 5736 * 2.Incorrect parameter types. 5737 * @throws { BusinessError } 6800101 - Parameter verification failed. 5738 * @syscap SystemCapability.Multimedia.Audio.Volume 5739 * @since 10 5740 */ 5741 /** 5742 * Obtains the maximum volume allowed for a volume type. 5743 * @param { AudioVolumeType } volumeType - Audio volume type. 5744 * @returns { number } Max volume level. 5745 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5746 * 1.Mandatory parameters are left unspecified; 5747 * 2.Incorrect parameter types. 5748 * @throws { BusinessError } 6800101 - Parameter verification failed. 5749 * @syscap SystemCapability.Multimedia.Audio.Volume 5750 * @crossplatform 5751 * @since 12 5752 * @deprecated since 20 5753 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getMaxVolumeByStream 5754 */ 5755 getMaxVolumeSync(volumeType: AudioVolumeType): number; 5756 5757 /** 5758 * Mutes a stream. This method uses an asynchronous callback to return the result. 5759 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5760 * @param { AudioVolumeType } volumeType - Audio stream type. 5761 * @param { boolean } mute - Mute status to set. The value true means to mute the stream, and false means the opposite. 5762 * @param { AsyncCallback<void> } callback - Callback used to return the result. 5763 * @syscap SystemCapability.Multimedia.Audio.Volume 5764 * @systemapi 5765 * @since 9 5766 */ 5767 mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void; 5768 /** 5769 * Mutes a stream. This method uses a promise to return the result. 5770 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5771 * @param { AudioVolumeType } volumeType - Audio stream type. 5772 * @param { boolean } mute - Mute status to set. The value true means to mute the stream, and false means the opposite. 5773 * @returns { Promise<void> } Promise used to return the result. 5774 * @syscap SystemCapability.Multimedia.Audio.Volume 5775 * @systemapi 5776 * @since 9 5777 */ 5778 mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>; 5779 5780 /** 5781 * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. 5782 * @param { AudioVolumeType } volumeType - Audio stream type. 5783 * @param { AsyncCallback<boolean> } callback - Callback used to return the mute status of the stream. The 5784 * value true means that the stream is muted, and false means the opposite. 5785 * @syscap SystemCapability.Multimedia.Audio.Volume 5786 * @since 9 5787 */ 5788 /** 5789 * Checks whether a volume type is muted. This method uses an asynchronous callback to return the query result. 5790 * @param { AudioVolumeType } volumeType - Audio volume type. 5791 * @param { AsyncCallback<boolean> } callback - Callback used to return the mute status of the volume type. The 5792 * value true means that the volume type is muted, and false means the opposite. 5793 * @syscap SystemCapability.Multimedia.Audio.Volume 5794 * @crossplatform 5795 * @since 12 5796 * @deprecated since 20 5797 * @useinstead ohos.multimedia.audio.AudioVolumeManager#isSystemMutedForStream 5798 */ 5799 isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 5800 /** 5801 * Checks whether a stream is muted. This method uses a promise to return the result. 5802 * @param { AudioVolumeType } volumeType - Audio stream type. 5803 * @returns { Promise<boolean> } Promise used to return the mute status of the stream. The value true 5804 * means that the stream is muted, and false means the opposite. 5805 * @syscap SystemCapability.Multimedia.Audio.Volume 5806 * @since 9 5807 */ 5808 /** 5809 * Checks whether a volume type is muted. This method uses a promise to return the result. 5810 * @param { AudioVolumeType } volumeType - Audio volume type. 5811 * @returns { Promise<boolean> } Promise used to return the mute status of the volume type. The value true 5812 * means that the volume type is muted, and false means the opposite. 5813 * @syscap SystemCapability.Multimedia.Audio.Volume 5814 * @crossplatform 5815 * @since 12 5816 * @deprecated since 20 5817 * @useinstead ohos.multimedia.audio.AudioVolumeManager#isSystemMutedForStream 5818 */ 5819 isMute(volumeType: AudioVolumeType): Promise<boolean>; 5820 /** 5821 * Checks whether a stream is muted. 5822 * @param { AudioVolumeType } volumeType - Audio stream type. 5823 * @returns { boolean } The mute status of the stream. The value true 5824 * means that the stream is muted, and false means the opposite. 5825 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5826 * 1.Mandatory parameters are left unspecified; 5827 * 2.Incorrect parameter types. 5828 * @throws { BusinessError } 6800101 - Parameter verification failed. 5829 * @syscap SystemCapability.Multimedia.Audio.Volume 5830 * @since 10 5831 */ 5832 /** 5833 * Checks whether a volume type is muted. 5834 * @param { AudioVolumeType } volumeType - Audio volume type. 5835 * @returns { boolean } The mute status of the volume type. The value true 5836 * means that the volume type is muted, and false means the opposite. 5837 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5838 * 1.Mandatory parameters are left unspecified; 5839 * 2.Incorrect parameter types. 5840 * @throws { BusinessError } 6800101 - Parameter verification failed. 5841 * @syscap SystemCapability.Multimedia.Audio.Volume 5842 * @crossplatform 5843 * @since 12 5844 * @deprecated since 20 5845 * @useinstead ohos.multimedia.audio.AudioVolumeManager#isSystemMutedForStream 5846 */ 5847 isMuteSync(volumeType: AudioVolumeType): boolean; 5848 5849 /** 5850 * Sets the ringer mode. This method uses an asynchronous callback to return the result. 5851 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5852 * @param { AudioRingMode } mode - Ringer mode. 5853 * @param { AsyncCallback<void> } callback - Callback used to return the result. 5854 * @syscap SystemCapability.Multimedia.Audio.Volume 5855 * @systemapi 5856 * @since 9 5857 */ 5858 setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void; 5859 /** 5860 * Sets the ringer mode. This method uses a promise to return the result. 5861 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 5862 * @param { AudioRingMode } mode - Ringer mode. 5863 * @returns { Promise<void> } Promise used to return the result. 5864 * @syscap SystemCapability.Multimedia.Audio.Volume 5865 * @systemapi 5866 * @since 9 5867 */ 5868 setRingerMode(mode: AudioRingMode): Promise<void>; 5869 5870 /** 5871 * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. 5872 * @param { AsyncCallback<AudioRingMode> } callback - Callback used to return the ringer mode. 5873 * @syscap SystemCapability.Multimedia.Audio.Volume 5874 * @since 9 5875 */ 5876 /** 5877 * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. 5878 * @param { AsyncCallback<AudioRingMode> } callback - Callback used to return the ringer mode. 5879 * @syscap SystemCapability.Multimedia.Audio.Volume 5880 * @crossplatform 5881 * @since 12 5882 */ 5883 getRingerMode(callback: AsyncCallback<AudioRingMode>): void; 5884 /** 5885 * Obtains the ringer mode. This method uses a promise to return the query result. 5886 * @returns { Promise<AudioRingMode> } Promise used to return the ringer mode. 5887 * @syscap SystemCapability.Multimedia.Audio.Volume 5888 * @since 9 5889 */ 5890 /** 5891 * Obtains the ringer mode. This method uses a promise to return the query result. 5892 * @returns { Promise<AudioRingMode> } Promise used to return the ringer mode. 5893 * @syscap SystemCapability.Multimedia.Audio.Volume 5894 * @crossplatform 5895 * @since 12 5896 */ 5897 getRingerMode(): Promise<AudioRingMode>; 5898 /** 5899 * Obtains the ringer mode. 5900 * @returns { AudioRingMode } Current ringer mode. 5901 * @syscap SystemCapability.Multimedia.Audio.Volume 5902 * @since 10 5903 */ 5904 /** 5905 * Obtains the ringer mode. 5906 * @returns { AudioRingMode } Current ringer mode. 5907 * @syscap SystemCapability.Multimedia.Audio.Volume 5908 * @crossplatform 5909 * @since 12 5910 */ 5911 getRingerModeSync(): AudioRingMode; 5912 5913 /** 5914 * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. 5915 * @param { 'ringerModeChange' } type - Type of the event to listen for. Only the ringerModeChange event is supported. 5916 * @param { Callback<AudioRingMode> } callback - Callback used to get the updated ringer mode. 5917 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5918 * 1.Mandatory parameters are left unspecified; 5919 * 2.Incorrect parameter types. 5920 * @throws { BusinessError } 6800101 - Parameter verification failed. 5921 * @syscap SystemCapability.Multimedia.Audio.Volume 5922 * @since 9 5923 */ 5924 on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void; 5925 5926 /** 5927 * Unsubscribes to the ringer mode state change events. 5928 * @param { 'ringerModeChange' } type - Type of the event to listen for. 5929 * @param { Callback<AudioRingMode> } callback - Callback used to get the updated ringer mode. 5930 * @throws { BusinessError } 6800101 - Parameter verification failed. 5931 * @syscap SystemCapability.Multimedia.Audio.Volume 5932 * @since 18 5933 */ 5934 off(type: 'ringerModeChange', callback?: Callback<AudioRingMode>): void; 5935 5936 /** 5937 * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. 5938 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5939 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 5940 * @param { AsyncCallback<void> } callback - Callback used to return the result. 5941 * @syscap SystemCapability.Multimedia.Audio.Volume 5942 * @since 9 5943 * @deprecated since 11 5944 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicMute 5945 */ 5946 setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void; 5947 /** 5948 * Mutes or unmutes the microphone. This method uses a promise to return the result. 5949 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5950 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 5951 * @returns { Promise<void> } Promise used to return the result. 5952 * @syscap SystemCapability.Multimedia.Audio.Volume 5953 * @since 9 5954 * @deprecated since 11 5955 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicMute 5956 */ 5957 setMicrophoneMute(mute: boolean): Promise<void>; 5958 5959 /** 5960 * Mutes or unmutes the microphone. This method uses a promise to return the result. 5961 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 5962 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 5963 * @returns { Promise<void> } Promise used to return the result. 5964 * @throws { BusinessError } 201 - Permission denied. 5965 * @throws { BusinessError } 202 - Not system App. 5966 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5967 * 1.Mandatory parameters are left unspecified; 5968 * 2.Incorrect parameter types. 5969 * @throws { BusinessError } 6800101 - Parameter verification failed. 5970 * @syscap SystemCapability.Multimedia.Audio.Volume 5971 * @systemapi 5972 * @since 11 5973 */ 5974 setMicMute(mute: boolean): Promise<void>; 5975 5976 /** 5977 * Mutes or unmutes the microphone. This method uses a promise to return the result. 5978 * @permission ohos.permission.MICROPHONE_CONTROL 5979 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 5980 * @param { PolicyType } type - Mute status to set. This value represents the caller's type such as EDM or privacy. 5981 * @returns { Promise<void> } Promise used to return the result. 5982 * @throws { BusinessError } 201 - Permission denied. 5983 * @throws { BusinessError } 202 - Not system App. 5984 * @throws { BusinessError } 401 - Parameter error. Possible causes: 5985 * 1.Mandatory parameters missing. 5986 * 2.Incorrect parameter types. 5987 * @throws { BusinessError } 6800101 - Parameter verification failed. 5988 * @syscap SystemCapability.Multimedia.Audio.Volume 5989 * @systemapi 5990 * @since 12 5991 */ 5992 setMicMutePersistent(mute: boolean, type: PolicyType): Promise<void>; 5993 5994 /** 5995 * Checks whether the persistent microphone status is muted. 5996 * @permission ohos.permission.MICROPHONE_CONTROL 5997 * @returns { boolean } Returns microphone persistent mute status. 5998 * true: The persistent mic mute is enabled in the current system. 5999 * false: The persistent mic mute is disabled in the current system. 6000 * @throws { BusinessError } 201 - Permission denied. 6001 * @throws { BusinessError } 202 - Not system App. 6002 * @syscap SystemCapability.Multimedia.Audio.Volume 6003 * @systemapi 6004 * @since 12 6005 */ 6006 isPersistentMicMute(): boolean; 6007 6008 /** 6009 * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. 6010 * @param { AsyncCallback<boolean> } callback - used to return the mute status of the microphone. The value 6011 * true means that the microphone is muted, and false means the opposite. 6012 * @syscap SystemCapability.Multimedia.Audio.Volume 6013 * @since 9 6014 */ 6015 /** 6016 * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. 6017 * @param { AsyncCallback<boolean> } callback - used to return the mute status of the microphone. The value 6018 * true means that the microphone is muted, and false means the opposite. 6019 * @syscap SystemCapability.Multimedia.Audio.Volume 6020 * @crossplatform 6021 * @since 12 6022 */ 6023 isMicrophoneMute(callback: AsyncCallback<boolean>): void; 6024 /** 6025 * Checks whether the microphone is muted. This method uses a promise to return the query result. 6026 * @returns { Promise<boolean> } Promise used to return the mute status of the microphone. The value true 6027 * means that the microphone is muted, and false means the opposite. 6028 * @syscap SystemCapability.Multimedia.Audio.Volume 6029 * @since 9 6030 */ 6031 /** 6032 * Checks whether the microphone is muted. This method uses a promise to return the query result. 6033 * @returns { Promise<boolean> } Promise used to return the mute status of the microphone. The value true 6034 * means that the microphone is muted, and false means the opposite. 6035 * @syscap SystemCapability.Multimedia.Audio.Volume 6036 * @crossplatform 6037 * @since 12 6038 */ 6039 isMicrophoneMute(): Promise<boolean>; 6040 /** 6041 * Checks whether the microphone is muted. 6042 * @returns { boolean } The mute status of the microphone. The value true 6043 * means that the microphone is muted, and false means the opposite. 6044 * @syscap SystemCapability.Multimedia.Audio.Volume 6045 * @since 10 6046 */ 6047 /** 6048 * Checks whether the microphone is muted. 6049 * @returns { boolean } The mute status of the microphone. The value true 6050 * means that the microphone is muted, and false means the opposite. 6051 * @syscap SystemCapability.Multimedia.Audio.Volume 6052 * @crossplatform 6053 * @since 12 6054 */ 6055 isMicrophoneMuteSync(): boolean; 6056 6057 /** 6058 * Listens for system microphone state change events. This method uses a callback to get microphone change events. 6059 * @param { 'micStateChange' } type - Type of the event to listen for. Only the micStateChange event is supported. 6060 * @param { Callback<MicStateChangeEvent> } callback - Callback used to get the system microphone state change event. 6061 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6062 * 1.Mandatory parameters are left unspecified; 6063 * 2.Incorrect parameter types. 6064 * @throws { BusinessError } 6800101 - Parameter verification failed. 6065 * @syscap SystemCapability.Multimedia.Audio.Volume 6066 * @since 9 6067 */ 6068 on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void; 6069 6070 /** 6071 * Unsubscribes to the microphone state change events. 6072 * @param { 'micStateChange' } type - Type of the event to listen for. 6073 * @param { Callback<MicStateChangeEvent> } callback - Callback used to get the system microphone state change event. 6074 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6075 * 1.Mandatory parameters missing; 6076 * 2.Incorrect parameter types. 6077 * @throws { BusinessError } 6800101 - Parameter verification failed. 6078 * @syscap SystemCapability.Multimedia.Audio.Volume 6079 * @since 12 6080 */ 6081 off(type: 'micStateChange', callback?: Callback<MicStateChangeEvent>): void; 6082 6083 /** 6084 * Gets if this volume group is volume unadjustable. 6085 * @returns { boolean } Whether it is volume unadjustable. 6086 * @syscap SystemCapability.Multimedia.Audio.Volume 6087 * @since 10 6088 */ 6089 /** 6090 * Gets if this volume group is volume unadjustable. 6091 * @returns { boolean } Whether it is volume unadjustable. 6092 * @syscap SystemCapability.Multimedia.Audio.Volume 6093 * @crossplatform 6094 * @since 12 6095 */ 6096 isVolumeUnadjustable(): boolean; 6097 6098 /** 6099 * Adjusts system volume by step, volume type is decided by system. 6100 * This method uses an asynchronous callback to return the result. 6101 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 6102 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 6103 * @param { AsyncCallback<void> } callback - Callback used to return the result. 6104 * @throws { BusinessError } 201 - Permission denied. 6105 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6106 * 1.Mandatory parameters are left unspecified; 6107 * 2.Incorrect parameter types. 6108 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 6109 * @throws { BusinessError } 6800301 - System error. Return by callback. 6110 * @syscap SystemCapability.Multimedia.Audio.Volume 6111 * @systemapi 6112 * @since 10 6113 */ 6114 adjustVolumeByStep(adjustType: VolumeAdjustType, callback: AsyncCallback<void>): void; 6115 /** 6116 * Adjusts system volume by step, volume type is decided by system. 6117 * This method uses a promise to return the result. 6118 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 6119 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 6120 * @returns { Promise<void> } Promise used to return the result. 6121 * @throws { BusinessError } 201 - Permission denied. 6122 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6123 * 1.Mandatory parameters are left unspecified; 6124 * 2.Incorrect parameter types. 6125 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 6126 * @throws { BusinessError } 6800301 - System error. Return by promise. 6127 * @syscap SystemCapability.Multimedia.Audio.Volume 6128 * @systemapi 6129 * @since 10 6130 */ 6131 adjustVolumeByStep(adjustType: VolumeAdjustType): Promise<void>; 6132 6133 /** 6134 * Adjusts system volume by step for target volume type. 6135 * This method uses an asynchronous callback to return the result. 6136 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 6137 * @param { AudioVolumeType } volumeType - Audio volume type. 6138 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 6139 * @param { AsyncCallback<void> } callback - Callback used to return the result. 6140 * @throws { BusinessError } 201 - Permission denied. 6141 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6142 * 1.Mandatory parameters are left unspecified; 6143 * 2.Incorrect parameter types. 6144 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 6145 * @throws { BusinessError } 6800301 - System error. Return by callback. 6146 * @syscap SystemCapability.Multimedia.Audio.Volume 6147 * @systemapi 6148 * @since 10 6149 */ 6150 adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType, callback: AsyncCallback<void>): void; 6151 /** 6152 * Adjusts system volume by step for target volume type. 6153 * This method uses a promise to return the result. 6154 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 6155 * @param { AudioVolumeType } volumeType - Audio volume type. 6156 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 6157 * @returns { Promise<void> } Promise used to return the result. 6158 * @throws { BusinessError } 201 - Permission denied. 6159 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6160 * 1.Mandatory parameters are left unspecified; 6161 * 2.Incorrect parameter types. 6162 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 6163 * @throws { BusinessError } 6800301 - System error. Return by promise. 6164 * @syscap SystemCapability.Multimedia.Audio.Volume 6165 * @systemapi 6166 * @since 10 6167 */ 6168 adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType): Promise<void>; 6169 6170 /** 6171 * Gets the volume db value that system calculate by volume type, volume level and device type. 6172 * This method uses an asynchronous callback to return the result. 6173 * @param { AudioVolumeType } volumeType - Audio volume type. 6174 * @param { number } volumeLevel - Volume level to set. 6175 * @param { DeviceType } device - Output device type. 6176 * @param { AsyncCallback<number> } callback - Callback used to return the result. 6177 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6178 * 1.Mandatory parameters are left unspecified; 6179 * 2.Incorrect parameter types. 6180 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 6181 * @throws { BusinessError } 6800301 - System error. Return by callback. 6182 * @syscap SystemCapability.Multimedia.Audio.Volume 6183 * @since 10 6184 */ 6185 /** 6186 * Gets the volume db value that system calculate by volume type, volume level and device type. 6187 * This method uses an asynchronous callback to return the result. 6188 * @param { AudioVolumeType } volumeType - Audio volume type. 6189 * @param { number } volumeLevel - Volume level to set. 6190 * @param { DeviceType } device - Output device type. 6191 * @param { AsyncCallback<number> } callback - Callback used to return the result. 6192 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6193 * 1.Mandatory parameters are left unspecified; 6194 * 2.Incorrect parameter types. 6195 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 6196 * @throws { BusinessError } 6800301 - System error. Return by callback. 6197 * @syscap SystemCapability.Multimedia.Audio.Volume 6198 * @crossplatform 6199 * @since 12 6200 * @deprecated since 20 6201 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getVolumeInUnitOfDbByStream 6202 */ 6203 getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType, callback: AsyncCallback<number>): void; 6204 /** 6205 * Gets the volume db value that system calculate by volume type, volume level and device type. 6206 * This method uses a promise to return the result. 6207 * @param { AudioVolumeType } volumeType - Audio volume type. 6208 * @param { number } volumeLevel - Volume level to set. 6209 * @param { DeviceType } device - Output device type. 6210 * @returns { Promise<number> } Promise used to return the result. 6211 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6212 * 1.Mandatory parameters are left unspecified; 6213 * 2.Incorrect parameter types. 6214 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 6215 * @throws { BusinessError } 6800301 - System error. Return by promise. 6216 * @syscap SystemCapability.Multimedia.Audio.Volume 6217 * @since 10 6218 */ 6219 /** 6220 * Gets the volume db value that system calculate by volume type, volume level and device type. 6221 * This method uses a promise to return the result. 6222 * @param { AudioVolumeType } volumeType - Audio volume type. 6223 * @param { number } volumeLevel - Volume level to set. 6224 * @param { DeviceType } device - Output device type. 6225 * @returns { Promise<number> } Promise used to return the result. 6226 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6227 * 1.Mandatory parameters are left unspecified; 6228 * 2.Incorrect parameter types. 6229 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 6230 * @throws { BusinessError } 6800301 - System error. Return by promise. 6231 * @syscap SystemCapability.Multimedia.Audio.Volume 6232 * @crossplatform 6233 * @since 12 6234 * @deprecated since 20 6235 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getVolumeInUnitOfDbByStream 6236 */ 6237 getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType): Promise<number>; 6238 /** 6239 * Gets the volume db value that system calculate by volume type, volume level and device type. 6240 * @param { AudioVolumeType } volumeType - Audio volume type. 6241 * @param { number } volumeLevel - Volume level to set. 6242 * @param { DeviceType } device - Output device type. 6243 * @returns { number } The system volume in dB. 6244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6245 * 1.Mandatory parameters are left unspecified; 6246 * 2.Incorrect parameter types. 6247 * @throws { BusinessError } 6800101 - Parameter verification failed. 6248 * @syscap SystemCapability.Multimedia.Audio.Volume 6249 * @since 10 6250 */ 6251 /** 6252 * Gets the volume db value that system calculate by volume type, volume level and device type. 6253 * @param { AudioVolumeType } volumeType - Audio volume type. 6254 * @param { number } volumeLevel - Volume level to set. 6255 * @param { DeviceType } device - Output device type. 6256 * @returns { number } The system volume in dB. 6257 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6258 * 1.Mandatory parameters are left unspecified; 6259 * 2.Incorrect parameter types. 6260 * @throws { BusinessError } 6800101 - Parameter verification failed. 6261 * @syscap SystemCapability.Multimedia.Audio.Volume 6262 * @crossplatform 6263 * @since 12 6264 * @deprecated since 20 6265 * @useinstead ohos.multimedia.audio.AudioVolumeManager#getVolumeInUnitOfDbByStream 6266 */ 6267 getSystemVolumeInDbSync(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType): number; 6268 6269 /** 6270 * Gets the max amplitude value for a specific input device. 6271 * This method uses a promise to return the result. 6272 * @param { AudioDeviceDescriptor } inputDevice - the target device. 6273 * @returns { Promise<number> } Promise used to return the max amplitude value. 6274 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6275 * 1.Mandatory parameters are left unspecified; 6276 * 2.Incorrect parameter types. 6277 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 6278 * @throws { BusinessError } 6800301 - System error. Return by promise. 6279 * @syscap SystemCapability.Multimedia.Audio.Volume 6280 * @since 12 6281 */ 6282 getMaxAmplitudeForInputDevice(inputDevice: AudioDeviceDescriptor): Promise<number>; 6283 /** 6284 * Gets the max amplitude value for a specific output device. 6285 * This method uses a promise to return the result. 6286 * @param { AudioDeviceDescriptor } outputDevice - the target device. 6287 * @returns { Promise<number> } Promise used to return the max amplitude value. 6288 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6289 * 1.Mandatory parameters are left unspecified; 6290 * 2.Incorrect parameter types. 6291 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 6292 * @throws { BusinessError } 6800301 - System error. Return by promise. 6293 * @syscap SystemCapability.Multimedia.Audio.Volume 6294 * @since 12 6295 */ 6296 getMaxAmplitudeForOutputDevice(outputDevice: AudioDeviceDescriptor): Promise<number>; 6297 } 6298 6299 /** 6300 * This interface is used to notify the listener of any device Spatialization or Head Tracking enable state change. 6301 * @interface AudioSpatialEnabledStateForDevice 6302 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6303 * @systemapi 6304 * @since 12 6305 */ 6306 interface AudioSpatialEnabledStateForDevice { 6307 /** 6308 * Audio device description. 6309 * @type { AudioDeviceDescriptor } 6310 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6311 * @systemapi 6312 * @since 12 6313 */ 6314 deviceDescriptor: AudioDeviceDescriptor; 6315 /** 6316 * Spatialization or Head Tracking enable state. 6317 * @type { boolean } 6318 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6319 * @systemapi 6320 * @since 12 6321 */ 6322 enabled: boolean; 6323 } 6324 6325 /** 6326 * Implements audio spatialization management. 6327 * @typedef AudioSpatializationManager 6328 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6329 * @since 18 6330 */ 6331 interface AudioSpatializationManager { 6332 /** 6333 * Checks whether spatialization is supported by system. 6334 * @returns { boolean } Whether spatialization is supported by system. 6335 * @throws { BusinessError } 202 - Not system App. 6336 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6337 * @systemapi 6338 * @since 11 6339 */ 6340 isSpatializationSupported(): boolean; 6341 6342 /** 6343 * Checks whether spatialization is supported by the specified device. 6344 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device description. 6345 * @returns { boolean } Whether spatialization is supported by the specified device. 6346 * @throws { BusinessError } 202 - Not system App. 6347 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6348 * 1.Mandatory parameters are left unspecified; 6349 * 2.Incorrect parameter types. 6350 * @throws { BusinessError } 6800101 - Parameter verification failed. 6351 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6352 * @systemapi 6353 * @since 11 6354 */ 6355 isSpatializationSupportedForDevice(deviceDescriptor: AudioDeviceDescriptor): boolean; 6356 6357 /** 6358 * Checks whether head tracking is supported by system. 6359 * @returns { boolean } Whether head tracking is supported by system. 6360 * @throws { BusinessError } 202 - Not system App. 6361 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6362 * @systemapi 6363 * @since 11 6364 */ 6365 isHeadTrackingSupported(): boolean; 6366 6367 /** 6368 * Checks whether head tracking is supported by the specified device. 6369 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device description. 6370 * @returns { boolean } Whether head tracking is supported by the specified device. 6371 * @throws { BusinessError } 202 - Not system App. 6372 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6373 * 1.Mandatory parameters are left unspecified; 6374 * 2.Incorrect parameter types. 6375 * @throws { BusinessError } 6800101 - Parameter verification failed. 6376 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6377 * @systemapi 6378 * @since 11 6379 */ 6380 isHeadTrackingSupportedForDevice(deviceDescriptor: AudioDeviceDescriptor): boolean; 6381 6382 /** 6383 * Sets the spatialization enabled or disabled. This method uses an asynchronous callback to return the result. 6384 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6385 * @param { boolean } enable - Spatialization enable state. 6386 * @param { AsyncCallback<void> } callback - Callback used to return the result. 6387 * @throws { BusinessError } 201 - Permission denied. Return by callback. 6388 * @throws { BusinessError } 202 - Not system App. 6389 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6390 * 1.Mandatory parameters are left unspecified; 6391 * 2.Incorrect parameter types. 6392 * @throws { BusinessError } 6800101 - Parameter verification failed. 6393 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6394 * @systemapi 6395 * @since 11 6396 * @deprecated since 12 6397 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#setSpatializationEnabled 6398 */ 6399 setSpatializationEnabled(enable: boolean, callback: AsyncCallback<void>): void; 6400 /** 6401 * Sets the spatialization enabled or disabled. This method uses a promise to return the result. 6402 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6403 * @param { boolean } enable - Spatialization enable state. 6404 * @returns { Promise<void> } Promise used to return the result. 6405 * @throws { BusinessError } 201 - Permission denied. Return by promise. 6406 * @throws { BusinessError } 202 - Not system App. 6407 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6408 * 1.Mandatory parameters are left unspecified; 6409 * 2.Incorrect parameter types. 6410 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6411 * @systemapi 6412 * @since 11 6413 * @deprecated since 12 6414 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#setSpatializationEnabled 6415 */ 6416 setSpatializationEnabled(enable: boolean): Promise<void>; 6417 /** 6418 * Sets the spatialization enabled or disabled by the specified device. 6419 * This method uses a promise to return the result. 6420 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6421 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device description. 6422 * @param { boolean } enabled - Spatialization enable state. 6423 * @returns { Promise<void> } Promise used to return the result. 6424 * @throws { BusinessError } 201 - Permission denied. Return by promise. 6425 * @throws { BusinessError } 202 - Not system App. 6426 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6427 * 1.Mandatory parameters are left unspecified; 6428 * 2.Incorrect parameter types. 6429 * @throws { BusinessError } 6800101 - Parameter verification failed. 6430 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6431 * @systemapi 6432 * @since 12 6433 */ 6434 setSpatializationEnabled(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise<void>; 6435 6436 /** 6437 * Checks whether the spatialization is enabled. 6438 * @returns { boolean } Whether the spatialization is enabled. 6439 * @throws { BusinessError } 202 - Not system App. 6440 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6441 * @systemapi 6442 * @since 11 6443 * @deprecated since 12 6444 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#isSpatializationEnabled 6445 */ 6446 isSpatializationEnabled(): boolean; 6447 /** 6448 * Checks whether the spatialization is enabled by the specified device. 6449 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device description. 6450 * @returns { boolean } Whether the spatialization is enabled by the specified device. 6451 * @throws { BusinessError } 202 - Not system App. 6452 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6453 * 1.Mandatory parameters are left unspecified; 6454 * 2.Incorrect parameter types. 6455 * @throws { BusinessError } 6800101 - Parameter verification failed. 6456 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6457 * @systemapi 6458 * @since 12 6459 */ 6460 isSpatializationEnabled(deviceDescriptor: AudioDeviceDescriptor): boolean; 6461 6462 /** 6463 * Subscribes to the spatialization enable state change events. When the spatialization enable state changes, 6464 * registered clients will receive the callback. 6465 * @param { 'spatializationEnabledChange' } type - Type of the event to listen for. 6466 * @param { Callback<boolean> } callback - Callback used to get the spatialization enable state. 6467 * @throws { BusinessError } 202 - Not system App. 6468 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6469 * 1.Mandatory parameters are left unspecified; 6470 * 2.Incorrect parameter types. 6471 * @throws { BusinessError } 6800101 - Parameter verification failed. 6472 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6473 * @systemapi 6474 * @since 11 6475 * @deprecated since 12 6476 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#on 6477 */ 6478 on(type: 'spatializationEnabledChange', callback: Callback<boolean>): void; 6479 /** 6480 * Subscribes to the spatialization enable state change events by the specified device. 6481 * When the spatialization enable state changes, registered clients will receive the callback. 6482 * @param { 'spatializationEnabledChangeForAnyDevice' } type - Type of the event to listen for. 6483 * @param { Callback<AudioSpatialEnabledStateForDevice> } callback - Callback used to get the spatialization enable state by the specified device. 6484 * @throws { BusinessError } 202 - Not system App. 6485 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6486 * 1.Mandatory parameters are left unspecified; 6487 * 2.Incorrect parameter types. 6488 * @throws { BusinessError } 6800101 - Parameter verification failed. 6489 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6490 * @systemapi 6491 * @since 12 6492 */ 6493 on(type: 'spatializationEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice>): void; 6494 6495 /** 6496 * Unsubscribes to the spatialization enable state change events. 6497 * @param { 'spatializationEnabledChange' } type - Type of the event to listen for. 6498 * @param { Callback<boolean> } callback - Callback used to get the spatialization enable state. 6499 * @throws { BusinessError } 202 - Not system App. 6500 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6501 * 1.Mandatory parameters are left unspecified; 6502 * 2.Incorrect parameter types. 6503 * @throws { BusinessError } 6800101 - Parameter verification failed. 6504 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6505 * @systemapi 6506 * @since 11 6507 * @deprecated since 12 6508 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#off 6509 */ 6510 off(type: 'spatializationEnabledChange', callback?: Callback<boolean>): void; 6511 /** 6512 * Unsubscribes to the spatialization enable state change events by the specified device. 6513 * @param { 'spatializationEnabledChangeForAnyDevice' } type - Type of the event to listen for. 6514 * @param { Callback<AudioSpatialEnabledStateForDevice> } callback - Callback used to get the spatialization enable state by the specified device. 6515 * @throws { BusinessError } 202 - Not system App. 6516 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6517 * 1.Mandatory parameters are left unspecified; 6518 * 2.Incorrect parameter types. 6519 * @throws { BusinessError } 6800101 - Parameter verification failed. 6520 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6521 * @systemapi 6522 * @since 12 6523 */ 6524 off(type: 'spatializationEnabledChangeForAnyDevice', callback?: Callback<AudioSpatialEnabledStateForDevice>): void; 6525 6526 /** 6527 * Sets the head tracking enabled or disabled. This method uses an asynchronous callback to return the result. 6528 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6529 * @param { boolean } enable - Head tracking enable state. 6530 * @param { AsyncCallback<void> } callback - Callback used to return the result. 6531 * @throws { BusinessError } 201 - Permission denied. Return by callback. 6532 * @throws { BusinessError } 202 - Not system App. 6533 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6534 * 1.Mandatory parameters are left unspecified; 6535 * 2.Incorrect parameter types. 6536 * @throws { BusinessError } 6800101 - Parameter verification failed. 6537 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6538 * @systemapi 6539 * @since 11 6540 * @deprecated since 12 6541 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#setHeadTrackingEnabled 6542 */ 6543 setHeadTrackingEnabled(enable: boolean, callback: AsyncCallback<void>): void; 6544 /** 6545 * Sets the head tracking enabled or disabled. This method uses a promise to return the result. 6546 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6547 * @param { boolean } enable - Head tracking enable state. 6548 * @returns { Promise<void> } Promise used to return the result. 6549 * @throws { BusinessError } 201 - Permission denied. Return by promise. 6550 * @throws { BusinessError } 202 - Not system App. 6551 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6552 * 1.Mandatory parameters are left unspecified; 6553 * 2.Incorrect parameter types. 6554 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6555 * @systemapi 6556 * @since 11 6557 * @deprecated since 12 6558 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#setHeadTrackingEnabled 6559 */ 6560 setHeadTrackingEnabled(enable: boolean): Promise<void>; 6561 /** 6562 * Sets the head tracking enabled or disabled by the specified device. 6563 * This method uses a promise to return the result. 6564 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6565 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device description. 6566 * @param { boolean } enabled - Head tracking enable state. 6567 * @returns { Promise<void> } Promise used to return the result. 6568 * @throws { BusinessError } 201 - Permission denied. Return by promise. 6569 * @throws { BusinessError } 202 - Not system App. 6570 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6571 * 1.Mandatory parameters are left unspecified; 6572 * 2.Incorrect parameter types. 6573 * @throws { BusinessError } 6800101 - Parameter verification failed. 6574 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6575 * @systemapi 6576 * @since 12 6577 */ 6578 setHeadTrackingEnabled(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise<void>; 6579 6580 /** 6581 * Checks whether the head tracking is enabled. 6582 * @returns { boolean } Whether the head tracking is enabled. 6583 * @throws { BusinessError } 202 - Not system App. 6584 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6585 * @systemapi 6586 * @since 11 6587 * @deprecated since 12 6588 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#isHeadTrackingEnabled 6589 */ 6590 isHeadTrackingEnabled(): boolean; 6591 /** 6592 * Checks whether the head tracking is enabled by the specified device. 6593 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device description. 6594 * @returns { boolean } Whether the head tracking is enabled by the specified device. 6595 * @throws { BusinessError } 202 - Not system App. 6596 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6597 * 1.Mandatory parameters are left unspecified; 6598 * 2.Incorrect parameter types. 6599 * @throws { BusinessError } 6800101 - Parameter verification failed. 6600 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6601 * @systemapi 6602 * @since 12 6603 */ 6604 isHeadTrackingEnabled(deviceDescriptor: AudioDeviceDescriptor): boolean; 6605 6606 /** 6607 * Subscribes to the head tracking enable state change events. When the head tracking enable state changes, 6608 * registered clients will receive the callback. 6609 * @param { 'headTrackingEnabledChange' } type - Type of the event to listen for. 6610 * @param { Callback<boolean> } callback - Callback used to get the head tracking enable state. 6611 * @throws { BusinessError } 202 - Not system App. 6612 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6613 * 1.Mandatory parameters are left unspecified; 6614 * 2.Incorrect parameter types. 6615 * @throws { BusinessError } 6800101 - Parameter verification failed. 6616 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6617 * @systemapi 6618 * @since 11 6619 * @deprecated since 12 6620 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#on 6621 */ 6622 on(type: 'headTrackingEnabledChange', callback: Callback<boolean>): void; 6623 /** 6624 * Subscribes to the head tracking enable state change events by the specified device. 6625 * When the head tracking enable state changes, registered clients will receive the callback. 6626 * @param { 'headTrackingEnabledChangeForAnyDevice' } type - Type of the event to listen for. 6627 * @param { Callback<AudioSpatialEnabledStateForDevice> } callback - Callback used to get the head tracking enable state by the specified device. 6628 * @throws { BusinessError } 202 - Not system App. 6629 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6630 * 1.Mandatory parameters are left unspecified; 6631 * 2.Incorrect parameter types. 6632 * @throws { BusinessError } 6800101 - Parameter verification failed. 6633 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6634 * @systemapi 6635 * @since 12 6636 */ 6637 on(type: 'headTrackingEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice>): void; 6638 6639 /** 6640 * Unsubscribes to the head tracking enable state change events. 6641 * @param { 'headTrackingEnabledChange' } type - Type of the event to listen for. 6642 * @param { Callback<boolean> } callback - Callback used to get the head tracking enable state. 6643 * @throws { BusinessError } 202 - Not system App. 6644 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6645 * 1.Mandatory parameters are left unspecified; 6646 * 2.Incorrect parameter types. 6647 * @throws { BusinessError } 6800101 - Parameter verification failed. 6648 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6649 * @systemapi 6650 * @since 11 6651 * @deprecated since 12 6652 * @useinstead ohos.multimedia.audio.AudioSpatializationManager#off 6653 */ 6654 off(type: 'headTrackingEnabledChange', callback?: Callback<boolean>): void; 6655 /** 6656 * Unsubscribes to the head tracking enable state change events by the specified device. 6657 * @param { 'headTrackingEnabledChangeForAnyDevice' } type - Type of the event to listen for. 6658 * @param { Callback<AudioSpatialEnabledStateForDevice> } callback - Callback used to get the head tracking enable state by the specified device. 6659 * @throws { BusinessError } 202 - Not system App. 6660 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6661 * 1.Mandatory parameters are left unspecified; 6662 * 2.Incorrect parameter types. 6663 * @throws { BusinessError } 6800101 - Parameter verification failed. 6664 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6665 * @systemapi 6666 * @since 12 6667 */ 6668 off(type: 'headTrackingEnabledChangeForAnyDevice', callback?: Callback<AudioSpatialEnabledStateForDevice>): void; 6669 6670 /** 6671 * Updates the spatial device state. 6672 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6673 * @param { AudioSpatialDeviceState } spatialDeviceState - Spatial device state. 6674 * @throws { BusinessError } 201 - Permission denied. 6675 * @throws { BusinessError } 202 - Not system App. 6676 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6677 * 1.Mandatory parameters are left unspecified; 6678 * 2.Incorrect parameter types. 6679 * @throws { BusinessError } 6800101 - Parameter verification failed. 6680 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6681 * @systemapi 6682 * @since 11 6683 */ 6684 updateSpatialDeviceState(spatialDeviceState: AudioSpatialDeviceState): void; 6685 6686 /** 6687 * Set spatialization rendering scene type. 6688 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6689 * @param { AudioSpatializationSceneType } spatializationSceneType - Spatialization scene type. 6690 * @throws { BusinessError } 201 - Permission denied. 6691 * @throws { BusinessError } 202 - Not system App. 6692 * @throws { BusinessError } 401 - Parameter error. Possible causes: 6693 * 1.Mandatory parameters are left unspecified; 6694 * 2.Incorrect parameter types. 6695 * @throws { BusinessError } 6800101 - Parameter verification failed. 6696 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6697 * @systemapi 6698 * @since 12 6699 */ 6700 setSpatializationSceneType(spatializationSceneType: AudioSpatializationSceneType): void; 6701 6702 /** 6703 * Get spatialization rendering scene type. 6704 * @returns { AudioSpatializationSceneType } Current spatialization rendering scene type. 6705 * @throws { BusinessError } 202 - Not system App. 6706 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6707 * @systemapi 6708 * @since 12 6709 */ 6710 getSpatializationSceneType(): AudioSpatializationSceneType; 6711 6712 /** 6713 * Checks whether the spatialization is enabled by the current device. 6714 * @returns { boolean } Whether the spatialization is enabled by the current device. 6715 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6716 * @since 18 6717 */ 6718 isSpatializationEnabledForCurrentDevice(): boolean; 6719 6720 /** 6721 * Subscribes to the spatialization enable state change events by the current device. 6722 * When the spatialization enable state changes, registered clients will receive the callback. 6723 * @param { 'spatializationEnabledChangeForCurrentDevice' } type - Type of the event to listen for. 6724 * @param { Callback<boolean> } callback - Callback used to get the spatialization enable state. 6725 * @throws { BusinessError } 6800101 - Parameter verification failed. 6726 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6727 * @since 18 6728 */ 6729 on(type: 'spatializationEnabledChangeForCurrentDevice', callback: Callback<boolean>): void; 6730 6731 /** 6732 * Unsubscribes to the spatialization enable state change events by the current device. 6733 * @param { 'spatializationEnabledChangeForCurrentDevice' } type - Type of the event to listen for. 6734 * @param { Callback<boolean> } callback - Callback used to get the spatialization enable state. 6735 * @throws { BusinessError } 6800101 - Parameter verification failed. 6736 * @syscap SystemCapability.Multimedia.Audio.Spatialization 6737 * @since 18 6738 */ 6739 off(type: 'spatializationEnabledChangeForCurrentDevice', callback?: Callback<boolean>): void; 6740 } 6741 6742 /** 6743 * Implements audio effect management. 6744 * @typedef AudioEffectManager 6745 * @syscap SystemCapability.Multimedia.Audio.Core 6746 * @systemapi 6747 * @since 18 6748 */ 6749 interface AudioEffectManager { 6750 /** 6751 * Gets supported audio effect properties based on current devices. 6752 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6753 * @returns { Array<AudioEffectProperty> } Array of supported audio effect properties. 6754 * @throws { BusinessError } 201 - Permission denied. 6755 * @throws { BusinessError } 202 - Caller is not a system application. 6756 * @throws { BusinessError } 6800301 - System error. 6757 * @syscap SystemCapability.Multimedia.Audio.Core 6758 * @systemapi 6759 * @since 18 6760 */ 6761 getSupportedAudioEffectProperty(): Array<AudioEffectProperty>; 6762 6763 /** 6764 * Sets current audio effect properties. 6765 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6766 * @param { Array<AudioEffectProperty> } propertyArray - array of audio effect property to be set. 6767 * Notice that only one effect property name in each effect property category should be set. 6768 * @throws { BusinessError } 201 - Permission denied. 6769 * @throws { BusinessError } 202 - Caller is not a system application. 6770 * @throws { BusinessError } 6800101 - Parameter verification failed. Possible causes: 6771 * 1. More than one effect property name of the same effect property category are in the input array. 6772 * 2. The input audioEffectProperties are not supported by the current device. 6773 * 3. The name or catergory of the input audioEffectProperties is incorrect. 6774 * @throws { BusinessError } 6800301 - System error. 6775 * @syscap SystemCapability.Multimedia.Audio.Core 6776 * @systemapi 6777 * @since 18 6778 */ 6779 setAudioEffectProperty(propertyArray: Array<AudioEffectProperty>): void; 6780 6781 /** 6782 * Gets current audio effect properties. 6783 * @permission ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS 6784 * @returns { Array<AudioEffectProperty> } Array of current audio effect properties. 6785 * @throws { BusinessError } 201 - Permission denied. 6786 * @throws { BusinessError } 202 - Caller is not a system application. 6787 * @throws { BusinessError } 6800301 - System error. 6788 * @syscap SystemCapability.Multimedia.Audio.Core 6789 * @systemapi 6790 * @since 18 6791 */ 6792 getAudioEffectProperty(): Array<AudioEffectProperty>; 6793 } 6794 6795 /** 6796 * Implements audio collaborative management. 6797 * @typedef AudioCollaborativeManager 6798 * @syscap SystemCapability.Multimedia.Audio.Core 6799 * @systemapi 6800 * @since 20 6801 */ 6802 interface AudioCollaborativeManager { 6803 /** 6804 * Checks whether the collaborative playback is supported by system. 6805 * @returns { boolean } Whether the collaborative playback is supported by system. 6806 * @throws { BusinessError } 202 - Not system application. 6807 * @syscap SystemCapability.Multimedia.Audio.Device 6808 * @systemapi 6809 * @since 20 6810 */ 6811 isCollaborativePlaybackSupported(): boolean; 6812 6813 /** 6814 * Enables or disables collaborative playback for the specified device. 6815 * Currently, only A2DP audio devices support collaborative playback. 6816 * If the system is using the specified device for audio output, 6817 * the audio will be played from both the local speaker and the specified device after this API is called. 6818 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device descriptor. 6819 * @param { boolean } enabled - Whether to enable or disable collaborative playback. The value true means to enable it, and false means to disable it. 6820 * @returns { Promise<void> } Promise used to return the result. 6821 * @throws { BusinessError } 202 - Not system application. 6822 * @throws { BusinessError } 801 - Capability not supported. 6823 * @throws { BusinessError } 6800101 - Parameter verification failed. Possible causes: 6824 * 1. The specified device is not an A2DP device. 6825 * 2. The specified device is not connected. 6826 * @syscap SystemCapability.Multimedia.Audio.Device 6827 * @systemapi 6828 * @since 20 6829 */ 6830 setCollaborativePlaybackEnabledForDevice(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise<void>; 6831 6832 /** 6833 * Checks whether collaborative playback is enabled for the specified device. 6834 * @param { AudioDeviceDescriptor } deviceDescriptor - Audio device descriptor. 6835 * @returns { boolean } Returns the check result. The value true means that collaborative playback is enabled for the specified device, 6836 * and false means the opposite. 6837 * @throws { BusinessError } 202 - Not system application. 6838 * @throws { BusinessError } 6800101 - Parameter verification failed. 6839 * @syscap SystemCapability.Multimedia.Audio.Device 6840 * @systemapi 6841 * @since 20 6842 */ 6843 isCollaborativePlaybackEnabledForDevice(deviceDescriptor: AudioDeviceDescriptor): boolean; 6844 } 6845 6846 /** 6847 * Connect type for device. 6848 * @enum { number } 6849 * @syscap SystemCapability.Multimedia.Audio.Volume 6850 * @systemapi 6851 * @since 9 6852 */ 6853 enum ConnectType { 6854 /** 6855 * Connect type for local device. 6856 * @syscap SystemCapability.Multimedia.Audio.Volume 6857 * @systemapi 6858 * @since 9 6859 */ 6860 CONNECT_TYPE_LOCAL = 1, 6861 6862 /** 6863 * Connect type for distributed device. 6864 * @syscap SystemCapability.Multimedia.Audio.Volume 6865 * @systemapi 6866 * @since 9 6867 */ 6868 CONNECT_TYPE_DISTRIBUTED = 2 6869 } 6870 6871 /** 6872 * Describes an audio volume group. 6873 * @typedef VolumeGroupInfo 6874 * @syscap SystemCapability.Multimedia.Audio.Volume 6875 * @systemapi 6876 * @since 9 6877 */ 6878 interface VolumeGroupInfo { 6879 /** 6880 * Device network id. 6881 * @type { string } 6882 * @readonly 6883 * @syscap SystemCapability.Multimedia.Audio.Volume 6884 * @systemapi 6885 * @since 9 6886 */ 6887 readonly networkId: string; 6888 6889 /** 6890 * Volume group id. 6891 * @type { number } 6892 * @readonly 6893 * @syscap SystemCapability.Multimedia.Audio.Volume 6894 * @systemapi 6895 * @since 9 6896 */ 6897 readonly groupId: number; 6898 6899 /** 6900 * Volume mapping group id. 6901 * @type { number } 6902 * @readonly 6903 * @syscap SystemCapability.Multimedia.Audio.Volume 6904 * @systemapi 6905 * @since 9 6906 */ 6907 readonly mappingId: number; 6908 6909 /** 6910 * Volume group name. 6911 * @type { string } 6912 * @readonly 6913 * @syscap SystemCapability.Multimedia.Audio.Volume 6914 * @systemapi 6915 * @since 9 6916 */ 6917 readonly groupName: string; 6918 6919 /** 6920 * Connect type of device for this group. 6921 * @type { ConnectType } 6922 * @readonly 6923 * @syscap SystemCapability.Multimedia.Audio.Volume 6924 * @systemapi 6925 * @since 9 6926 */ 6927 readonly type: ConnectType; 6928 } 6929 6930 /** 6931 * Array of VolumeGroupInfos, which is read-only. 6932 * @typedef { Array<Readonly<VolumeGroupInfo>> } VolumeGroupInfos 6933 * @syscap SystemCapability.Multimedia.Audio.Volume 6934 * @systemapi 6935 * @since 9 6936 */ 6937 type VolumeGroupInfos = Array<Readonly<VolumeGroupInfo>>; 6938 6939 /** 6940 * Array of AudioRendererChangeInfo, which is read-only. 6941 * @typedef { Array<Readonly<AudioRendererChangeInfo>> } AudioRendererChangeInfoArray 6942 * @syscap SystemCapability.Multimedia.Audio.Renderer 6943 * @since 9 6944 */ 6945 /** 6946 * Array of AudioRendererChangeInfo, which is read-only. 6947 * @typedef { Array<Readonly<AudioRendererChangeInfo>> } AudioRendererChangeInfoArray 6948 * @syscap SystemCapability.Multimedia.Audio.Renderer 6949 * @crossplatform 6950 * @since 12 6951 */ 6952 type AudioRendererChangeInfoArray = Array<Readonly<AudioRendererChangeInfo>>; 6953 6954 /** 6955 * Describes audio renderer change information. 6956 * @typedef AudioRendererChangeInfo 6957 * @syscap SystemCapability.Multimedia.Audio.Renderer 6958 * @since 9 6959 */ 6960 /** 6961 * Describes audio renderer change information. 6962 * @typedef AudioRendererChangeInfo 6963 * @syscap SystemCapability.Multimedia.Audio.Renderer 6964 * @crossplatform 6965 * @since 12 6966 */ 6967 interface AudioRendererChangeInfo { 6968 /** 6969 * Audio stream unique id. 6970 * @type { number } 6971 * @syscap SystemCapability.Multimedia.Audio.Renderer 6972 * @since 9 6973 */ 6974 /** 6975 * Audio stream unique id. 6976 * @type { number } 6977 * @readonly 6978 * @syscap SystemCapability.Multimedia.Audio.Renderer 6979 * @crossplatform 6980 * @since 12 6981 */ 6982 readonly streamId: number; 6983 6984 /** 6985 * Uid for audio renderer client application. 6986 * @type { number } 6987 * @readonly 6988 * @syscap SystemCapability.Multimedia.Audio.Renderer 6989 * @systemapi 6990 * @since 9 6991 */ 6992 readonly clientUid: number; 6993 6994 /** 6995 * Audio renderer information. 6996 * @type { AudioRendererInfo } 6997 * @syscap SystemCapability.Multimedia.Audio.Renderer 6998 * @since 9 6999 */ 7000 /** 7001 * Audio renderer information. 7002 * @type { AudioRendererInfo } 7003 * @readonly 7004 * @syscap SystemCapability.Multimedia.Audio.Renderer 7005 * @crossplatform 7006 * @since 12 7007 */ 7008 readonly rendererInfo: AudioRendererInfo; 7009 7010 /** 7011 * Audio state. 7012 * @type { AudioState } 7013 * @readonly 7014 * @syscap SystemCapability.Multimedia.Audio.Renderer 7015 * @systemapi 7016 * @since 9 7017 */ 7018 readonly rendererState: AudioState; 7019 7020 /** 7021 * Audio output devices. 7022 * @type { AudioDeviceDescriptors } 7023 * @syscap SystemCapability.Multimedia.Audio.Renderer 7024 * @since 9 7025 */ 7026 /** 7027 * Audio output devices. 7028 * @type { AudioDeviceDescriptors } 7029 * @readonly 7030 * @syscap SystemCapability.Multimedia.Audio.Renderer 7031 * @crossplatform 7032 * @since 12 7033 */ 7034 readonly deviceDescriptors: AudioDeviceDescriptors; 7035 } 7036 7037 /** 7038 * Array of AudioCapturerChangeInfo, which is read-only. 7039 * @typedef { Array<Readonly<AudioCapturerChangeInfo>> } AudioCapturerChangeInfoArray 7040 * @syscap SystemCapability.Multimedia.Audio.Capturer 7041 * @since 9 7042 */ 7043 /** 7044 * Array of AudioCapturerChangeInfo, which is read-only. 7045 * @typedef { Array<Readonly<AudioCapturerChangeInfo>> } AudioCapturerChangeInfoArray 7046 * @syscap SystemCapability.Multimedia.Audio.Capturer 7047 * @crossplatform 7048 * @since 12 7049 */ 7050 type AudioCapturerChangeInfoArray = Array<Readonly<AudioCapturerChangeInfo>>; 7051 7052 /** 7053 * Describes audio capturer change information. 7054 * @typedef AudioCapturerChangeInfo 7055 * @syscap SystemCapability.Multimedia.Audio.Capturer 7056 * @since 9 7057 */ 7058 /** 7059 * Describes audio capturer change information. 7060 * @typedef AudioCapturerChangeInfo 7061 * @syscap SystemCapability.Multimedia.Audio.Capturer 7062 * @crossplatform 7063 * @since 12 7064 */ 7065 interface AudioCapturerChangeInfo { 7066 /** 7067 * Audio stream unique id. 7068 * @type { number } 7069 * @syscap SystemCapability.Multimedia.Audio.Capturer 7070 * @since 9 7071 */ 7072 /** 7073 * Audio stream unique id. 7074 * @type { number } 7075 * @readonly 7076 * @syscap SystemCapability.Multimedia.Audio.Capturer 7077 * @crossplatform 7078 * @since 12 7079 */ 7080 readonly streamId: number; 7081 7082 /** 7083 * Uid for audio capturer client application. 7084 * @type { number } 7085 * @readonly 7086 * @syscap SystemCapability.Multimedia.Audio.Capturer 7087 * @systemapi 7088 * @since 9 7089 */ 7090 readonly clientUid: number; 7091 7092 /** 7093 * Audio capturer information. 7094 * @type { AudioCapturerInfo } 7095 * @syscap SystemCapability.Multimedia.Audio.Capturer 7096 * @since 9 7097 */ 7098 /** 7099 * Audio capturer information. 7100 * @type { AudioCapturerInfo } 7101 * @readonly 7102 * @syscap SystemCapability.Multimedia.Audio.Capturer 7103 * @crossplatform 7104 * @since 12 7105 */ 7106 readonly capturerInfo: AudioCapturerInfo; 7107 7108 /** 7109 * Audio state. 7110 * @type { AudioState } 7111 * @readonly 7112 * @syscap SystemCapability.Multimedia.Audio.Capturer 7113 * @systemapi 7114 * @since 9 7115 */ 7116 readonly capturerState: AudioState; 7117 7118 /** 7119 * Audio input devices. 7120 * @type { AudioDeviceDescriptors } 7121 * @syscap SystemCapability.Multimedia.Audio.Capturer 7122 * @since 9 7123 */ 7124 /** 7125 * Audio input devices. 7126 * @type { AudioDeviceDescriptors } 7127 * @readonly 7128 * @syscap SystemCapability.Multimedia.Audio.Capturer 7129 * @crossplatform 7130 * @since 12 7131 */ 7132 readonly deviceDescriptors: AudioDeviceDescriptors; 7133 7134 /** 7135 * Audio capturer muted status. 7136 * @type { ?boolean } 7137 * @syscap SystemCapability.Multimedia.Audio.Capturer 7138 * @since 11 7139 */ 7140 /** 7141 * Audio capturer muted status. 7142 * @type { ?boolean } 7143 * @readonly 7144 * @syscap SystemCapability.Multimedia.Audio.Capturer 7145 * @crossplatform 7146 * @since 12 7147 */ 7148 readonly muted?: boolean; 7149 } 7150 7151 /** 7152 * Describes an audio device. 7153 * @typedef AudioDeviceDescriptor 7154 * @syscap SystemCapability.Multimedia.Audio.Device 7155 * @since 7 7156 */ 7157 /** 7158 * Describes an audio device. 7159 * @typedef AudioDeviceDescriptor 7160 * @syscap SystemCapability.Multimedia.Audio.Device 7161 * @crossplatform 7162 * @atomicservice 7163 * @since 12 7164 */ 7165 interface AudioDeviceDescriptor { 7166 /** 7167 * Audio device role. 7168 * @type { DeviceRole } 7169 * @syscap SystemCapability.Multimedia.Audio.Device 7170 * @since 7 7171 */ 7172 /** 7173 * Audio device role. 7174 * @type { DeviceRole } 7175 * @readonly 7176 * @syscap SystemCapability.Multimedia.Audio.Device 7177 * @crossplatform 7178 * @atomicservice 7179 * @since 12 7180 */ 7181 readonly deviceRole: DeviceRole; 7182 7183 /** 7184 * Audio device type. 7185 * @type { DeviceType } 7186 * @syscap SystemCapability.Multimedia.Audio.Device 7187 * @since 7 7188 */ 7189 /** 7190 * Audio device type. 7191 * @type { DeviceType } 7192 * @readonly 7193 * @syscap SystemCapability.Multimedia.Audio.Device 7194 * @crossplatform 7195 * @atomicservice 7196 * @since 12 7197 */ 7198 readonly deviceType: DeviceType; 7199 7200 /** 7201 * Audio device id. 7202 * @type { number } 7203 * @syscap SystemCapability.Multimedia.Audio.Device 7204 * @since 9 7205 */ 7206 /** 7207 * Audio device id. 7208 * @type { number } 7209 * @readonly 7210 * @syscap SystemCapability.Multimedia.Audio.Device 7211 * @crossplatform 7212 * @atomicservice 7213 * @since 12 7214 */ 7215 readonly id: number; 7216 7217 /** 7218 * Audio device name. 7219 * @type { string } 7220 * @syscap SystemCapability.Multimedia.Audio.Device 7221 * @since 9 7222 */ 7223 /** 7224 * Audio device name. 7225 * @type { string } 7226 * @readonly 7227 * @syscap SystemCapability.Multimedia.Audio.Device 7228 * @crossplatform 7229 * @atomicservice 7230 * @since 12 7231 */ 7232 readonly name: string; 7233 7234 /** 7235 * Audio device address. 7236 * @type { string } 7237 * @syscap SystemCapability.Multimedia.Audio.Device 7238 * @since 9 7239 */ 7240 /** 7241 * Audio device address. 7242 * @type { string } 7243 * @readonly 7244 * @syscap SystemCapability.Multimedia.Audio.Device 7245 * @crossplatform 7246 * @atomicservice 7247 * @since 12 7248 */ 7249 readonly address: string; 7250 7251 /** 7252 * Supported sampling rates. 7253 * @type { Array<number> } 7254 * @syscap SystemCapability.Multimedia.Audio.Device 7255 * @since 9 7256 */ 7257 /** 7258 * Supported sampling rates. 7259 * @type { Array<number> } 7260 * @readonly 7261 * @syscap SystemCapability.Multimedia.Audio.Device 7262 * @crossplatform 7263 * @atomicservice 7264 * @since 12 7265 */ 7266 readonly sampleRates: Array<number>; 7267 7268 /** 7269 * Supported channel counts. 7270 * @type { Array<number> } 7271 * @syscap SystemCapability.Multimedia.Audio.Device 7272 * @since 9 7273 */ 7274 /** 7275 * Supported channel counts. 7276 * @type { Array<number> } 7277 * @readonly 7278 * @syscap SystemCapability.Multimedia.Audio.Device 7279 * @crossplatform 7280 * @atomicservice 7281 * @since 12 7282 */ 7283 readonly channelCounts: Array<number>; 7284 7285 /** 7286 * Supported channel masks. 7287 * @type { Array<number> } 7288 * @syscap SystemCapability.Multimedia.Audio.Device 7289 * @since 9 7290 */ 7291 /** 7292 * Supported channel masks. 7293 * @type { Array<number> } 7294 * @readonly 7295 * @syscap SystemCapability.Multimedia.Audio.Device 7296 * @crossplatform 7297 * @atomicservice 7298 * @since 12 7299 */ 7300 readonly channelMasks: Array<number>; 7301 /** 7302 * Device network id 7303 * @type { string } 7304 * @readonly 7305 * @syscap SystemCapability.Multimedia.Audio.Device 7306 * @systemapi 7307 * @since 9 7308 */ 7309 readonly networkId: string; 7310 /** 7311 * Interrupt group id 7312 * @type { number } 7313 * @readonly 7314 * @syscap SystemCapability.Multimedia.Audio.Device 7315 * @systemapi 7316 * @since 9 7317 */ 7318 readonly interruptGroupId: number; 7319 /** 7320 * Volume group id 7321 * @type { number } 7322 * @readonly 7323 * @syscap SystemCapability.Multimedia.Audio.Device 7324 * @systemapi 7325 * @since 9 7326 */ 7327 readonly volumeGroupId: number; 7328 /** 7329 * Name used to display, considering distributed device situation. 7330 * @type { string } 7331 * @syscap SystemCapability.Multimedia.Audio.Device 7332 * @since 10 7333 */ 7334 /** 7335 * Name used to display, considering distributed device situation. 7336 * @type { string } 7337 * @readonly 7338 * @syscap SystemCapability.Multimedia.Audio.Device 7339 * @crossplatform 7340 * @atomicservice 7341 * @since 12 7342 */ 7343 readonly displayName: string; 7344 7345 /** 7346 * Supported encoding types. 7347 * @type { ?Array<AudioEncodingType> } 7348 * @syscap SystemCapability.Multimedia.Audio.Core 7349 * @since 11 7350 */ 7351 /** 7352 * Supported encoding types. 7353 * @type { ?Array<AudioEncodingType> } 7354 * @readonly 7355 * @syscap SystemCapability.Multimedia.Audio.Core 7356 * @crossplatform 7357 * @atomicservice 7358 * @since 12 7359 */ 7360 readonly encodingTypes?: Array<AudioEncodingType>; 7361 7362 /** 7363 * whether supports spatial rendering. 7364 * @type { boolean } 7365 * @readonly 7366 * @syscap SystemCapability.Multimedia.Audio.Spatialization 7367 * @since 18 7368 */ 7369 readonly spatializationSupported?: boolean; 7370 7371 /** 7372 * Only {@link DeviceType.SPEAKER} with networkId、{@link DeviceType.REMOTE_CAST} 7373 * or {@link DeviceType.REMOTE_DAUDIO} has dmDeviceType which indicated deviceTypeId. 7374 * @type { number } 7375 * @readonly 7376 * @syscap SystemCapability.Multimedia.Audio.Core 7377 * @systemapi 7378 * @since 18 7379 */ 7380 readonly dmDeviceType?: number; 7381 } 7382 7383 /** 7384 * Array of AudioDeviceDescriptors, which is read-only. 7385 * @typedef { Array<Readonly<AudioDeviceDescriptor>> } AudioDeviceDescriptors 7386 * @syscap SystemCapability.Multimedia.Audio.Device 7387 * @since 7 7388 */ 7389 /** 7390 * Array of AudioDeviceDescriptors, which is read-only. 7391 * @typedef { Array<Readonly<AudioDeviceDescriptor>> } AudioDeviceDescriptors 7392 * @syscap SystemCapability.Multimedia.Audio.Device 7393 * @crossplatform 7394 * @atomicservice 7395 * @since 12 7396 */ 7397 type AudioDeviceDescriptors = Array<Readonly<AudioDeviceDescriptor>>; 7398 7399 /** 7400 * Volume mode. 7401 * @enum { number } 7402 * @syscap SystemCapability.Multimedia.Audio.Volume 7403 * @since 19 7404 */ 7405 enum AudioVolumeMode { 7406 /** 7407 * Audio volume affected by system volume level. 7408 * @syscap SystemCapability.Multimedia.Audio.Volume 7409 * @since 19 7410 */ 7411 SYSTEM_GLOBAL = 0, 7412 /** 7413 * Audio volume affected by app's individual percentage. 7414 * @syscap SystemCapability.Multimedia.Audio.Volume 7415 * @since 19 7416 */ 7417 APP_INDIVIDUAL = 1 7418 } 7419 7420 /** 7421 * Describes the volume event received by the app when the volume is changed. 7422 * @typedef VolumeEvent 7423 * @syscap SystemCapability.Multimedia.Audio.Volume 7424 * @since 9 7425 */ 7426 /** 7427 * Describes the volume event received by the app when the volume is changed. 7428 * @typedef VolumeEvent 7429 * @syscap SystemCapability.Multimedia.Audio.Volume 7430 * @crossplatform 7431 * @since 12 7432 */ 7433 interface VolumeEvent { 7434 /** 7435 * Volume type of the current stream. 7436 * @type { AudioVolumeType } 7437 * @syscap SystemCapability.Multimedia.Audio.Volume 7438 * @since 9 7439 */ 7440 volumeType: AudioVolumeType; 7441 /** 7442 * Volume level. 7443 * @type { number } 7444 * @syscap SystemCapability.Multimedia.Audio.Volume 7445 * @since 9 7446 */ 7447 /** 7448 * Volume level. 7449 * @type { number } 7450 * @syscap SystemCapability.Multimedia.Audio.Volume 7451 * @crossplatform 7452 * @since 12 7453 */ 7454 volume: number; 7455 /** 7456 * Whether to show the volume change in UI. 7457 * @type { boolean } 7458 * @syscap SystemCapability.Multimedia.Audio.Volume 7459 * @since 9 7460 */ 7461 updateUi: boolean; 7462 /** 7463 * volumeGroup id 7464 * @type { number } 7465 * @syscap SystemCapability.Multimedia.Audio.Volume 7466 * @systemapi 7467 * @since 9 7468 */ 7469 volumeGroupId: number; 7470 /** 7471 * Device network id 7472 * @type { string } 7473 * @syscap SystemCapability.Multimedia.Audio.Volume 7474 * @systemapi 7475 * @since 9 7476 */ 7477 networkId: string; 7478 /** 7479 * Audio volume mode of this volume event 7480 * @type { ?AudioVolumeMode } 7481 * @syscap SystemCapability.Multimedia.Audio.Volume 7482 * @since 19 7483 */ 7484 volumeMode?: AudioVolumeMode; 7485 } 7486 7487 /** 7488 * Describes the stream volume event when the volume is changed. 7489 * @typedef StreamVolumeEvent 7490 * @syscap SystemCapability.Multimedia.Audio.Volume 7491 * @since 20 7492 */ 7493 interface StreamVolumeEvent { 7494 /** 7495 * The type of streamUsage whose volume changes. 7496 * @type { StreamUsage } 7497 * @syscap SystemCapability.Multimedia.Audio.Volume 7498 * @since 20 7499 */ 7500 streamUsage: StreamUsage; 7501 /** 7502 * Volume level. 7503 * @type { number } 7504 * @syscap SystemCapability.Multimedia.Audio.Volume 7505 * @since 20 7506 */ 7507 volume: number; 7508 /** 7509 * Whether to show the volume change in UI. 7510 * @type { boolean } 7511 * @syscap SystemCapability.Multimedia.Audio.Volume 7512 * @since 20 7513 */ 7514 updateUi: boolean; 7515 } 7516 7517 /** 7518 * Describes the callback invoked for audio interruption or focus gain events.When the audio of an application 7519 * is interrupted by another application, the callback is invoked to notify the former application. 7520 * @typedef InterruptAction 7521 * @syscap SystemCapability.Multimedia.Audio.Renderer 7522 * @since 7 7523 * @deprecated since 9 7524 * @useinstead ohos.multimedia.audio.InterruptEvent 7525 */ 7526 interface InterruptAction { 7527 7528 /** 7529 * Event type. 7530 * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. 7531 * @type { InterruptActionType } 7532 * @syscap SystemCapability.Multimedia.Audio.Renderer 7533 * @since 7 7534 * @deprecated since 9 7535 */ 7536 actionType: InterruptActionType; 7537 7538 /** 7539 * Type of the audio interruption event. 7540 * @type { ?InterruptType } 7541 * @syscap SystemCapability.Multimedia.Audio.Renderer 7542 * @since 7 7543 * @deprecated since 9 7544 */ 7545 type?: InterruptType; 7546 7547 /** 7548 * Hint for the audio interruption event. 7549 * @type { ?InterruptHint } 7550 * @syscap SystemCapability.Multimedia.Audio.Renderer 7551 * @since 7 7552 * @deprecated since 9 7553 */ 7554 hint?: InterruptHint; 7555 7556 /** 7557 * Whether the focus is gained or released. The value true means that the focus is gained or released, 7558 * and false means that the focus fails to be gained or released. 7559 * @type { ?boolean } 7560 * @syscap SystemCapability.Multimedia.Audio.Renderer 7561 * @since 7 7562 * @deprecated since 9 7563 */ 7564 activated?: boolean; 7565 } 7566 7567 /** 7568 * Describes input parameters of audio listening events. 7569 * @typedef AudioInterrupt 7570 * @syscap SystemCapability.Multimedia.Audio.Renderer 7571 * @since 7 7572 * @deprecated since 9 7573 */ 7574 interface AudioInterrupt { 7575 7576 /** 7577 * Audio stream usage type. 7578 * @type { StreamUsage } 7579 * @syscap SystemCapability.Multimedia.Audio.Renderer 7580 * @since 7 7581 * @deprecated since 9 7582 */ 7583 streamUsage: StreamUsage; 7584 7585 /** 7586 * Type of the media interrupted. 7587 * @type { ContentType } 7588 * @syscap SystemCapability.Multimedia.Audio.Renderer 7589 * @since 7 7590 * @deprecated since 9 7591 */ 7592 contentType: ContentType; 7593 7594 /** 7595 * Whether audio playback can be paused when it is interrupted. 7596 * The value true means that audio playback can be paused when it is interrupted, and false means the opposite. 7597 * @type { boolean } 7598 * @syscap SystemCapability.Multimedia.Audio.Renderer 7599 * @since 7 7600 * @deprecated since 9 7601 */ 7602 pauseWhenDucked: boolean; 7603 } 7604 7605 /** 7606 * Describes the microphone state change event received by the app when the microphone state is changed. 7607 * @typedef MicStateChangeEvent 7608 * @syscap SystemCapability.Multimedia.Audio.Device 7609 * @since 9 7610 */ 7611 interface MicStateChangeEvent { 7612 /** 7613 * Mic mute state. 7614 * @type { boolean } 7615 * @syscap SystemCapability.Multimedia.Audio.Device 7616 * @since 9 7617 */ 7618 mute: boolean; 7619 } 7620 /** 7621 * Describes the device change type and device information. 7622 * @typedef DeviceChangeAction 7623 * @syscap SystemCapability.Multimedia.Audio.Device 7624 * @since 7 7625 */ 7626 /** 7627 * Describes the device change type and device information. 7628 * @typedef DeviceChangeAction 7629 * @syscap SystemCapability.Multimedia.Audio.Device 7630 * @crossplatform 7631 * @since 12 7632 */ 7633 interface DeviceChangeAction { 7634 /** 7635 * Device change type. 7636 * @type { DeviceChangeType } 7637 * @syscap SystemCapability.Multimedia.Audio.Device 7638 * @since 7 7639 */ 7640 /** 7641 * Device change type. 7642 * @type { DeviceChangeType } 7643 * @syscap SystemCapability.Multimedia.Audio.Device 7644 * @crossplatform 7645 * @since 12 7646 */ 7647 type: DeviceChangeType; 7648 7649 /** 7650 * Device information. 7651 * @type { AudioDeviceDescriptors } 7652 * @syscap SystemCapability.Multimedia.Audio.Device 7653 * @since 7 7654 */ 7655 /** 7656 * Device information. 7657 * @type { AudioDeviceDescriptors } 7658 * @syscap SystemCapability.Multimedia.Audio.Device 7659 * @crossplatform 7660 * @since 12 7661 */ 7662 deviceDescriptors: AudioDeviceDescriptors; 7663 } 7664 7665 /** 7666 * Enumerates channel blend mode. 7667 * @enum { number } 7668 * @syscap SystemCapability.Multimedia.Audio.Core 7669 * @since 11 7670 */ 7671 /** 7672 * Enumerates channel blend mode. 7673 * @enum { number } 7674 * @syscap SystemCapability.Multimedia.Audio.Core 7675 * @crossplatform 7676 * @since 12 7677 */ 7678 enum ChannelBlendMode { 7679 /** 7680 * No channel process. 7681 * @syscap SystemCapability.Multimedia.Audio.Core 7682 * @since 11 7683 */ 7684 /** 7685 * No channel process. 7686 * @syscap SystemCapability.Multimedia.Audio.Core 7687 * @crossplatform 7688 * @since 12 7689 */ 7690 MODE_DEFAULT = 0, 7691 /** 7692 * Blend left and right channel. 7693 * @syscap SystemCapability.Multimedia.Audio.Core 7694 * @since 11 7695 */ 7696 /** 7697 * Blend left and right channel. 7698 * @syscap SystemCapability.Multimedia.Audio.Core 7699 * @crossplatform 7700 * @since 12 7701 */ 7702 MODE_BLEND_LR = 1, 7703 /** 7704 * Replicate left to right channel. 7705 * @syscap SystemCapability.Multimedia.Audio.Core 7706 * @since 11 7707 */ 7708 /** 7709 * Replicate left to right channel. 7710 * @syscap SystemCapability.Multimedia.Audio.Core 7711 * @crossplatform 7712 * @since 12 7713 */ 7714 MODE_ALL_LEFT = 2, 7715 /** 7716 * Replicate right to left channel. 7717 * @syscap SystemCapability.Multimedia.Audio.Core 7718 * @since 11 7719 */ 7720 /** 7721 * Replicate right to left channel. 7722 * @syscap SystemCapability.Multimedia.Audio.Core 7723 * @crossplatform 7724 * @since 12 7725 */ 7726 MODE_ALL_RIGHT = 3, 7727 } 7728 7729 /** 7730 * Enumerates audio stream device change reason. 7731 * @enum { number } 7732 * @syscap SystemCapability.Multimedia.Audio.Device 7733 * @since 11 7734 */ 7735 /** 7736 * Enumerates audio stream device change reason. 7737 * @enum { number } 7738 * @syscap SystemCapability.Multimedia.Audio.Device 7739 * @crossplatform 7740 * @atomicservice 7741 * @since 12 7742 */ 7743 enum AudioStreamDeviceChangeReason { 7744 /** 7745 * Unknown. 7746 * @syscap SystemCapability.Multimedia.Audio.Device 7747 * @since 11 7748 */ 7749 /** 7750 * This is default device change reason. 7751 * @syscap SystemCapability.Multimedia.Audio.Device 7752 * @crossplatform 7753 * @atomicservice 7754 * @since 12 7755 */ 7756 REASON_UNKNOWN = 0, 7757 /** 7758 * New device available. 7759 * @syscap SystemCapability.Multimedia.Audio.Device 7760 * @since 11 7761 */ 7762 /** 7763 * New device available. 7764 * @syscap SystemCapability.Multimedia.Audio.Device 7765 * @crossplatform 7766 * @atomicservice 7767 * @since 12 7768 */ 7769 REASON_NEW_DEVICE_AVAILABLE = 1, 7770 /** 7771 * Old device unavailable. Applications should consider to pause the audio playback when this reason is 7772 * reported. 7773 * @syscap SystemCapability.Multimedia.Audio.Device 7774 * @since 11 7775 */ 7776 /** 7777 * Old device unavailable. Applications should consider to pause the audio playback when this reason is 7778 * reported. 7779 * @syscap SystemCapability.Multimedia.Audio.Device 7780 * @crossplatform 7781 * @atomicservice 7782 * @since 12 7783 */ 7784 REASON_OLD_DEVICE_UNAVAILABLE = 2, 7785 /** 7786 * Overrode by user or system. 7787 * @syscap SystemCapability.Multimedia.Audio.Device 7788 * @since 11 7789 */ 7790 /** 7791 * Overrode by user or system. 7792 * @syscap SystemCapability.Multimedia.Audio.Device 7793 * @crossplatform 7794 * @atomicservice 7795 * @since 12 7796 */ 7797 REASON_OVERRODE = 3, 7798 /** 7799 * Device information when the audio session is activated. 7800 * @syscap SystemCapability.Multimedia.Audio.Device 7801 * @since 20 7802 */ 7803 REASON_SESSION_ACTIVATED = 4, 7804 /** 7805 * There is a higher-priority stream, causing the system device to change. 7806 * @syscap SystemCapability.Multimedia.Audio.Device 7807 * @since 20 7808 */ 7809 REASON_STREAM_PRIORITY_CHANGED = 5, 7810 } 7811 /** 7812 * Audio stream device change info. 7813 * @typedef AudioStreamDeviceChangeInfo 7814 * @syscap SystemCapability.Multimedia.Audio.Device 7815 * @since 11 7816 */ 7817 /** 7818 * Audio stream device change info. 7819 * @typedef AudioStreamDeviceChangeInfo 7820 * @syscap SystemCapability.Multimedia.Audio.Device 7821 * @crossplatform 7822 * @atomicservice 7823 * @since 12 7824 */ 7825 interface AudioStreamDeviceChangeInfo { 7826 /** 7827 * Audio device descriptors after change. 7828 * @type { AudioDeviceDescriptors } 7829 * @syscap SystemCapability.Multimedia.Audio.Device 7830 * @since 11 7831 */ 7832 /** 7833 * Audio device descriptors after change. 7834 * @type { AudioDeviceDescriptors } 7835 * @syscap SystemCapability.Multimedia.Audio.Device 7836 * @crossplatform 7837 * @atomicservice 7838 * @since 12 7839 */ 7840 devices: AudioDeviceDescriptors; 7841 /** 7842 * Audio stream device change reason. 7843 * @type { AudioStreamDeviceChangeReason } 7844 * @syscap SystemCapability.Multimedia.Audio.Device 7845 * @since 11 7846 */ 7847 /** 7848 * Audio stream device change reason. 7849 * @type { AudioStreamDeviceChangeReason } 7850 * @syscap SystemCapability.Multimedia.Audio.Device 7851 * @crossplatform 7852 * @atomicservice 7853 * @since 12 7854 */ 7855 changeReason: AudioStreamDeviceChangeReason; 7856 } 7857 7858 /** 7859 * Enumerates callback result. 7860 * @enum { number } 7861 * @syscap SystemCapability.Multimedia.Audio.Core 7862 * @crossplatform 7863 * @since 12 7864 */ 7865 enum AudioDataCallbackResult { 7866 /** 7867 * Indicates data of this callback is invalid. 7868 * @syscap SystemCapability.Multimedia.Audio.Core 7869 * @crossplatform 7870 * @since 12 7871 */ 7872 INVALID = -1, 7873 7874 /** 7875 * Indicates data of this callback is valid. 7876 * @syscap SystemCapability.Multimedia.Audio.Core 7877 * @crossplatform 7878 * @since 12 7879 */ 7880 VALID = 0, 7881 } 7882 7883 /** 7884 * Type definition of callback function for audio renderer write data. 7885 * 7886 * @typedef { function } AudioRendererWriteDataCallback 7887 * @param { ArrayBuffer } data - audio data array buffer. 7888 * @returns { AudioDataCallbackResult | void } result of callback or void. If void or AudioDataCallbackResult.VALID is 7889 * returned, it indicates the data is valid and will be played. If AudioDataCallbackResult.INVALID is returned, it 7890 * indicates the data is will not be played. 7891 * @syscap SystemCapability.Multimedia.Audio.Renderer 7892 * @crossplatform 7893 * @since 12 7894 */ 7895 type AudioRendererWriteDataCallback = (data: ArrayBuffer) => AudioDataCallbackResult | void; 7896 7897 7898 /** 7899 * Audio timestamp info. 7900 * @typedef AudioTimestampInfo 7901 * @syscap SystemCapability.Multimedia.Audio.Core 7902 * @since 19 7903 */ 7904 interface AudioTimestampInfo { 7905 /** 7906 * Frame position. 7907 * @type { number } 7908 * @readonly 7909 * @syscap SystemCapability.Multimedia.Audio.Core 7910 * @since 19 7911 */ 7912 readonly framePos: number; 7913 7914 /** 7915 * Timestamp when frame in {@link AudioTimestampInfo#framePos} was rendered or captured. 7916 * @type { number } 7917 * @readonly 7918 * @syscap SystemCapability.Multimedia.Audio.Core 7919 * @since 19 7920 */ 7921 readonly timestamp: number; 7922 } 7923 7924 /** 7925 * Provides audio playback APIs. 7926 * @typedef AudioRenderer 7927 * @syscap SystemCapability.Multimedia.Audio.Renderer 7928 * @since 8 7929 */ 7930 /** 7931 * Provides audio playback APIs. 7932 * @typedef AudioRenderer 7933 * @syscap SystemCapability.Multimedia.Audio.Renderer 7934 * @crossplatform 7935 * @since 12 7936 */ 7937 interface AudioRenderer { 7938 /** 7939 * Defines the current render state. 7940 * @type { AudioState } 7941 * @syscap SystemCapability.Multimedia.Audio.Renderer 7942 * @since 8 7943 */ 7944 /** 7945 * Defines the current render state. 7946 * @type { AudioState } 7947 * @readonly 7948 * @syscap SystemCapability.Multimedia.Audio.Renderer 7949 * @crossplatform 7950 * @since 12 7951 */ 7952 readonly state: AudioState; 7953 7954 /** 7955 * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous 7956 * callback to return the result. 7957 * @param { AsyncCallback<AudioRendererInfo> } callback - Callback used to return the renderer information. 7958 * @syscap SystemCapability.Multimedia.Audio.Renderer 7959 * @since 8 7960 */ 7961 /** 7962 * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous 7963 * callback to return the result. 7964 * @param { AsyncCallback<AudioRendererInfo> } callback - Callback used to return the renderer information. 7965 * @syscap SystemCapability.Multimedia.Audio.Renderer 7966 * @crossplatform 7967 * @since 12 7968 */ 7969 getRendererInfo(callback: AsyncCallback<AudioRendererInfo>): void; 7970 /** 7971 * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to 7972 * return the result. 7973 * @returns { Promise<AudioRendererInfo> } Promise used to return the renderer information. 7974 * @syscap SystemCapability.Multimedia.Audio.Renderer 7975 * @since 8 7976 */ 7977 /** 7978 * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to 7979 * return the result. 7980 * @returns { Promise<AudioRendererInfo> } Promise used to return the renderer information. 7981 * @syscap SystemCapability.Multimedia.Audio.Renderer 7982 * @crossplatform 7983 * @since 12 7984 */ 7985 getRendererInfo(): Promise<AudioRendererInfo>; 7986 /** 7987 * Obtains the renderer information provided while creating a renderer instance. 7988 * @returns { AudioRendererInfo } The renderer information. 7989 * @syscap SystemCapability.Multimedia.Audio.Renderer 7990 * @since 10 7991 */ 7992 /** 7993 * Obtains the renderer information provided while creating a renderer instance. 7994 * @returns { AudioRendererInfo } The renderer information. 7995 * @syscap SystemCapability.Multimedia.Audio.Renderer 7996 * @crossplatform 7997 * @since 12 7998 */ 7999 getRendererInfoSync(): AudioRendererInfo; 8000 8001 /** 8002 * Obtains the renderer stream information. This method uses an asynchronous callback to return the result. 8003 * @param { AsyncCallback<AudioStreamInfo> } callback - Callback used to return the stream information. 8004 * @syscap SystemCapability.Multimedia.Audio.Renderer 8005 * @since 8 8006 */ 8007 /** 8008 * Obtains the renderer stream information. This method uses an asynchronous callback to return the result. 8009 * @param { AsyncCallback<AudioStreamInfo> } callback - Callback used to return the stream information. 8010 * @syscap SystemCapability.Multimedia.Audio.Renderer 8011 * @crossplatform 8012 * @since 12 8013 */ 8014 getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void; 8015 /** 8016 * Obtains the renderer stream information. This method uses a promise to return the result. 8017 * @returns { Promise<AudioStreamInfo> } Promise used to return the stream information. 8018 * @syscap SystemCapability.Multimedia.Audio.Renderer 8019 * @since 8 8020 */ 8021 /** 8022 * Obtains the renderer stream information. This method uses a promise to return the result. 8023 * @returns { Promise<AudioStreamInfo> } Promise used to return the stream information. 8024 * @syscap SystemCapability.Multimedia.Audio.Renderer 8025 * @crossplatform 8026 * @since 12 8027 */ 8028 getStreamInfo(): Promise<AudioStreamInfo>; 8029 /** 8030 * Obtains the renderer stream information. 8031 * @returns { AudioStreamInfo } The stream information. 8032 * @syscap SystemCapability.Multimedia.Audio.Renderer 8033 * @since 10 8034 */ 8035 /** 8036 * Obtains the renderer stream information. 8037 * @returns { AudioStreamInfo } The stream information. 8038 * @syscap SystemCapability.Multimedia.Audio.Renderer 8039 * @crossplatform 8040 * @since 12 8041 */ 8042 getStreamInfoSync(): AudioStreamInfo; 8043 8044 /** 8045 * Obtains the renderer stream id. This method uses an asynchronous callback to return the result. 8046 * @param { AsyncCallback<number> } callback - Callback used to return the stream id. 8047 * @syscap SystemCapability.Multimedia.Audio.Renderer 8048 * @since 9 8049 */ 8050 /** 8051 * Obtains the renderer stream id. This method uses an asynchronous callback to return the result. 8052 * @param { AsyncCallback<number> } callback - Callback used to return the stream id. 8053 * @syscap SystemCapability.Multimedia.Audio.Renderer 8054 * @crossplatform 8055 * @since 12 8056 */ 8057 getAudioStreamId(callback: AsyncCallback<number>): void; 8058 /** 8059 * Obtains the renderer stream id. This method uses a promise to return the result. 8060 * @returns { Promise<number> } Promise used to return the stream id. 8061 * @syscap SystemCapability.Multimedia.Audio.Renderer 8062 * @since 9 8063 */ 8064 /** 8065 * Obtains the renderer stream id. This method uses a promise to return the result. 8066 * @returns { Promise<number> } Promise used to return the stream id. 8067 * @syscap SystemCapability.Multimedia.Audio.Renderer 8068 * @crossplatform 8069 * @since 12 8070 */ 8071 getAudioStreamId(): Promise<number>; 8072 /** 8073 * Obtains the renderer stream id. 8074 * @returns { number } The stream id. 8075 * @syscap SystemCapability.Multimedia.Audio.Renderer 8076 * @since 10 8077 */ 8078 /** 8079 * Obtains the renderer stream id. 8080 * @returns { number } The stream id. 8081 * @syscap SystemCapability.Multimedia.Audio.Renderer 8082 * @crossplatform 8083 * @since 12 8084 */ 8085 getAudioStreamIdSync(): number; 8086 8087 /** 8088 * Obtains the current audio effect mode. This method uses an asynchronous callback to return the query result. 8089 * @param { AsyncCallback<AudioEffectMode> } callback - Callback used to return the current audio effect mode. 8090 * @syscap SystemCapability.Multimedia.Audio.Renderer 8091 * @since 10 8092 */ 8093 getAudioEffectMode(callback: AsyncCallback<AudioEffectMode>): void; 8094 /** 8095 * Obtains the current audio effect mode. This method uses a promise to return the query result. 8096 * @returns { Promise<AudioEffectMode> } Promise used to return the current audio effect mode. 8097 * @syscap SystemCapability.Multimedia.Audio.Renderer 8098 * @since 10 8099 */ 8100 getAudioEffectMode(): Promise<AudioEffectMode>; 8101 8102 /** 8103 * Sets audio effect mode for current audio renderer. This method uses an asynchronous callback to return the result. 8104 * @param { AudioEffectMode } mode - Audio effect mode. 8105 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8106 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8107 * 1.Mandatory parameters are left unspecified; 8108 * 2.Incorrect parameter types. 8109 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by callback. 8110 * @syscap SystemCapability.Multimedia.Audio.Renderer 8111 * @since 10 8112 */ 8113 setAudioEffectMode(mode: AudioEffectMode, callback: AsyncCallback<void>): void; 8114 /** 8115 * Sets audio effect mode for current audio renderer. This method uses a promise to return the result. 8116 * @param { AudioEffectMode } mode - Audio effect mode. 8117 * @returns { Promise<void> } Promise used to return the result. 8118 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8119 * 1.Mandatory parameters are left unspecified; 8120 * 2.Incorrect parameter types. 8121 * @throws { BusinessError } 6800101 - Parameter verification failed. Return by promise. 8122 * @syscap SystemCapability.Multimedia.Audio.Renderer 8123 * @since 10 8124 */ 8125 setAudioEffectMode(mode: AudioEffectMode): Promise<void>; 8126 8127 /** 8128 * Starts the renderer. 8129 * Success: This method uses an asynchronous callback to return the result. 8130 * Failure: This method uses an asynchronous callback to return the error instance. Possible causes: 8131 * 6800301: Unsupported state, Audio focus request failed, System error. 8132 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8133 * @syscap SystemCapability.Multimedia.Audio.Renderer 8134 * @since 8 8135 */ 8136 /** 8137 * Starts the renderer. This method uses an asynchronous callback to return the result. 8138 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8139 * @syscap SystemCapability.Multimedia.Audio.Renderer 8140 * @crossplatform 8141 * @since 12 8142 */ 8143 start(callback: AsyncCallback<void>): void; 8144 /** 8145 * Starts the renderer. 8146 * Success: This method uses a promise to return the result. 8147 * Failure: This method uses a promise to return the error instance. Possible causes: 8148 * 6800301: Unsupported state, Audio focus request failed, System error. 8149 * @returns { Promise<void> } Promise used to return the result. 8150 * @syscap SystemCapability.Multimedia.Audio.Renderer 8151 * @since 8 8152 */ 8153 /** 8154 * Starts the renderer. This method uses a promise to return the result. 8155 * @returns { Promise<void> } Promise used to return the result. 8156 * @syscap SystemCapability.Multimedia.Audio.Renderer 8157 * @crossplatform 8158 * @since 12 8159 */ 8160 start(): Promise<void>; 8161 8162 /** 8163 * Writes the buffer. This method uses an asynchronous callback to return the result. 8164 * @param { ArrayBuffer } buffer - Buffer to be written. 8165 * @param { AsyncCallback<number> } callback - Returns the number of bytes written if the operation is successful. 8166 * Returns an error code otherwise. 8167 * @syscap SystemCapability.Multimedia.Audio.Renderer 8168 * @since 8 8169 * @deprecated since 11 8170 * @useinstead ohos.multimedia.audio.AudioRenderer#event:writeData 8171 */ 8172 write(buffer: ArrayBuffer, callback: AsyncCallback<number>): void; 8173 /** 8174 * Writes the buffer. This method uses a promise to return the result. 8175 * @param { ArrayBuffer } buffer - Buffer to be written. 8176 * @returns { Promise<number> } Returns the number of bytes written if the operation is successful. 8177 * Returns an error code otherwise. 8178 * @syscap SystemCapability.Multimedia.Audio.Renderer 8179 * @since 8 8180 * @deprecated since 11 8181 * @useinstead ohos.multimedia.audio.AudioRenderer#event:writeData 8182 */ 8183 write(buffer: ArrayBuffer): Promise<number>; 8184 8185 /** 8186 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an 8187 * asynchronous callback to return the result. 8188 * @param { AsyncCallback<number> } callback - Callback used to return the timestamp. 8189 * @syscap SystemCapability.Multimedia.Audio.Renderer 8190 * @since 8 8191 */ 8192 /** 8193 * Obtains the timestamp for audio frame that passed by system framework most recently. 8194 * The timestamp is not accurate because audio device latency is not considered very thoughtfully. 8195 * This method uses an asynchronous callback to return the result. 8196 * @param { AsyncCallback<number> } callback - Callback used to return the audio timestamp based on the monotonic nanosecond system timer. 8197 * @syscap SystemCapability.Multimedia.Audio.Renderer 8198 * @crossplatform 8199 * @since 12 8200 */ 8201 getAudioTime(callback: AsyncCallback<number>): void; 8202 /** 8203 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a 8204 * promise to return the result. 8205 * @returns { Promise<number> } Promise used to return the timestamp. 8206 * @syscap SystemCapability.Multimedia.Audio.Renderer 8207 * @since 8 8208 */ 8209 /** 8210 * Obtains the timestamp for audio frame that passed by system framework most recently. 8211 * The timestamp is not accurate because audio device latency is not considered very thoughtfully. 8212 * This method uses a promise to return the result. 8213 * @returns { Promise<number> } Promise used to return the audio timestamp based on the monotonic nanosecond system timer. 8214 * @syscap SystemCapability.Multimedia.Audio.Renderer 8215 * @crossplatform 8216 * @since 12 8217 */ 8218 getAudioTime(): Promise<number>; 8219 /** 8220 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. 8221 * @returns { number } The audio timestamp. 8222 * @syscap SystemCapability.Multimedia.Audio.Renderer 8223 * @since 10 8224 */ 8225 /** 8226 * Obtains the timestamp for audio frame that passed by system framework most recently. 8227 * The timestamp is not accurate because audio device latency is not considered very thoughtfully. 8228 * @returns { number } The audio timestamp based on the monotonic nanosecond system timer. 8229 * @syscap SystemCapability.Multimedia.Audio.Renderer 8230 * @crossplatform 8231 * @since 12 8232 */ 8233 getAudioTimeSync(): number; 8234 8235 /** 8236 * Obtains the timestamp info. 8237 * 8238 * @returns { Promise<AudioTimestampInfo> } The Promise used to return timestamp info. 8239 * @throws { BusinessError } 6800103 - Operation not permit at current state. 8240 * @syscap SystemCapability.Multimedia.Audio.Renderer 8241 * @since 19 8242 */ 8243 getAudioTimestampInfo(): Promise<AudioTimestampInfo>; 8244 8245 /** 8246 * Obtains the timestamp info. 8247 * 8248 * @returns { AudioTimestampInfo } The returned timestamp info. 8249 * @throws { BusinessError } 6800103 - Operation not permit at current state. 8250 * @syscap SystemCapability.Multimedia.Audio.Renderer 8251 * @since 19 8252 */ 8253 getAudioTimestampInfoSync(): AudioTimestampInfo; 8254 8255 /** 8256 * Drains the playback buffer. This method uses an asynchronous callback to return the result. 8257 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8258 * @syscap SystemCapability.Multimedia.Audio.Renderer 8259 * @since 8 8260 */ 8261 /** 8262 * Drains the playback buffer. This method uses an asynchronous callback to return the result. 8263 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8264 * @syscap SystemCapability.Multimedia.Audio.Renderer 8265 * @crossplatform 8266 * @since 12 8267 */ 8268 drain(callback: AsyncCallback<void>): void; 8269 /** 8270 * Drains the playback buffer. This method uses a promise to return the result. 8271 * @returns { Promise<void> } Promise used to return the result. 8272 * @syscap SystemCapability.Multimedia.Audio.Renderer 8273 * @since 8 8274 */ 8275 /** 8276 * Drains the playback buffer. This method uses a promise to return the result. 8277 * @returns { Promise<void> } Promise used to return the result. 8278 * @syscap SystemCapability.Multimedia.Audio.Renderer 8279 * @crossplatform 8280 * @since 12 8281 */ 8282 drain(): Promise<void>; 8283 8284 /** 8285 * Flushes the playback buffer. This method uses a promise to return the result. 8286 * @returns { Promise<void> } Promise used to return the result. 8287 * @throws { BusinessError } 6800103 - Operation not permit at current state. Return by promise. 8288 * @syscap SystemCapability.Multimedia.Audio.Renderer 8289 * @since 11 8290 */ 8291 /** 8292 * Flushes the playback buffer. This method uses a promise to return the result. 8293 * @returns { Promise<void> } Promise used to return the result. 8294 * @throws { BusinessError } 6800103 - Operation not permit at current state. Return by promise. 8295 * @syscap SystemCapability.Multimedia.Audio.Renderer 8296 * @crossplatform 8297 * @since 12 8298 */ 8299 flush(): Promise<void>; 8300 8301 /** 8302 * Pauses rendering. This method uses an asynchronous callback to return the result. 8303 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8304 * @syscap SystemCapability.Multimedia.Audio.Renderer 8305 * @since 8 8306 */ 8307 /** 8308 * Pauses rendering. This method uses an asynchronous callback to return the result. 8309 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8310 * @syscap SystemCapability.Multimedia.Audio.Renderer 8311 * @crossplatform 8312 * @since 12 8313 */ 8314 pause(callback: AsyncCallback<void>): void; 8315 /** 8316 * Pauses rendering. This method uses a promise to return the result. 8317 * @returns { Promise<void> } Promise used to return the result. 8318 * @syscap SystemCapability.Multimedia.Audio.Renderer 8319 * @since 8 8320 */ 8321 /** 8322 * Pauses rendering. This method uses a promise to return the result. 8323 * @returns { Promise<void> } Promise used to return the result. 8324 * @syscap SystemCapability.Multimedia.Audio.Renderer 8325 * @crossplatform 8326 * @since 12 8327 */ 8328 pause(): Promise<void>; 8329 8330 /** 8331 * Stops rendering. This method uses an asynchronous callback to return the result. 8332 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8333 * @syscap SystemCapability.Multimedia.Audio.Renderer 8334 * @since 8 8335 */ 8336 /** 8337 * Stops rendering. This method uses an asynchronous callback to return the result. 8338 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8339 * @syscap SystemCapability.Multimedia.Audio.Renderer 8340 * @crossplatform 8341 * @since 12 8342 */ 8343 stop(callback: AsyncCallback<void>): void; 8344 /** 8345 * Stops rendering. This method uses a promise to return the result. 8346 * @returns { Promise<void> } Promise used to return the result. 8347 * @syscap SystemCapability.Multimedia.Audio.Renderer 8348 * @since 8 8349 */ 8350 /** 8351 * Stops rendering. This method uses a promise to return the result. 8352 * @returns { Promise<void> } Promise used to return the result. 8353 * @syscap SystemCapability.Multimedia.Audio.Renderer 8354 * @crossplatform 8355 * @since 12 8356 */ 8357 stop(): Promise<void>; 8358 8359 /** 8360 * Releases the renderer. This method uses an asynchronous callback to return the result. 8361 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8362 * @syscap SystemCapability.Multimedia.Audio.Renderer 8363 * @since 8 8364 */ 8365 /** 8366 * Releases the renderer. This method uses an asynchronous callback to return the result. 8367 * <p><strong>NOTE</strong>: 8368 * The framework will not actively release audio streams in the Stop/Pause state. 8369 * Please make sure to call this method to release the stream when it is no longer needed. 8370 * </p> 8371 * 8372 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8373 * @syscap SystemCapability.Multimedia.Audio.Renderer 8374 * @crossplatform 8375 * @since 12 8376 */ 8377 release(callback: AsyncCallback<void>): void; 8378 /** 8379 * Releases the renderer. This method uses a promise to return the result. 8380 * @returns { Promise<void> } Promise used to return the result. 8381 * @syscap SystemCapability.Multimedia.Audio.Renderer 8382 * @since 8 8383 */ 8384 /** 8385 * Releases the renderer. This method uses a promise to return the result. 8386 * <p><strong>NOTE</strong>: 8387 * The framework will not actively release audio streams in the Stop/Pause state. 8388 * Please make sure to call this method to release the stream when it is no longer needed. 8389 * </p> 8390 * 8391 * @returns { Promise<void> } Promise used to return the result. 8392 * @syscap SystemCapability.Multimedia.Audio.Renderer 8393 * @crossplatform 8394 * @since 12 8395 */ 8396 release(): Promise<void>; 8397 8398 /** 8399 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to 8400 * return the result. 8401 * @param { AsyncCallback<number> } callback - Callback used to return the buffer size. 8402 * @syscap SystemCapability.Multimedia.Audio.Renderer 8403 * @since 8 8404 */ 8405 /** 8406 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to 8407 * return the result. 8408 * @param { AsyncCallback<number> } callback - Callback used to return the buffer size. 8409 * @syscap SystemCapability.Multimedia.Audio.Renderer 8410 * @crossplatform 8411 * @since 12 8412 */ 8413 getBufferSize(callback: AsyncCallback<number>): void; 8414 /** 8415 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result. 8416 * @returns { Promise<number> } Promise used to return the buffer size. 8417 * @syscap SystemCapability.Multimedia.Audio.Renderer 8418 * @since 8 8419 */ 8420 /** 8421 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result. 8422 * @returns { Promise<number> } Promise used to return the buffer size. 8423 * @syscap SystemCapability.Multimedia.Audio.Renderer 8424 * @crossplatform 8425 * @since 12 8426 */ 8427 getBufferSize(): Promise<number>; 8428 /** 8429 * Obtains a reasonable minimum buffer size in bytes for rendering. 8430 * @returns { number } The audio buffer size. 8431 * @syscap SystemCapability.Multimedia.Audio.Renderer 8432 * @since 10 8433 */ 8434 /** 8435 * Obtains a reasonable minimum buffer size in bytes for rendering. 8436 * @returns { number } The audio buffer size. 8437 * @syscap SystemCapability.Multimedia.Audio.Renderer 8438 * @crossplatform 8439 * @since 12 8440 */ 8441 getBufferSizeSync(): number; 8442 8443 /** 8444 * Sets the render rate. This method uses an asynchronous callback to return the result. 8445 * @param { AudioRendererRate } rate - Audio render rate. 8446 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8447 * @syscap SystemCapability.Multimedia.Audio.Renderer 8448 * @since 8 8449 * @deprecated since 11 8450 * @useinstead ohos.multimedia.audio.AudioRenderer#setSpeed 8451 */ 8452 setRenderRate(rate: AudioRendererRate, callback: AsyncCallback<void>): void; 8453 8454 /** 8455 * Sets the render rate. This method uses a promise to return the result. 8456 * @param { AudioRendererRate } rate - Audio render rate. 8457 * @returns { Promise<void> } Promise used to return the result. 8458 * @syscap SystemCapability.Multimedia.Audio.Renderer 8459 * @since 8 8460 * @deprecated since 11 8461 * @useinstead ohos.multimedia.audio.AudioRenderer#setSpeed 8462 */ 8463 setRenderRate(rate: AudioRendererRate): Promise<void>; 8464 8465 /** 8466 * Sets the playback speed. 8467 * @param { number } speed - Audio playback speed. The value type is float, form 0.25 to 4.0. 8468 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8469 * 1.Mandatory parameters are left unspecified; 8470 * 2.Incorrect parameter types. 8471 * @throws { BusinessError } 6800101 - Parameter verification failed. 8472 * @syscap SystemCapability.Multimedia.Audio.Renderer 8473 * @since 11 8474 */ 8475 /** 8476 * Sets the playback speed. 8477 * @param { number } speed - Audio playback speed. The value type is float, form 0.25 to 4.0. 8478 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8479 * 1.Mandatory parameters are left unspecified; 8480 * 2.Incorrect parameter types. 8481 * @throws { BusinessError } 6800101 - Parameter verification failed. 8482 * @syscap SystemCapability.Multimedia.Audio.Renderer 8483 * @crossplatform 8484 * @since 12 8485 */ 8486 setSpeed(speed: number): void; 8487 8488 /** 8489 * Obtains the current render rate. This method uses an asynchronous callback to return the result. 8490 * @param { AsyncCallback<AudioRendererRate> } callback - Callback used to return the audio render rate. 8491 * @syscap SystemCapability.Multimedia.Audio.Renderer 8492 * @since 8 8493 * @deprecated since 11 8494 * @useinstead ohos.multimedia.audio.AudioRenderer#getSpeed 8495 */ 8496 getRenderRate(callback: AsyncCallback<AudioRendererRate>): void; 8497 8498 /** 8499 * Obtains the current render rate. This method uses a promise to return the result. 8500 * @returns { Promise<AudioRendererRate> } Promise used to return the audio render rate. 8501 * @syscap SystemCapability.Multimedia.Audio.Renderer 8502 * @since 8 8503 * @deprecated since 11 8504 * @useinstead ohos.multimedia.audio.AudioRenderer#getSpeed 8505 */ 8506 getRenderRate(): Promise<AudioRendererRate>; 8507 8508 /** 8509 * Obtains the current render rate. 8510 * @returns { AudioRendererRate } The audio render rate. 8511 * @syscap SystemCapability.Multimedia.Audio.Renderer 8512 * @since 10 8513 * @deprecated since 11 8514 * @useinstead ohos.multimedia.audio.AudioRenderer#getSpeed 8515 */ 8516 getRenderRateSync(): AudioRendererRate; 8517 8518 /** 8519 * Obtains the current playback speed. 8520 * @returns { number } The playback speed. 8521 * @syscap SystemCapability.Multimedia.Audio.Renderer 8522 * @since 11 8523 */ 8524 /** 8525 * Obtains the current playback speed. 8526 * @returns { number } The playback speed. 8527 * @syscap SystemCapability.Multimedia.Audio.Renderer 8528 * @crossplatform 8529 * @since 12 8530 */ 8531 getSpeed(): number; 8532 8533 /** 8534 * Set interrupt mode. 8535 * @param { InterruptMode } mode - The interrupt mode. 8536 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8537 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8538 * @since 9 8539 */ 8540 /** 8541 * Set interrupt mode. 8542 * @param { InterruptMode } mode - The interrupt mode. 8543 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8544 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8545 * @crossplatform 8546 * @since 12 8547 */ 8548 setInterruptMode(mode: InterruptMode, callback: AsyncCallback<void>): void; 8549 /** 8550 * Set interrupt mode. 8551 * @param { InterruptMode } mode - The interrupt mode. 8552 * @returns { Promise<void> } Promise used to return the result. 8553 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8554 * @since 9 8555 */ 8556 /** 8557 * Set interrupt mode. 8558 * @param { InterruptMode } mode - The interrupt mode. 8559 * @returns { Promise<void> } Promise used to return the result. 8560 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8561 * @crossplatform 8562 * @since 12 8563 */ 8564 setInterruptMode(mode: InterruptMode): Promise<void>; 8565 /** 8566 * Set interrupt mode. 8567 * @param { InterruptMode } mode - The interrupt mode. 8568 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8569 * 1.Mandatory parameters are left unspecified; 8570 * 2.Incorrect parameter types. 8571 * @throws { BusinessError } 6800101 - Parameter verification failed. 8572 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8573 * @since 10 8574 */ 8575 /** 8576 * Set interrupt mode. 8577 * @param { InterruptMode } mode - The interrupt mode. 8578 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8579 * 1.Mandatory parameters are left unspecified; 8580 * 2.Incorrect parameter types. 8581 * @throws { BusinessError } 6800101 - Parameter verification failed. 8582 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8583 * @crossplatform 8584 * @since 12 8585 */ 8586 setInterruptModeSync(mode: InterruptMode): void; 8587 8588 /** 8589 * Sets the volume for this stream. This method uses an asynchronous callback to return the result. 8590 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 8591 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8592 * @syscap SystemCapability.Multimedia.Audio.Renderer 8593 * @since 9 8594 */ 8595 /** 8596 * Sets the volume for this stream. This method uses an asynchronous callback to return the result. 8597 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 8598 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8599 * @syscap SystemCapability.Multimedia.Audio.Renderer 8600 * @crossplatform 8601 * @since 12 8602 */ 8603 setVolume(volume: number, callback: AsyncCallback<void>): void; 8604 /** 8605 * Sets the volume for a stream. This method uses a promise to return the result. 8606 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 8607 * @returns { Promise<void> } Promise used to return the result. 8608 * @syscap SystemCapability.Multimedia.Audio.Renderer 8609 * @since 9 8610 */ 8611 /** 8612 * Sets the volume for a stream. This method uses a promise to return the result. 8613 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 8614 * @returns { Promise<void> } Promise used to return the result. 8615 * @syscap SystemCapability.Multimedia.Audio.Renderer 8616 * @crossplatform 8617 * @since 12 8618 */ 8619 setVolume(volume: number): Promise<void>; 8620 8621 /** 8622 * Gets volume of this stream. 8623 * @returns { number } Returns one float value. 8624 * @syscap SystemCapability.Multimedia.Audio.Renderer 8625 * @since 12 8626 */ 8627 getVolume(): number; 8628 8629 /** 8630 * Changes the volume with ramp for a duration. 8631 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 8632 * @param { number } duration - Duration for volume ramp, in millisecond. 8633 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8634 * 1.Mandatory parameters are left unspecified; 8635 * 2.Incorrect parameter types. 8636 * @throws { BusinessError } 6800101 - Parameter verification failed. 8637 * @syscap SystemCapability.Multimedia.Audio.Renderer 8638 * @since 11 8639 */ 8640 /** 8641 * Changes the volume with ramp for a duration. 8642 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 8643 * @param { number } duration - Duration for volume ramp, in millisecond. 8644 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8645 * 1.Mandatory parameters are left unspecified; 8646 * 2.Incorrect parameter types. 8647 * @throws { BusinessError } 6800101 - Parameter verification failed. 8648 * @syscap SystemCapability.Multimedia.Audio.Renderer 8649 * @crossplatform 8650 * @since 12 8651 */ 8652 setVolumeWithRamp(volume: number, duration: number): void; 8653 8654 /** 8655 * Gets the min volume this stream can set. This method uses an asynchronous callback to return the result. 8656 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8657 * @syscap SystemCapability.Multimedia.Audio.Renderer 8658 * @since 10 8659 */ 8660 /** 8661 * Gets the min volume this stream can set. This method uses an asynchronous callback to return the result. 8662 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8663 * @syscap SystemCapability.Multimedia.Audio.Renderer 8664 * @crossplatform 8665 * @since 12 8666 */ 8667 getMinStreamVolume(callback: AsyncCallback<number>): void; 8668 /** 8669 * Gets the min volume this stream can set. This method uses a promise to return the result. 8670 * @returns { Promise<number> } Promise used to return the result. 8671 * @syscap SystemCapability.Multimedia.Audio.Renderer 8672 * @since 10 8673 */ 8674 /** 8675 * Gets the min volume this stream can set. This method uses a promise to return the result. 8676 * @returns { Promise<number> } Promise used to return the result. 8677 * @syscap SystemCapability.Multimedia.Audio.Renderer 8678 * @crossplatform 8679 * @since 12 8680 */ 8681 getMinStreamVolume(): Promise<number>; 8682 /** 8683 * Gets the min volume this stream can set. 8684 * @returns { number } Min stream volume. 8685 * @syscap SystemCapability.Multimedia.Audio.Renderer 8686 * @since 10 8687 */ 8688 /** 8689 * Gets the min volume this stream can set. 8690 * @returns { number } Min stream volume. 8691 * @syscap SystemCapability.Multimedia.Audio.Renderer 8692 * @crossplatform 8693 * @since 12 8694 */ 8695 getMinStreamVolumeSync(): number; 8696 8697 /** 8698 * Gets the max volume this stream can set. This method uses an asynchronous callback to return the result. 8699 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8700 * @syscap SystemCapability.Multimedia.Audio.Renderer 8701 * @since 10 8702 */ 8703 /** 8704 * Gets the max volume this stream can set. This method uses an asynchronous callback to return the result. 8705 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8706 * @syscap SystemCapability.Multimedia.Audio.Renderer 8707 * @crossplatform 8708 * @since 12 8709 */ 8710 getMaxStreamVolume(callback: AsyncCallback<number>): void; 8711 /** 8712 * Gets the max volume this stream can set. This method uses a promise to return the result. 8713 * @returns { Promise<number> } Promise used to return the result. 8714 * @syscap SystemCapability.Multimedia.Audio.Renderer 8715 * @since 10 8716 */ 8717 /** 8718 * Gets the max volume this stream can set. This method uses a promise to return the result. 8719 * @returns { Promise<number> } Promise used to return the result. 8720 * @syscap SystemCapability.Multimedia.Audio.Renderer 8721 * @crossplatform 8722 * @since 12 8723 */ 8724 getMaxStreamVolume(): Promise<number>; 8725 /** 8726 * Gets the max volume this stream can set. 8727 * @returns { number } Max stream volume. 8728 * @syscap SystemCapability.Multimedia.Audio.Renderer 8729 * @since 10 8730 */ 8731 /** 8732 * Gets the max volume this stream can set. 8733 * @returns { number } Max stream volume. 8734 * @syscap SystemCapability.Multimedia.Audio.Renderer 8735 * @crossplatform 8736 * @since 12 8737 */ 8738 getMaxStreamVolumeSync(): number; 8739 8740 /** 8741 * Gets buffer underflow count. This method uses an asynchronous callback to return the result. 8742 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8743 * @syscap SystemCapability.Multimedia.Audio.Renderer 8744 * @since 10 8745 */ 8746 /** 8747 * Gets buffer underflow count. This method uses an asynchronous callback to return the result. 8748 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8749 * @syscap SystemCapability.Multimedia.Audio.Renderer 8750 * @crossplatform 8751 * @since 12 8752 */ 8753 getUnderflowCount(callback: AsyncCallback<number>): void; 8754 /** 8755 * Gets buffer underflow count. This method uses a promise to return the result. 8756 * @returns { Promise<number> } Promise used to return the result. 8757 * @syscap SystemCapability.Multimedia.Audio.Renderer 8758 * @since 10 8759 */ 8760 /** 8761 * Gets buffer underflow count. This method uses a promise to return the result. 8762 * @returns { Promise<number> } Promise used to return the result. 8763 * @syscap SystemCapability.Multimedia.Audio.Renderer 8764 * @crossplatform 8765 * @since 12 8766 */ 8767 getUnderflowCount(): Promise<number>; 8768 /** 8769 * Gets buffer underflow count. 8770 * @returns { number } Underflow count number. 8771 * @syscap SystemCapability.Multimedia.Audio.Renderer 8772 * @since 10 8773 */ 8774 /** 8775 * Gets buffer underflow count. 8776 * @returns { number } Underflow count number. 8777 * @syscap SystemCapability.Multimedia.Audio.Renderer 8778 * @crossplatform 8779 * @since 12 8780 */ 8781 getUnderflowCountSync(): number; 8782 8783 /** 8784 * Gets the output device or devices for this stream. 8785 * This method uses an asynchronous callback to return the result. 8786 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 8787 * @syscap SystemCapability.Multimedia.Audio.Device 8788 * @since 10 8789 */ 8790 /** 8791 * Gets the output device or devices for this stream. 8792 * This method uses an asynchronous callback to return the result. 8793 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 8794 * @syscap SystemCapability.Multimedia.Audio.Device 8795 * @crossplatform 8796 * @since 12 8797 */ 8798 getCurrentOutputDevices(callback: AsyncCallback<AudioDeviceDescriptors>): void; 8799 /** 8800 * Gets the output device or devices for this stream. 8801 * This method uses a promise to return the result. 8802 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 8803 * @syscap SystemCapability.Multimedia.Audio.Device 8804 * @since 10 8805 */ 8806 /** 8807 * Gets the output device or devices for this stream. 8808 * This method uses a promise to return the result. 8809 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 8810 * @syscap SystemCapability.Multimedia.Audio.Device 8811 * @crossplatform 8812 * @since 12 8813 */ 8814 getCurrentOutputDevices(): Promise<AudioDeviceDescriptors>; 8815 /** 8816 * Gets the output device or devices for this stream. 8817 * @returns { AudioDeviceDescriptors } Output device or devices. 8818 * @syscap SystemCapability.Multimedia.Audio.Device 8819 * @since 10 8820 */ 8821 /** 8822 * Gets the output device or devices for this stream. 8823 * @returns { AudioDeviceDescriptors } Output device or devices. 8824 * @syscap SystemCapability.Multimedia.Audio.Device 8825 * @crossplatform 8826 * @since 12 8827 */ 8828 getCurrentOutputDevicesSync(): AudioDeviceDescriptors; 8829 8830 /** 8831 * Sets channel blend mode for this stream. 8832 * @param { ChannelBlendMode } mode - Target channel blend mode. 8833 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8834 * 1.Mandatory parameters are left unspecified; 8835 * 2.Incorrect parameter types. 8836 * @throws { BusinessError } 6800101 - Parameter verification failed. 8837 * @throws { BusinessError } 6800103 - Operation not permit at current state. 8838 * @syscap SystemCapability.Multimedia.Audio.Renderer 8839 * @since 11 8840 */ 8841 /** 8842 * Sets channel blend mode for this stream. 8843 * @param { ChannelBlendMode } mode - Target channel blend mode. 8844 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8845 * 1.Mandatory parameters are left unspecified; 8846 * 2.Incorrect parameter types. 8847 * @throws { BusinessError } 6800101 - Parameter verification failed. 8848 * @throws { BusinessError } 6800103 - Operation not permit at current state. 8849 * @syscap SystemCapability.Multimedia.Audio.Renderer 8850 * @crossplatform 8851 * @since 12 8852 */ 8853 setChannelBlendMode(mode: ChannelBlendMode): void; 8854 8855 /** 8856 * Sets silent and mix with other stream for this stream. 8857 * @param { boolean } on - Whether play silent and mix with other streams. 8858 * true: set the silent mode and mix with other streams. 8859 * false: unset the silent mode, current stream will trigger the audio focus internally. 8860 * @syscap SystemCapability.Multimedia.Audio.Renderer 8861 * @since 12 8862 */ 8863 setSilentModeAndMixWithOthers(on: boolean): void; 8864 8865 /** 8866 * Gets silent and mix with other stream status for this stream. 8867 * @returns { boolean } Returns silent and mix with other stream status. 8868 * true: current stream is in the silent mode and mix with other streams. 8869 * false: current stream in in the normal playback mode 8870 * @syscap SystemCapability.Multimedia.Audio.Renderer 8871 * @since 12 8872 */ 8873 getSilentModeAndMixWithOthers(): boolean; 8874 8875 /** 8876 * Temporarily changes the current audio device 8877 * This function applys on audiorenderers whose StreamUsage are 8878 * STREAM_USAGE_VOICE_COMMUNICATIN/STREAM_USAGE_VIDEO_COMMUNICATION/STREAM_USAGE_VOICE_MESSAGE. 8879 * Setting the device will only takes effect if no other accessory such as headphones are in use 8880 * @param { DeviceType } deviceType - the available deviceTypes are 8881 * EARPIECE: Built-in earpiece 8882 * SPEAKER: Built-in speaker 8883 * DEFAULT: System default output device 8884 * @returns { Promise<void> } Promise used to return the result. 8885 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8886 * 1.Mandatory parameters are left unspecified; 8887 * 2.Incorrect parameter types. 8888 * @throws { BusinessError } 6800101 - Parameter verification failed. 8889 * @throws { BusinessError } 6800103 - Operation not permit at current state. 8890 * @syscap SystemCapability.Multimedia.Audio.Renderer 8891 * @since 12 8892 */ 8893 setDefaultOutputDevice(deviceType: DeviceType): Promise<void>; 8894 8895 /** 8896 * Sets the loudness gain of this stream. The default loudness gain is 0.0dB. 8897 * The stream usage of the audio renderer must be {@link StreamUsage#STREAM_USAGE_MUSIC}, 8898 * {@link StreamUsage#STREAM_USAGE_MOVIE} or {@link StreamUsage#STREAM_USAGE_AUDIOBOOK}. 8899 * After calling this interface, the adjustment of loundness gain will take effect immediately. 8900 * @param { number } loudnessGain - Loudness gain to set, expressed in dB. The value type is float. 8901 * The loudness gain changes from -90.0dB to 24.0dB. 8902 * @returns { Promise<void> } Promise used to return the result. 8903 * @throws { BusinessError } 6800101 - Parameter verification failed. 8904 * @throws { BusinessError } 6800104 - Operation is not supported on this renderer, e.g. the stream usage of this 8905 * renderer is not one of {@link StreamUsage#STREAM_USAGE_MUSIC}, {@link StreamUsage#STREAM_USAGE_MOVIE} or 8906 * {@link StreamUsage#STREAM_USAGE_AUDIOBOOK}, or this renderer is routed through the high-resolution playback path. 8907 * @syscap SystemCapability.Multimedia.Audio.Renderer 8908 * @since 20 8909 */ 8910 setLoudnessGain(loudnessGain: number): Promise<void>; 8911 8912 /** 8913 * Gets loudness gain of this stream. 8914 * @returns { number } Returns one float value. 8915 * @syscap SystemCapability.Multimedia.Audio.Renderer 8916 * @since 20 8917 */ 8918 getLoudnessGain(): number; 8919 8920 /** 8921 * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is 8922 * triggered when audio playback is interrupted. 8923 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 8924 * @param { Callback<InterruptEvent> } callback - Callback used to listen for interrupt callback. 8925 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8926 * 1.Mandatory parameters are left unspecified; 8927 * 2.Incorrect parameter types. 8928 * @throws { BusinessError } 6800101 - Parameter verification failed. 8929 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8930 * @since 9 8931 */ 8932 /** 8933 * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is 8934 * triggered when audio playback is interrupted. 8935 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 8936 * @param { Callback<InterruptEvent> } callback - Callback used to listen for interrupt callback. 8937 * @throws { BusinessError } 401 - Parameter error. Possible causes: 8938 * 1.Mandatory parameters are left unspecified; 8939 * 2.Incorrect parameter types. 8940 * @throws { BusinessError } 6800101 - Parameter verification failed. 8941 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8942 * @crossplatform 8943 * @since 12 8944 */ 8945 on(type: 'audioInterrupt', callback: Callback<InterruptEvent>): void; 8946 8947 /** 8948 * Unsubscribes audio interrupt events. 8949 * @param { 'audioInterrupt' } type - Type of the event to listen for. 8950 * @param { Callback<InterruptEvent> } callback - Callback used to listen for interrupt callback. 8951 * @throws { BusinessError } 6800101 - Parameter verification failed. 8952 * @syscap SystemCapability.Multimedia.Audio.Interrupt 8953 * @since 18 8954 */ 8955 off(type: 'audioInterrupt', callback?: Callback<InterruptEvent>): void; 8956 8957 /** 8958 * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, 8959 * the callback is invoked. 8960 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 8961 * @param { number } frame - Number of frames to trigger the event. The value must be greater than 0. 8962 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 8963 * @syscap SystemCapability.Multimedia.Audio.Renderer 8964 * @since 8 8965 */ 8966 /** 8967 * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, 8968 * the callback is invoked. 8969 * <p><strong>NOTE</strong>: 8970 * Before renderer release, the value of internal records frames will continue to increase, 8971 * and operations such as stop/pause/flush/drain will not reset this value. 8972 * </p> 8973 * 8974 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 8975 * @param { number } frame - Number of frames to trigger the event. The value must be greater than 0. 8976 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 8977 * @syscap SystemCapability.Multimedia.Audio.Renderer 8978 * @crossplatform 8979 * @since 12 8980 */ 8981 on(type: 'markReach', frame: number, callback: Callback<number>): void; 8982 /** 8983 * Unsubscribes from mark reached events. 8984 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 8985 * @syscap SystemCapability.Multimedia.Audio.Renderer 8986 * @since 8 8987 */ 8988 /** 8989 * Unsubscribes from mark reached events. 8990 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 8991 * @syscap SystemCapability.Multimedia.Audio.Renderer 8992 * @crossplatform 8993 * @since 12 8994 */ 8995 /** 8996 * Unsubscribes from mark reached events. 8997 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 8998 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 8999 * @syscap SystemCapability.Multimedia.Audio.Renderer 9000 * @crossplatform 9001 * @since 18 9002 */ 9003 off(type: 'markReach', callback?: Callback<number>): void; 9004 9005 /** 9006 * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, 9007 * the callback is invoked. 9008 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 9009 * @param { number } frame - Period during which frame rendering is listened. The value must be greater than 0. 9010 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 9011 * @syscap SystemCapability.Multimedia.Audio.Renderer 9012 * @since 8 9013 */ 9014 /** 9015 * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, 9016 * the callback is invoked. 9017 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 9018 * @param { number } frame - Period during which frame rendering is listened. The value must be greater than 0. 9019 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 9020 * @syscap SystemCapability.Multimedia.Audio.Renderer 9021 * @crossplatform 9022 * @since 12 9023 */ 9024 on(type: 'periodReach', frame: number, callback: Callback<number>): void; 9025 /** 9026 * Unsubscribes from period reached events. 9027 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 9028 * @syscap SystemCapability.Multimedia.Audio.Renderer 9029 * @since 8 9030 */ 9031 /** 9032 * Unsubscribes from period reached events. 9033 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 9034 * @syscap SystemCapability.Multimedia.Audio.Renderer 9035 * @crossplatform 9036 * @since 12 9037 */ 9038 /** 9039 * Unsubscribes from period reached events. 9040 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 9041 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 9042 * @syscap SystemCapability.Multimedia.Audio.Renderer 9043 * @crossplatform 9044 * @since 18 9045 */ 9046 off(type: 'periodReach', callback?: Callback<number>): void; 9047 9048 /** 9049 * Subscribes audio state change event callback. 9050 * @param { 'stateChange' } type - Type of the event to listen for. Only the stateChange event is supported. 9051 * @param { Callback<AudioState> } callback - Callback invoked when state change. 9052 * @syscap SystemCapability.Multimedia.Audio.Renderer 9053 * @since 8 9054 */ 9055 /** 9056 * Subscribes audio renderer state change event callback. 9057 * @param { 'stateChange' } type - Type of the event to listen for. Only the stateChange event is supported. 9058 * @param { Callback<AudioState> } callback - Callback invoked when state change. 9059 * @syscap SystemCapability.Multimedia.Audio.Renderer 9060 * @crossplatform 9061 * @since 12 9062 */ 9063 on(type: 'stateChange', callback: Callback<AudioState>): void; 9064 9065 /** 9066 * Unsubscribes audio state change event callback. 9067 * @param { 'stateChange' } type - Type of the event to listen for. 9068 * @param { Callback<AudioState> } callback - Callback invoked when state change. 9069 * @throws { BusinessError } 6800101 - Parameter verification failed. 9070 * @syscap SystemCapability.Multimedia.Audio.Renderer 9071 * @since 18 9072 */ 9073 off(type: 'stateChange', callback?: Callback<AudioState>): void; 9074 9075 /** 9076 * Subscribes output device change event callback. 9077 * The event is triggered when output device change for this stream. 9078 * @param { 'outputDeviceChange' } type - Type of the event to listen for. 9079 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to listen device change event. 9080 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9081 * 1.Mandatory parameters are left unspecified; 9082 * 2.Incorrect parameter types. 9083 * @throws { BusinessError } 6800101 - Parameter verification failed. 9084 * @syscap SystemCapability.Multimedia.Audio.Device 9085 * @since 10 9086 */ 9087 /** 9088 * Subscribes output device change event callback. 9089 * The event is triggered when output device change for this stream. 9090 * @param { 'outputDeviceChange' } type - Type of the event to listen for. 9091 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to listen device change event. 9092 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9093 * 1.Mandatory parameters are left unspecified; 9094 * 2.Incorrect parameter types. 9095 * @throws { BusinessError } 6800101 - Parameter verification failed. 9096 * @syscap SystemCapability.Multimedia.Audio.Device 9097 * @crossplatform 9098 * @since 12 9099 */ 9100 on(type: 'outputDeviceChange', callback: Callback<AudioDeviceDescriptors>): void; 9101 9102 /** 9103 * Subscribes output device change event callback. 9104 * The event is triggered when output device change for this stream. 9105 * @param { 'outputDeviceChangeWithInfo' } type - Type of the event to listen for. 9106 * @param { Callback<AudioStreamDeviceChangeInfo> } callback - Callback used to listen device change event. 9107 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9108 * 1.Mandatory parameters are left unspecified; 9109 * 2.Incorrect parameter types. 9110 * @throws { BusinessError } 6800101 - Parameter verification failed. 9111 * @syscap SystemCapability.Multimedia.Audio.Device 9112 * @since 11 9113 */ 9114 /** 9115 * Subscribes output device change event callback. 9116 * The event is triggered when output device change for this stream. 9117 * @param { 'outputDeviceChangeWithInfo' } type - Type of the event to listen for. 9118 * @param { Callback<AudioStreamDeviceChangeInfo> } callback - Callback used to listen device change event. 9119 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9120 * 1.Mandatory parameters are left unspecified; 9121 * 2.Incorrect parameter types. 9122 * @throws { BusinessError } 6800101 - Parameter verification failed. 9123 * @syscap SystemCapability.Multimedia.Audio.Device 9124 * @crossplatform 9125 * @since 12 9126 */ 9127 on(type: 'outputDeviceChangeWithInfo', callback: Callback<AudioStreamDeviceChangeInfo>): void; 9128 9129 /** 9130 * Unsubscribes output device change event callback. 9131 * @param { 'outputDeviceChange' } type - Type of the event to listen for. 9132 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used in subscribe. 9133 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9134 * 1.Mandatory parameters are left unspecified; 9135 * 2.Incorrect parameter types. 9136 * @throws { BusinessError } 6800101 - Parameter verification failed. 9137 * @syscap SystemCapability.Multimedia.Audio.Device 9138 * @since 10 9139 */ 9140 /** 9141 * Unsubscribes output device change event callback. 9142 * @param { 'outputDeviceChange' } type - Type of the event to listen for. 9143 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used in subscribe. 9144 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9145 * 1.Mandatory parameters are left unspecified; 9146 * 2.Incorrect parameter types. 9147 * @throws { BusinessError } 6800101 - Parameter verification failed. 9148 * @syscap SystemCapability.Multimedia.Audio.Device 9149 * @crossplatform 9150 * @since 12 9151 */ 9152 off(type: 'outputDeviceChange', callback?: Callback<AudioDeviceDescriptors>): void; 9153 9154 /** 9155 * Unsubscribes output device change event callback. 9156 * @param { 'outputDeviceChangeWithInfo' } type - Type of the event to listen for. 9157 * @param { Callback<AudioStreamDeviceChangeInfo> } callback - Callback used in subscribe. 9158 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9159 * 1.Mandatory parameters are left unspecified; 9160 * 2.Incorrect parameter types. 9161 * @throws { BusinessError } 6800101 - Parameter verification failed. 9162 * @syscap SystemCapability.Multimedia.Audio.Device 9163 * @since 11 9164 */ 9165 /** 9166 * Unsubscribes output device change event callback. 9167 * @param { 'outputDeviceChangeWithInfo' } type - Type of the event to listen for. 9168 * @param { Callback<AudioStreamDeviceChangeInfo> } callback - Callback used in subscribe. 9169 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9170 * 1.Mandatory parameters are left unspecified; 9171 * 2.Incorrect parameter types. 9172 * @throws { BusinessError } 6800101 - Parameter verification failed. 9173 * @syscap SystemCapability.Multimedia.Audio.Device 9174 * @crossplatform 9175 * @since 12 9176 */ 9177 off(type: 'outputDeviceChangeWithInfo', callback?: Callback<AudioStreamDeviceChangeInfo>): void; 9178 9179 /** 9180 * Subscribes audio data callback. 9181 * The event is triggered when audio buffer is available for writing more data. 9182 * @param { 'writeData' } type - Type of the event to listen for. 9183 * @param { Callback<ArrayBuffer> } callback - Callback with buffer to write. 9184 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9185 * 1.Mandatory parameters are left unspecified; 9186 * 2.Incorrect parameter types. 9187 * @throws { BusinessError } 6800101 - Parameter verification failed. 9188 * @syscap SystemCapability.Multimedia.Audio.Renderer 9189 * @since 11 9190 */ 9191 /** 9192 * Subscribes audio data callback. 9193 * The event is triggered when audio buffer is available for writing more data. 9194 * @param { 'writeData' } type - Type of the event to listen for. 9195 * @param { AudioRendererWriteDataCallback } callback - Audio renderer write data callback. 9196 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9197 * 1.Mandatory parameters are left unspecified; 9198 * 2.Incorrect parameter types. 9199 * @throws { BusinessError } 6800101 - Parameter verification failed. 9200 * @syscap SystemCapability.Multimedia.Audio.Renderer 9201 * @crossplatform 9202 * @since 12 9203 */ 9204 on(type: 'writeData', callback: AudioRendererWriteDataCallback): void; 9205 9206 /** 9207 * Unsubscribes audio data callback. 9208 * @param { 'writeData' } type - Type of the event to listen for. 9209 * @param { Callback<ArrayBuffer> } callback - Callback used in subscribe. 9210 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9211 * 1.Mandatory parameters are left unspecified; 9212 * 2.Incorrect parameter types. 9213 * @throws { BusinessError } 6800101 - Parameter verification failed. 9214 * @syscap SystemCapability.Multimedia.Audio.Renderer 9215 * @since 11 9216 */ 9217 /** 9218 * Unsubscribes audio data callback. 9219 * @param { 'writeData' } type - Type of the event to listen for. 9220 * @param { AudioRendererWriteDataCallback } callback - Audio renderer write data callback. 9221 * @throws { BusinessError } 401 - Parameter error. Possible causes: 9222 * 1.Mandatory parameters are left unspecified; 9223 * 2.Incorrect parameter types. 9224 * @throws { BusinessError } 6800101 - Parameter verification failed. 9225 * @syscap SystemCapability.Multimedia.Audio.Renderer 9226 * @crossplatform 9227 * @since 12 9228 */ 9229 off(type: 'writeData', callback?: AudioRendererWriteDataCallback): void; 9230 } 9231 9232 /** 9233 * Enumerates source types. 9234 * @enum { number } 9235 * @syscap SystemCapability.Multimedia.Audio.Core 9236 * @since 8 9237 */ 9238 /** 9239 * Enumerates source types. 9240 * @enum { number } 9241 * @syscap SystemCapability.Multimedia.Audio.Core 9242 * @crossplatform 9243 * @since 12 9244 */ 9245 enum SourceType { 9246 /** 9247 * Invalid source type. 9248 * @syscap SystemCapability.Multimedia.Audio.Core 9249 * @since 8 9250 */ 9251 SOURCE_TYPE_INVALID = -1, 9252 /** 9253 * Mic source type. 9254 * @syscap SystemCapability.Multimedia.Audio.Core 9255 * @since 8 9256 */ 9257 /** 9258 * Mic source type. 9259 * @syscap SystemCapability.Multimedia.Audio.Core 9260 * @crossplatform 9261 * @since 12 9262 */ 9263 SOURCE_TYPE_MIC = 0, 9264 /** 9265 * Voice recognition source type. 9266 * @syscap SystemCapability.Multimedia.Audio.Core 9267 * @since 9 9268 */ 9269 /** 9270 * Voice recognition source type. 9271 * @syscap SystemCapability.Multimedia.Audio.Core 9272 * @crossplatform 9273 * @since 12 9274 */ 9275 SOURCE_TYPE_VOICE_RECOGNITION = 1, 9276 /** 9277 * Playback capture source type. 9278 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 9279 * @since 10 9280 * @deprecated since 12 9281 * @useinstead OH_AVScreenCapture in native interface. 9282 */ 9283 SOURCE_TYPE_PLAYBACK_CAPTURE = 2, 9284 /** 9285 * Wakeup source type. 9286 * Permission ohos.permission.MANAGE_INTELLIGENT_VOICE is needed when calling createAudioCapturer with this type. 9287 * @syscap SystemCapability.Multimedia.Audio.Core 9288 * @systemapi 9289 * @since 10 9290 */ 9291 SOURCE_TYPE_WAKEUP = 3, 9292 9293 /** 9294 * Voice call source type. 9295 * Permission ohos.permission.RECORD_VOICE_CALL is needed when calling createAudioCapturer with this type. 9296 * @syscap SystemCapability.Multimedia.Audio.Core 9297 * @systemapi 9298 * @since 11 9299 */ 9300 SOURCE_TYPE_VOICE_CALL = 4, 9301 9302 /** 9303 * Voice communication source type. 9304 * @syscap SystemCapability.Multimedia.Audio.Core 9305 * @since 8 9306 */ 9307 /** 9308 * Voice communication source type. 9309 * @syscap SystemCapability.Multimedia.Audio.Core 9310 * @crossplatform 9311 * @since 12 9312 */ 9313 SOURCE_TYPE_VOICE_COMMUNICATION = 7, 9314 9315 /** 9316 * Voice message source type. 9317 * @syscap SystemCapability.Multimedia.Audio.Core 9318 * @since 12 9319 */ 9320 SOURCE_TYPE_VOICE_MESSAGE = 10, 9321 9322 /** 9323 * Source type for voice transcription and processing. 9324 * @syscap SystemCapability.Multimedia.Audio.Core 9325 * @systemapi 9326 * @since 18 9327 */ 9328 SOURCE_TYPE_VOICE_TRANSCRIPTION = 12, 9329 9330 /** 9331 * Camcorder source type. 9332 * @syscap SystemCapability.Multimedia.Audio.Core 9333 * @since 13 9334 */ 9335 SOURCE_TYPE_CAMCORDER = 13, 9336 9337 /** 9338 * Unprocessed source type. 9339 * @syscap SystemCapability.Multimedia.Audio.Core 9340 * @since 14 9341 */ 9342 SOURCE_TYPE_UNPROCESSED = 14, 9343 /** 9344 * Live broadcast source type. 9345 * @syscap SystemCapability.Multimedia.Audio.Core 9346 * @since 20 9347 */ 9348 SOURCE_TYPE_LIVE = 17 9349 } 9350 9351 /** 9352 * Describes audio capturer information. 9353 * @typedef AudioCapturerInfo 9354 * @syscap SystemCapability.Multimedia.Audio.Core 9355 * @since 8 9356 */ 9357 /** 9358 * Describes audio capturer information. 9359 * @typedef AudioCapturerInfo 9360 * @syscap SystemCapability.Multimedia.Audio.Core 9361 * @crossplatform 9362 * @since 12 9363 */ 9364 interface AudioCapturerInfo { 9365 /** 9366 * Audio source type. 9367 * @type { SourceType } 9368 * @syscap SystemCapability.Multimedia.Audio.Core 9369 * @since 8 9370 */ 9371 /** 9372 * Audio source type. 9373 * @type { SourceType } 9374 * @syscap SystemCapability.Multimedia.Audio.Core 9375 * @crossplatform 9376 * @since 12 9377 */ 9378 source: SourceType; 9379 /** 9380 * Audio capturer flags. 9381 * @type { number } 9382 * @syscap SystemCapability.Multimedia.Audio.Core 9383 * @since 8 9384 */ 9385 /** 9386 * Audio capturer flags. 9387 * @type { number } 9388 * @syscap SystemCapability.Multimedia.Audio.Core 9389 * @crossplatform 9390 * @since 12 9391 */ 9392 capturerFlags: number; 9393 } 9394 9395 /** 9396 * Describes audio capturer configuration options. 9397 * @typedef AudioCapturerOptions 9398 * @syscap SystemCapability.Multimedia.Audio.Capturer 9399 * @since 8 9400 */ 9401 /** 9402 * Describes audio capturer configuration options. 9403 * @typedef AudioCapturerOptions 9404 * @syscap SystemCapability.Multimedia.Audio.Capturer 9405 * @crossplatform 9406 * @since 12 9407 */ 9408 interface AudioCapturerOptions { 9409 /** 9410 * Stream information. 9411 * @type { AudioStreamInfo } 9412 * @syscap SystemCapability.Multimedia.Audio.Capturer 9413 * @since 8 9414 */ 9415 /** 9416 * Stream information. 9417 * @type { AudioStreamInfo } 9418 * @syscap SystemCapability.Multimedia.Audio.Capturer 9419 * @crossplatform 9420 * @since 12 9421 */ 9422 streamInfo: AudioStreamInfo; 9423 /** 9424 * Capturer information. 9425 * @type { AudioCapturerInfo } 9426 * @syscap SystemCapability.Multimedia.Audio.Capturer 9427 * @since 8 9428 */ 9429 /** 9430 * Capturer information. 9431 * @type { AudioCapturerInfo } 9432 * @syscap SystemCapability.Multimedia.Audio.Capturer 9433 * @crossplatform 9434 * @since 12 9435 */ 9436 capturerInfo: AudioCapturerInfo; 9437 /** 9438 * Playback capture config. 9439 * @type { ?AudioPlaybackCaptureConfig } 9440 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 9441 * @since 10 9442 * @deprecated since 12 9443 * @useinstead OH_AVScreenCapture in native interface. 9444 */ 9445 playbackCaptureConfig?: AudioPlaybackCaptureConfig; 9446 } 9447 9448 /** 9449 * Describe playback capture filtering options 9450 * @typedef CaptureFilterOptions 9451 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 9452 * @since 10 9453 * @deprecated since 12 9454 * @useinstead OH_AVScreenCapture in native interface. 9455 */ 9456 interface CaptureFilterOptions { 9457 /** 9458 * Filter by stream usages. If you want to capture voice streams, additional permission is needed. 9459 * @type { Array<StreamUsage> } 9460 * @permission ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO 9461 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 9462 * @since 10 9463 */ 9464 /** 9465 * Filter by stream usages. But not allow to capture voice streams. 9466 * @type { Array<StreamUsage> } 9467 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 9468 * @since 11 9469 * @deprecated since 12 9470 * @useinstead OH_AVScreenCapture in native interface. 9471 */ 9472 usages: Array<StreamUsage>; 9473 } 9474 9475 /** 9476 * Describe playback capture config object. 9477 * @typedef AudioPlaybackCaptureConfig 9478 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 9479 * @since 10 9480 * @deprecated since 12 9481 * @useinstead OH_AVScreenCapture in native interface. 9482 */ 9483 interface AudioPlaybackCaptureConfig { 9484 /** 9485 * Add filter options to decide which streams to be captured. 9486 * @type { CaptureFilterOptions } 9487 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 9488 * @since 10 9489 * @deprecated since 12 9490 * @useinstead OH_AVScreenCapture in native interface. 9491 */ 9492 filterOptions: CaptureFilterOptions; 9493 } 9494 9495 /** 9496 * Provides APIs for audio recording. 9497 * @typedef AudioCapturer 9498 * @syscap SystemCapability.Multimedia.Audio.Capturer 9499 * @since 8 9500 */ 9501 /** 9502 * Provides APIs for audio recording. 9503 * @typedef AudioCapturer 9504 * @syscap SystemCapability.Multimedia.Audio.Capturer 9505 * @crossplatform 9506 * @since 12 9507 */ 9508 interface AudioCapturer { 9509 /** 9510 * Defines the current capture state. 9511 * @type { AudioState } 9512 * @syscap SystemCapability.Multimedia.Audio.Capturer 9513 * @since 8 9514 */ 9515 /** 9516 * Defines the current capture state. 9517 * @type { AudioState } 9518 * @readonly 9519 * @syscap SystemCapability.Multimedia.Audio.Capturer 9520 * @crossplatform 9521 * @since 12 9522 */ 9523 readonly state: AudioState; 9524 9525 /** 9526 * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous 9527 * callback to return the result. 9528 * @param { AsyncCallback<AudioCapturerInfo> } callback - Callback used to return the capturer information. 9529 * @syscap SystemCapability.Multimedia.Audio.Capturer 9530 * @since 8 9531 */ 9532 /** 9533 * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous 9534 * callback to return the result. 9535 * @param { AsyncCallback<AudioCapturerInfo> } callback - Callback used to return the capturer information. 9536 * @syscap SystemCapability.Multimedia.Audio.Capturer 9537 * @crossplatform 9538 * @since 12 9539 */ 9540 getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo>): void; 9541 /** 9542 * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to 9543 * return the result. 9544 * @returns { Promise<AudioCapturerInfo> } Promise used to return the capturer information. 9545 * @syscap SystemCapability.Multimedia.Audio.Capturer 9546 * @since 8 9547 */ 9548 /** 9549 * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to 9550 * return the result. 9551 * @returns { Promise<AudioCapturerInfo> } Promise used to return the capturer information. 9552 * @syscap SystemCapability.Multimedia.Audio.Capturer 9553 * @crossplatform 9554 * @since 12 9555 */ 9556 getCapturerInfo(): Promise<AudioCapturerInfo>; 9557 /** 9558 * Obtains the capturer information provided while creating a capturer instance. 9559 * @returns { AudioCapturerInfo } The capturer information. 9560 * @syscap SystemCapability.Multimedia.Audio.Capturer 9561 * @since 10 9562 */ 9563 /** 9564 * Obtains the capturer information provided while creating a capturer instance. 9565 * @returns { AudioCapturerInfo } The capturer information. 9566 * @syscap SystemCapability.Multimedia.Audio.Capturer 9567 * @crossplatform 9568 * @since 12 9569 */ 9570 getCapturerInfoSync(): AudioCapturerInfo; 9571 9572 /** 9573 * Obtains the capturer stream information. This method uses an asynchronous callback to return the result. 9574 * @param { AsyncCallback<AudioStreamInfo> } callback - Callback used to return the stream information. 9575 * @syscap SystemCapability.Multimedia.Audio.Capturer 9576 * @since 8 9577 */ 9578 /** 9579 * Obtains the capturer stream information. This method uses an asynchronous callback to return the result. 9580 * @param { AsyncCallback<AudioStreamInfo> } callback - Callback used to return the stream information. 9581 * @syscap SystemCapability.Multimedia.Audio.Capturer 9582 * @crossplatform 9583 * @since 12 9584 */ 9585 getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void; 9586 /** 9587 * Obtains the capturer stream information. This method uses a promise to return the result. 9588 * @returns { Promise<AudioStreamInfo> } Promise used to return the stream information. 9589 * @syscap SystemCapability.Multimedia.Audio.Capturer 9590 * @since 8 9591 */ 9592 /** 9593 * Obtains the capturer stream information. This method uses a promise to return the result. 9594 * @returns { Promise<AudioStreamInfo> } Promise used to return the stream information. 9595 * @syscap SystemCapability.Multimedia.Audio.Capturer 9596 * @crossplatform 9597 * @since 12 9598 */ 9599 getStreamInfo(): Promise<AudioStreamInfo>; 9600 /** 9601 * Obtains the capturer stream information. 9602 * @returns { AudioStreamInfo } The stream information. 9603 * @syscap SystemCapability.Multimedia.Audio.Capturer 9604 * @since 10 9605 */ 9606 /** 9607 * Obtains the capturer stream information. 9608 * @returns { AudioStreamInfo } The stream information. 9609 * @syscap SystemCapability.Multimedia.Audio.Capturer 9610 * @crossplatform 9611 * @since 12 9612 */ 9613 getStreamInfoSync(): AudioStreamInfo; 9614 9615 /** 9616 * Obtains the capturer stream id. This method uses an asynchronous callback to return the result. 9617 * @param { AsyncCallback<number> } callback - Callback used to return the stream id. 9618 * @syscap SystemCapability.Multimedia.Audio.Capturer 9619 * @since 9 9620 */ 9621 /** 9622 * Obtains the capturer stream id. This method uses an asynchronous callback to return the result. 9623 * @param { AsyncCallback<number> } callback - Callback used to return the stream id. 9624 * @syscap SystemCapability.Multimedia.Audio.Capturer 9625 * @crossplatform 9626 * @since 12 9627 */ 9628 getAudioStreamId(callback: AsyncCallback<number>): void; 9629 /** 9630 * Obtains the capturer stream id. This method uses a promise to return the result. 9631 * @returns { Promise<number> } Promise used to return the stream id. 9632 * @syscap SystemCapability.Multimedia.Audio.Capturer 9633 * @since 9 9634 */ 9635 /** 9636 * Obtains the capturer stream id. This method uses a promise to return the result. 9637 * @returns { Promise<number> } Promise used to return the stream id. 9638 * @syscap SystemCapability.Multimedia.Audio.Capturer 9639 * @crossplatform 9640 * @since 12 9641 */ 9642 getAudioStreamId(): Promise<number>; 9643 /** 9644 * Obtains the capturer stream id. 9645 * @returns { number } The stream id. 9646 * @syscap SystemCapability.Multimedia.Audio.Capturer 9647 * @since 10 9648 */ 9649 /** 9650 * Obtains the capturer stream id. 9651 * @returns { number } The stream id. 9652 * @syscap SystemCapability.Multimedia.Audio.Capturer 9653 * @crossplatform 9654 * @since 12 9655 */ 9656 getAudioStreamIdSync(): number; 9657 9658 /** 9659 * Starts capturing. 9660 * Success: This method uses an asynchronous callback to return the result. 9661 * Failure: This method uses an asynchronous callback to return the error instance. Possible causes: 9662 * 6800301: Unsupported state, Audio focus request failed, System error. 9663 * @param { AsyncCallback<void> } callback - Callback used to return the result. 9664 * @syscap SystemCapability.Multimedia.Audio.Capturer 9665 * @since 8 9666 */ 9667 /** 9668 * Starts capturing. This method uses an asynchronous callback to return the result. 9669 * @param { AsyncCallback<void> } callback - Callback used to return the result. 9670 * @syscap SystemCapability.Multimedia.Audio.Capturer 9671 * @crossplatform 9672 * @since 12 9673 */ 9674 start(callback: AsyncCallback<void>): void; 9675 /** 9676 * Starts capturing. 9677 * Success: This method uses a promise to return the result. 9678 * Failure: This method uses a promise to return the error instance. Possible causes: 9679 * 6800301: Unsupported state, Audio focus request failed, System error. 9680 * @returns { Promise<void> } Promise used to return the result. 9681 * @syscap SystemCapability.Multimedia.Audio.Capturer 9682 * @since 8 9683 */ 9684 /** 9685 * Starts capturing. This method uses a promise to return the result. 9686 * @returns { Promise<void> } Promise used to return the result. 9687 * @syscap SystemCapability.Multimedia.Audio.Capturer 9688 * @crossplatform 9689 * @since 12 9690 */ 9691 start(): Promise<void>; 9692 9693 /** 9694 * Reads the buffer from the audio capturer. This method uses an asynchronous callback to return the result. 9695 * @param { number } size - Number of bytes to read. 9696 * @param { boolean } isBlockingRead - Whether the read operation should be blocked. 9697 * @param { AsyncCallback<ArrayBuffer> } callback - Callback used to return the buffer. 9698 * @syscap SystemCapability.Multimedia.Audio.Capturer 9699 * @since 8 9700 * @deprecated since 11 9701 * @useinstead ohos.multimedia.audio.AudioCapturer#event:readData 9702 */ 9703 read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer>): void; 9704 /** 9705 * Reads the buffer from the audio capturer. This method uses a promise to return the result. 9706 * @param { number } size - Number of bytes to read. 9707 * @param { boolean } isBlockingRead - Whether the read operation should be blocked. 9708 * @returns { Promise<ArrayBuffer> } Returns the buffer data read if the operation is successful. 9709 * Returns an error code otherwise. 9710 * @syscap SystemCapability.Multimedia.Audio.Capturer 9711 * @since 8 9712 * @deprecated since 11 9713 * @useinstead ohos.multimedia.audio.AudioCapturer#event:readData 9714 */ 9715 read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer>; 9716 9717 /** 9718 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an 9719 * asynchronous callback to return the result. 9720 * @param { AsyncCallback<number> } callback - Callback used to return the timestamp. 9721 * @syscap SystemCapability.Multimedia.Audio.Capturer 9722 * @since 8 9723 */ 9724 /** 9725 * Obtains the timestamp for audio frame that passed by system framework most recently. 9726 * The timestamp is not accurate because audio device latency is not considered very thoughtfully. 9727 * This method uses an asynchronous callback to return the result. 9728 * @param { AsyncCallback<number> } callback - Callback used to return the audio timestamp based on the monotonic nanosecond system timer. 9729 * @syscap SystemCapability.Multimedia.Audio.Capturer 9730 * @crossplatform 9731 * @since 12 9732 */ 9733 getAudioTime(callback: AsyncCallback<number>): void; 9734 /** 9735 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a 9736 * promise to return the result. 9737 * @returns { Promise<number> } Promise used to return the timestamp. 9738 * @syscap SystemCapability.Multimedia.Audio.Capturer 9739 * @since 8 9740 */ 9741 /** 9742 * Obtains the timestamp for audio frame that passed by system framework most recently. 9743 * The timestamp is not accurate because audio device latency is not considered very thoughtfully. 9744 * This method uses a promise to return the result. 9745 * @returns { Promise<number> } Promise used to return the audio timestamp based on the monotonic nanosecond system timer. 9746 * @syscap SystemCapability.Multimedia.Audio.Capturer 9747 * @crossplatform 9748 * @since 12 9749 */ 9750 getAudioTime(): Promise<number>; 9751 /** 9752 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. 9753 * @returns { number } The audio timestamp. 9754 * @syscap SystemCapability.Multimedia.Audio.Capturer 9755 * @since 10 9756 */ 9757 /** 9758 * Obtains the timestamp for audio frame that passed by system framework most recently. 9759 * The timestamp is not accurate because audio device latency is not considered very thoughtfully. 9760 * @returns { number } The audio timestamp based on the monotonic nanosecond system timer. 9761 * @syscap SystemCapability.Multimedia.Audio.Capturer 9762 * @crossplatform 9763 * @since 12 9764 */ 9765 getAudioTimeSync(): number; 9766 9767 /** 9768 * Obtains the timestamp info. 9769 * 9770 * @returns { Promise<AudioTimestampInfo> } The Promise used to return timestamp info. 9771 * @throws { BusinessError } 6800103 - Operation not permit at current state. 9772 * @syscap SystemCapability.Multimedia.Audio.Capturer 9773 * @since 19 9774 */ 9775 getAudioTimestampInfo(): Promise<AudioTimestampInfo>; 9776 9777 /** 9778 * Obtains the timestamp info. 9779 * 9780 * @returns { AudioTimestampInfo } The returned timestamp info. 9781 * @throws { BusinessError } 6800103 - Operation not permit at current state. 9782 * @syscap SystemCapability.Multimedia.Audio.Capturer 9783 * @since 19 9784 */ 9785 getAudioTimestampInfoSync(): AudioTimestampInfo; 9786 9787 /** 9788 * Stops capturing. This method uses an asynchronous callback to return the result. 9789 * @param { AsyncCallback<void> } callback - Callback used to return the result. 9790 * @syscap SystemCapability.Multimedia.Audio.Capturer 9791 * @since 8 9792 */ 9793 /** 9794 * Stops capturing. This method uses an asynchronous callback to return the result. 9795 * @param { AsyncCallback<void> } callback - Callback used to return the result. 9796 * @syscap SystemCapability.Multimedia.Audio.Capturer 9797 * @crossplatform 9798 * @since 12 9799 */ 9800 stop(callback: AsyncCallback<void>): void; 9801 /** 9802 * Stops capturing. This method uses a promise to return the result. 9803 * @returns { Promise<void> } Promise used to return the result. 9804 * @syscap SystemCapability.Multimedia.Audio.Capturer 9805 * @since 8 9806 */ 9807 /** 9808 * Stops capturing. This method uses a promise to return the result. 9809 * @returns { Promise<void> } Promise used to return the result. 9810 * @syscap SystemCapability.Multimedia.Audio.Capturer 9811 * @crossplatform 9812 * @since 12 9813 */ 9814 stop(): Promise<void>; 9815 9816 /** 9817 * Releases the capturer. This method uses an asynchronous callback to return the result. 9818 * @param { AsyncCallback<void> } callback - Callback used to return the result. 9819 * @syscap SystemCapability.Multimedia.Audio.Capturer 9820 * @since 8 9821 */ 9822 /** 9823 * Releases the capturer. This method uses an asynchronous callback to return the result. 9824 * @param { AsyncCallback<void> } callback - Callback used to return the result. 9825 * @syscap SystemCapability.Multimedia.Audio.Capturer 9826 * @crossplatform 9827 * @since 12 9828 */ 9829 release(callback: AsyncCallback<void>): void; 9830 /** 9831 * Releases the capturer. This method uses a promise to return the result. 9832 * @returns { Promise<void> } - Promise used to return the result. 9833 * @syscap SystemCapability.Multimedia.Audio.Capturer 9834 * @since 8 9835 */ 9836 /** 9837 * Releases the capturer. This method uses a promise to return the result. 9838 * @returns { Promise<void> } - Promise used to return the result. 9839 * @syscap SystemCapability.Multimedia.Audio.Capturer 9840 * @crossplatform 9841 * @since 12 9842 */ 9843 release(): Promise<void>; 9844 9845 /** 9846 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to 9847 * return the result. 9848 * @param { AsyncCallback<number> } callback - Callback used to return the buffer size. 9849 * @syscap SystemCapability.Multimedia.Audio.Capturer 9850 * @since 8 9851 */ 9852 /** 9853 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to 9854 * return the result. 9855 * @param { AsyncCallback<number> } callback - Callback used to return the buffer size. 9856 * @syscap SystemCapability.Multimedia.Audio.Capturer 9857 * @crossplatform 9858 * @since 12 9859 */ 9860 getBufferSize(callback: AsyncCallback<number>): void; 9861 /** 9862 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result. 9863 * @returns { Promise<number> } Promise used to return the buffer size. 9864 * @syscap SystemCapability.Multimedia.Audio.Capturer 9865 * @since 8 9866 */ 9867 /** 9868 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result. 9869 * @returns { Promise<number> } Promise used to return the buffer size. 9870 * @syscap SystemCapability.Multimedia.Audio.Capturer 9871 * @crossplatform 9872 * @since 12 9873 */ 9874 getBufferSize(): Promise<number>; 9875 /** 9876 * Obtains a reasonable minimum buffer size in bytes for capturing. 9877 * @returns { number } Promise used to return the buffer size. 9878 * @syscap SystemCapability.Multimedia.Audio.Capturer 9879 * @since 10 9880 */ 9881 /** 9882 * Obtains a reasonable minimum buffer size in bytes for capturing. 9883 * @returns { number } Promise used to return the buffer size. 9884 * @syscap SystemCapability.Multimedia.Audio.Capturer 9885 * @crossplatform 9886 * @since 12 9887 */ 9888 getBufferSizeSync(): number; 9889 9890 /** 9891 * Gets the input device or devices for this stream. 9892 * @returns { AudioDeviceDescriptors } Descriptors of input devices. 9893 * @syscap SystemCapability.Multimedia.Audio.Device 9894 * @since 11 9895 */ 9896 /** 9897 * Gets the input device or devices for this stream. 9898 * @returns { AudioDeviceDescriptors } Descriptors of input devices. 9899 * @syscap SystemCapability.Multimedia.Audio.Device 9900 * @crossplatform 9901 * @since 12 9902 */ 9903 getCurrentInputDevices(): AudioDeviceDescriptors; 9904 9905 /** 9906 * Gets full capturer info for this stream. 9907 * @returns { AudioCapturerChangeInfo } Full capture info. 9908 * @syscap SystemCapability.Multimedia.Audio.Device 9909 * @since 11 9910 */ 9911 /** 9912 * Gets full capturer info for this stream. 9913 * @returns { AudioCapturerChangeInfo } Full capture info. 9914 * @syscap SystemCapability.Multimedia.Audio.Device 9915 * @crossplatform 9916 * @since 12 9917 */ 9918 getCurrentAudioCapturerChangeInfo(): AudioCapturerChangeInfo; 9919 9920 /** 9921 * Gets overflow count. 9922 * @returns { Promise<number> } - Promise used to return the result. 9923 * @syscap SystemCapability.Multimedia.Audio.Capturer 9924 * @since 12 9925 */ 9926 getOverflowCount(): Promise<number> 9927 9928 /** 9929 * Gets overflow count. 9930 * @returns { number } Overflow count number. 9931 * @syscap SystemCapability.Multimedia.Audio.Capturer 9932 * @since 12 9933 */ 9934 getOverflowCountSync(): number; 9935 9936 /** 9937 * Set if capturer want to be muted instead of interrupted, should be set before start. 9938 * @param { boolean } muteWhenInterrupted - use {@code true} if application want its stream to be muted 9939 * instead of interrupted. 9940 * @returns { Promise<void> } Promise used to return the result. 9941 * @throws { BusinessError } 6800103 - Operation not permitted at current state. 9942 * @syscap SystemCapability.Multimedia.Audio.Capturer 9943 * @since 20 9944 */ 9945 setWillMuteWhenInterrupted(muteWhenInterrupted: boolean): Promise<void>; 9946 9947 /** 9948 * Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter, 9949 * the callback is invoked. 9950 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 9951 * @param { number } frame - Number of frames to trigger the event. The value must be greater than 0. 9952 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 9953 * @syscap SystemCapability.Multimedia.Audio.Capturer 9954 * @since 8 9955 */ 9956 /** 9957 * Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter, 9958 * the callback is invoked. 9959 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 9960 * @param { number } frame - Number of frames to trigger the event. The value must be greater than 0. 9961 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 9962 * @syscap SystemCapability.Multimedia.Audio.Capturer 9963 * @crossplatform 9964 * @since 12 9965 */ 9966 on(type: 'markReach', frame: number, callback: Callback<number>): void; 9967 /** 9968 * Unsubscribes from the mark reached events. 9969 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 9970 * @syscap SystemCapability.Multimedia.Audio.Capturer 9971 * @since 8 9972 */ 9973 /** 9974 * Unsubscribes from the mark reached events. 9975 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 9976 * @syscap SystemCapability.Multimedia.Audio.Capturer 9977 * @crossplatform 9978 * @since 12 9979 */ 9980 /** 9981 * Unsubscribes from the mark reached events. 9982 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 9983 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 9984 * @syscap SystemCapability.Multimedia.Audio.Capturer 9985 * @crossplatform 9986 * @since 18 9987 */ 9988 off(type: 'markReach', callback?: Callback<number>): void; 9989 9990 /** 9991 * Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter, 9992 * the callback is invoked. 9993 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 9994 * @param { number } frame - Period during which frame capturing is listened. The value must be greater than 0. 9995 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 9996 * @syscap SystemCapability.Multimedia.Audio.Capturer 9997 * @since 8 9998 */ 9999 /** 10000 * Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter, 10001 * the callback is invoked. 10002 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 10003 * @param { number } frame - Period during which frame capturing is listened. The value must be greater than 0. 10004 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 10005 * @syscap SystemCapability.Multimedia.Audio.Capturer 10006 * @crossplatform 10007 * @since 12 10008 */ 10009 on(type: 'periodReach', frame: number, callback: Callback<number>): void; 10010 /** 10011 * Unsubscribes from period reached events. 10012 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 10013 * @syscap SystemCapability.Multimedia.Audio.Capturer 10014 * @since 8 10015 */ 10016 /** 10017 * Unsubscribes from period reached events. 10018 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 10019 * @syscap SystemCapability.Multimedia.Audio.Capturer 10020 * @crossplatform 10021 * @since 12 10022 */ 10023 /** 10024 * Unsubscribes from period reached events. 10025 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 10026 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 10027 * @syscap SystemCapability.Multimedia.Audio.Capturer 10028 * @crossplatform 10029 * @since 18 10030 */ 10031 off(type: 'periodReach', callback?: Callback<number>): void; 10032 10033 /** 10034 * Subscribes audio state change event callback. 10035 * @param { 'stateChange' } type - Type of the event to listen for. Only the stateChange event is supported. 10036 * @param { Callback<AudioState> } callback - Callback used to listen for the audio state change event. 10037 * @syscap SystemCapability.Multimedia.Audio.Capturer 10038 * @since 8 10039 */ 10040 /** 10041 * Subscribes audio state change event callback. 10042 * @param { 'stateChange' } type - Type of the event to listen for. Only the stateChange event is supported. 10043 * @param { Callback<AudioState> } callback - Callback used to listen for the audio state change event. 10044 * @syscap SystemCapability.Multimedia.Audio.Capturer 10045 * @crossplatform 10046 * @since 12 10047 */ 10048 on(type: 'stateChange', callback: Callback<AudioState>): void; 10049 10050 /** 10051 * Unsubscribes audio state change event callback. 10052 * @param { 'stateChange' } type - Type of the event to listen for. 10053 * @param { Callback<AudioState> } callback - Callback used to listen for the audio state change event. 10054 * @throws { BusinessError } 6800101 - Parameter verification failed. 10055 * @syscap SystemCapability.Multimedia.Audio.Capturer 10056 * @since 18 10057 */ 10058 off(type: 'stateChange', callback?: Callback<AudioState>): void; 10059 10060 /** 10061 * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is 10062 * triggered when audio recording is interrupted. 10063 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 10064 * @param { Callback<InterruptEvent> } callback - Callback used to listen for interrupt callback. 10065 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10066 * 1.Mandatory parameters are left unspecified; 10067 * 2.Incorrect parameter types. 10068 * @throws { BusinessError } 6800101 - Parameter verification failed. 10069 * @syscap SystemCapability.Multimedia.Audio.Interrupt 10070 * @since 10 10071 */ 10072 /** 10073 * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is 10074 * triggered when audio recording is interrupted. 10075 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 10076 * @param { Callback<InterruptEvent> } callback - Callback used to listen for interrupt callback. 10077 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10078 * 1.Mandatory parameters are left unspecified; 10079 * 2.Incorrect parameter types. 10080 * @throws { BusinessError } 6800101 - Parameter verification failed. 10081 * @syscap SystemCapability.Multimedia.Audio.Interrupt 10082 * @crossplatform 10083 * @since 12 10084 */ 10085 on(type: 'audioInterrupt', callback: Callback<InterruptEvent>): void; 10086 10087 /** 10088 * UnSubscribes to audio interrupt events. 10089 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 10090 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10091 * 1.Mandatory parameters are left unspecified; 10092 * 2.Incorrect parameter types. 10093 * @throws { BusinessError } 6800101 - Parameter verification failed. 10094 * @syscap SystemCapability.Multimedia.Audio.Interrupt 10095 * @since 10 10096 */ 10097 /** 10098 * UnSubscribes to audio interrupt events. 10099 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 10100 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10101 * 1.Mandatory parameters are left unspecified; 10102 * 2.Incorrect parameter types. 10103 * @throws { BusinessError } 6800101 - Parameter verification failed. 10104 * @syscap SystemCapability.Multimedia.Audio.Interrupt 10105 * @crossplatform 10106 * @since 12 10107 */ 10108 off(type: 'audioInterrupt'): void; 10109 10110 /** 10111 * Subscribes input device change event callback. 10112 * The event is triggered when input device change for this stream. 10113 * @param { 'inputDeviceChange' } type - Type of the event to listen for. 10114 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to listen device change event. 10115 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10116 * 1.Mandatory parameters are left unspecified; 10117 * 2.Incorrect parameter types. 10118 * @throws { BusinessError } 6800101 - Parameter verification failed. 10119 * @syscap SystemCapability.Multimedia.Audio.Device 10120 * @since 11 10121 */ 10122 /** 10123 * Subscribes input device change event callback. 10124 * The event is triggered when input device change for this stream. 10125 * @param { 'inputDeviceChange' } type - Type of the event to listen for. 10126 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to listen device change event. 10127 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10128 * 1.Mandatory parameters are left unspecified; 10129 * 2.Incorrect parameter types. 10130 * @throws { BusinessError } 6800101 - Parameter verification failed. 10131 * @syscap SystemCapability.Multimedia.Audio.Device 10132 * @crossplatform 10133 * @since 12 10134 */ 10135 on(type: 'inputDeviceChange', callback: Callback<AudioDeviceDescriptors>): void; 10136 /** 10137 * Unsubscribes input device change event callback. 10138 * @param { 'inputDeviceChange' } type - Type of the event to listen for. 10139 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used in subscribe. 10140 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10141 * 1.Mandatory parameters are left unspecified; 10142 * 2.Incorrect parameter types. 10143 * @throws { BusinessError } 6800101 - Parameter verification failed. 10144 * @syscap SystemCapability.Multimedia.Audio.Device 10145 * @since 11 10146 */ 10147 /** 10148 * Unsubscribes input device change event callback. 10149 * @param { 'inputDeviceChange' } type - Type of the event to listen for. 10150 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used in subscribe. 10151 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10152 * 1.Mandatory parameters are left unspecified; 10153 * 2.Incorrect parameter types. 10154 * @throws { BusinessError } 6800101 - Parameter verification failed. 10155 * @syscap SystemCapability.Multimedia.Audio.Device 10156 * @crossplatform 10157 * @since 12 10158 */ 10159 off(type: 'inputDeviceChange', callback?: Callback<AudioDeviceDescriptors>): void; 10160 10161 /** 10162 * Subscribes audio capturer info change event callback. 10163 * The event is triggered when input device change for this stream. 10164 * @param { 'audioCapturerChange' } type - Type of the event to listen for. 10165 * @param { Callback<AudioCapturerChangeInfo> } callback - Callback used to listen device change event. 10166 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10167 * 1.Mandatory parameters are left unspecified; 10168 * 2.Incorrect parameter types. 10169 * @throws { BusinessError } 6800101 - Parameter verification failed. 10170 * @syscap SystemCapability.Multimedia.Audio.Capturer 10171 * @since 11 10172 */ 10173 /** 10174 * Subscribes audio capturer info change event callback. 10175 * The event is triggered when input device change for this stream. 10176 * @param { 'audioCapturerChange' } type - Type of the event to listen for. 10177 * @param { Callback<AudioCapturerChangeInfo> } callback - Callback used to listen device change event. 10178 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10179 * 1.Mandatory parameters are left unspecified; 10180 * 2.Incorrect parameter types. 10181 * @throws { BusinessError } 6800101 - Parameter verification failed. 10182 * @syscap SystemCapability.Multimedia.Audio.Capturer 10183 * @crossplatform 10184 * @since 12 10185 */ 10186 on(type: 'audioCapturerChange', callback: Callback<AudioCapturerChangeInfo>): void; 10187 /** 10188 * Unsubscribes audio capturer info change event callback. 10189 * @param { 'audioCapturerChange' } type - Type of the event to listen for. 10190 * @param { Callback<AudioCapturerChangeInfo> } callback - Callback used in subscribe. 10191 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10192 * 1.Mandatory parameters are left unspecified; 10193 * 2.Incorrect parameter types. 10194 * @throws { BusinessError } 6800101 - Parameter verification failed. 10195 * @syscap SystemCapability.Multimedia.Audio.Capturer 10196 * @since 11 10197 */ 10198 /** 10199 * Unsubscribes audio capturer info change event callback. 10200 * @param { 'audioCapturerChange' } type - Type of the event to listen for. 10201 * @param { Callback<AudioCapturerChangeInfo> } callback - Callback used in subscribe. 10202 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10203 * 1.Mandatory parameters are left unspecified; 10204 * 2.Incorrect parameter types. 10205 * @throws { BusinessError } 6800101 - Parameter verification failed. 10206 * @syscap SystemCapability.Multimedia.Audio.Capturer 10207 * @crossplatform 10208 * @since 12 10209 */ 10210 off(type: 'audioCapturerChange', callback?: Callback<AudioCapturerChangeInfo>): void; 10211 10212 /** 10213 * Subscribes audio data callback. 10214 * The event is triggered when audio buffer is available for reading more data. 10215 * @param { 'readData' } type - Type of the event to listen for. 10216 * @param { Callback<ArrayBuffer> } callback - Callback with the buffer to read. 10217 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10218 * 1.Mandatory parameters are left unspecified; 10219 * 2.Incorrect parameter types. 10220 * @throws { BusinessError } 6800101 - Parameter verification failed. 10221 * @syscap SystemCapability.Multimedia.Audio.Capturer 10222 * @since 11 10223 */ 10224 /** 10225 * Subscribes audio data callback. 10226 * The event is triggered when audio buffer is available for reading more data. 10227 * @param { 'readData' } type - Type of the event to listen for. 10228 * @param { Callback<ArrayBuffer> } callback - Callback with the buffer to read. 10229 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10230 * 1.Mandatory parameters are left unspecified; 10231 * 2.Incorrect parameter types. 10232 * @throws { BusinessError } 6800101 - Parameter verification failed. 10233 * @syscap SystemCapability.Multimedia.Audio.Capturer 10234 * @crossplatform 10235 * @since 12 10236 */ 10237 on(type: 'readData', callback: Callback<ArrayBuffer>): void; 10238 10239 /** 10240 * Unsubscribes audio data callback. 10241 * @param { 'readData' } type - Type of the event to listen for. 10242 * @param { Callback<ArrayBuffer> } callback - Callback used in subscribe. 10243 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10244 * 1.Mandatory parameters are left unspecified; 10245 * 2.Incorrect parameter types. 10246 * @throws { BusinessError } 6800101 - Parameter verification failed. 10247 * @syscap SystemCapability.Multimedia.Audio.Capturer 10248 * @since 11 10249 */ 10250 /** 10251 * Unsubscribes audio data callback. 10252 * @param { 'readData' } type - Type of the event to listen for. 10253 * @param { Callback<ArrayBuffer> } callback - Callback used in subscribe. 10254 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10255 * 1.Mandatory parameters are left unspecified; 10256 * 2.Incorrect parameter types. 10257 * @throws { BusinessError } 6800101 - Parameter verification failed. 10258 * @syscap SystemCapability.Multimedia.Audio.Capturer 10259 * @crossplatform 10260 * @since 12 10261 */ 10262 off(type: 'readData', callback?: Callback<ArrayBuffer>): void; 10263 10264 /** 10265 * Sets default input device of this Capturer to DEVICE_TYPE_ACCESSORY. 10266 * Other capturers' devices will not be affected by this method. 10267 * This method can only be used before the capture stream starts. Besides, 10268 * if audio accessory is not connected, this method will report fail. After 10269 * calling this function, the input device of this capturer will not be affected 10270 * by other interfaces. 10271 * @throws { BusinessError } 202 - Caller is not a system application. 10272 * @throws { BusinessError } 6800103 - Operation not permit at current state. 10273 * @syscap SystemCapability.Multimedia.Audio.Capturer 10274 * @systemapi 10275 * @since 19 10276 */ 10277 setInputDeviceToAccessory(): void; 10278 } 10279 10280 /** 10281 * ASR noise suppression mode. 10282 * @enum { number } 10283 * @syscap SystemCapability.Multimedia.Audio.Capturer 10284 * @systemapi 10285 * @since 12 10286 */ 10287 enum AsrNoiseSuppressionMode { 10288 /** 10289 * Bypass noise suppression. 10290 * @syscap SystemCapability.Multimedia.Audio.Capturer 10291 * @systemapi 10292 * @since 12 10293 */ 10294 BYPASS = 0, 10295 /** 10296 * Standard noise suppression. 10297 * @syscap SystemCapability.Multimedia.Audio.Capturer 10298 * @systemapi 10299 * @since 12 10300 */ 10301 STANDARD = 1, 10302 /** 10303 * Near field noise suppression. 10304 * @syscap SystemCapability.Multimedia.Audio.Capturer 10305 * @systemapi 10306 * @since 12 10307 */ 10308 NEAR_FIELD = 2, 10309 /** 10310 * Far field noise suppression. 10311 * @syscap SystemCapability.Multimedia.Audio.Capturer 10312 * @systemapi 10313 * @since 12 10314 */ 10315 FAR_FIELD = 3, 10316 } 10317 10318 /** 10319 * ASR AEC mode. 10320 * @enum { number } 10321 * @syscap SystemCapability.Multimedia.Audio.Capturer 10322 * @systemapi 10323 * @since 12 10324 */ 10325 enum AsrAecMode { 10326 /** 10327 * Bypass AEC. 10328 * @syscap SystemCapability.Multimedia.Audio.Capturer 10329 * @systemapi 10330 * @since 12 10331 */ 10332 BYPASS = 0, 10333 /** 10334 * Using standard AEC. 10335 * @syscap SystemCapability.Multimedia.Audio.Capturer 10336 * @systemapi 10337 * @since 12 10338 */ 10339 STANDARD = 1, 10340 } 10341 10342 /** 10343 * ASR voice control mode. 10344 * @enum { number } 10345 * @syscap SystemCapability.Multimedia.Audio.Capturer 10346 * @systemapi 10347 * @since 12 10348 */ 10349 enum AsrVoiceControlMode { 10350 /** 10351 * Send output stream to TX. 10352 * @syscap SystemCapability.Multimedia.Audio.Capturer 10353 * @systemapi 10354 * @since 12 10355 */ 10356 AUDIO_2_VOICE_TX = 0, 10357 /** 10358 * Send both output stream and MIC input to TX. 10359 * @syscap SystemCapability.Multimedia.Audio.Capturer 10360 * @systemapi 10361 * @since 12 10362 */ 10363 AUDIO_MIX_2_VOICE_TX = 1, 10364 /** 10365 * Based on the AUDIO_2_VOICE_TX, Send output stream to voice call record. 10366 * @syscap SystemCapability.Multimedia.Audio.Capturer 10367 * @systemapi 10368 * @since 12 10369 */ 10370 AUDIO_2_VOICE_TX_EX = 2, 10371 /** 10372 * Based on the AUDIO_MIX_2_VOICE_TX, Send output stream to voice call record. 10373 * @syscap SystemCapability.Multimedia.Audio.Capturer 10374 * @systemapi 10375 * @since 12 10376 */ 10377 AUDIO_MIX_2_VOICE_TX_EX = 3, 10378 } 10379 10380 /** 10381 * ASR voice mute mode. 10382 * @enum { number } 10383 * @syscap SystemCapability.Multimedia.Audio.Capturer 10384 * @systemapi 10385 * @since 12 10386 */ 10387 enum AsrVoiceMuteMode { 10388 /** 10389 * Mute the local output stream. 10390 * @syscap SystemCapability.Multimedia.Audio.Capturer 10391 * @systemapi 10392 * @since 12 10393 */ 10394 OUTPUT_MUTE = 0, 10395 /** 10396 * Mute the local MIC input stream. 10397 * @syscap SystemCapability.Multimedia.Audio.Capturer 10398 * @systemapi 10399 * @since 12 10400 */ 10401 INPUT_MUTE = 1, 10402 /** 10403 * Send tts output stream to TX and mute the local output stream. 10404 * @syscap SystemCapability.Multimedia.Audio.Capturer 10405 * @systemapi 10406 * @since 12 10407 */ 10408 TTS_MUTE = 2, 10409 /** 10410 * Mute the voice call stream. 10411 * @syscap SystemCapability.Multimedia.Audio.Capturer 10412 * @systemapi 10413 * @since 12 10414 */ 10415 CALL_MUTE = 3, 10416 /** 10417 * Based on the OUTPUT_MUTE, send output stream to voice call record. 10418 * @syscap SystemCapability.Multimedia.Audio.Capturer 10419 * @systemapi 10420 * @since 12 10421 */ 10422 OUTPUT_MUTE_EX = 4, 10423 } 10424 10425 /** 10426 * ASR whisper detection mode. 10427 * @enum { number } 10428 * @syscap SystemCapability.Multimedia.Audio.Capturer 10429 * @systemapi 10430 * @since 12 10431 */ 10432 enum AsrWhisperDetectionMode { 10433 /** 10434 * No operation. 10435 * @syscap SystemCapability.Multimedia.Audio.Capturer 10436 * @systemapi 10437 * @since 12 10438 */ 10439 BYPASS = 0, 10440 /** 10441 * Use standard whisper detection model. 10442 * @syscap SystemCapability.Multimedia.Audio.Capturer 10443 * @systemapi 10444 * @since 12 10445 */ 10446 STANDARD = 1, 10447 } 10448 10449 /** 10450 * ASR processing controller. 10451 * @typedef AsrProcessingController 10452 * @syscap SystemCapability.Multimedia.Audio.Capturer 10453 * @systemapi 10454 * @since 12 10455 */ 10456 interface AsrProcessingController { 10457 /** 10458 * Set ASR AEC mode. 10459 * @param { AsrAecMode } mode - ASR AEC Mode. 10460 * @returns { boolean } Indicates whether the mode has been successfully set. 10461 * @throws { BusinessError } 202 - Caller is not a system application. 10462 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10463 * 1.Mandatory parameters are left unspecified; 10464 * 2.Incorrect parameter types. 10465 * @throws { BusinessError } 6800101 - Parameter verification failed. 10466 * @throws { BusinessError } 6800104 - Operation not allowed. 10467 * @syscap SystemCapability.Multimedia.Audio.Capturer 10468 * @systemapi 10469 * @since 12 10470 */ 10471 setAsrAecMode(mode: AsrAecMode): boolean; 10472 10473 /** 10474 * Get ASR AEC mode. 10475 * @returns { AsrAecMode } ASR AEC Mode. 10476 * @throws { BusinessError } 202 - Caller is not a system application. 10477 * @throws { BusinessError } 6800104 - Operation not allowed. 10478 * @syscap SystemCapability.Multimedia.Audio.Capturer 10479 * @systemapi 10480 * @since 12 10481 */ 10482 getAsrAecMode(): AsrAecMode; 10483 10484 /** 10485 * Set ASR noise suppression mode. 10486 * @param { AsrNoiseSuppressionMode } mode - ASR noise suppression mode. 10487 * @returns { boolean } Indicates whether the mode has been successfully set. 10488 * @throws { BusinessError } 202 - Caller is not a system application. 10489 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10490 * 1.Mandatory parameters are left unspecified; 10491 * 2.Incorrect parameter types. 10492 * @throws { BusinessError } 6800101 - Parameter verification failed. 10493 * @throws { BusinessError } 6800104 - Operation not allowed. 10494 * @syscap SystemCapability.Multimedia.Audio.Capturer 10495 * @systemapi 10496 * @since 12 10497 */ 10498 setAsrNoiseSuppressionMode(mode: AsrNoiseSuppressionMode): boolean; 10499 10500 /** 10501 * Get ASR noise suppression mode. 10502 * @returns { AsrNoiseSuppressionMode } ASR noise suppression mode. 10503 * @throws { BusinessError } 202 - Caller is not a system application. 10504 * @throws { BusinessError } 6800104 - Operation not allowed. 10505 * @syscap SystemCapability.Multimedia.Audio.Capturer 10506 * @systemapi 10507 * @since 12 10508 */ 10509 getAsrNoiseSuppressionMode(): AsrNoiseSuppressionMode; 10510 10511 /** 10512 * Query whether user is whispering. 10513 * @returns { boolean } whether user is whispering. 10514 * @throws { BusinessError } 202 - Caller is not a system application. 10515 * @throws { BusinessError } 6800104 - Operation not allowed. 10516 * @syscap SystemCapability.Multimedia.Audio.Capturer 10517 * @systemapi 10518 * @since 12 10519 */ 10520 isWhispering(): boolean; 10521 10522 /** 10523 * Set ASR voice control mode. 10524 * @param { AsrVoiceControlMode } mode - ASR voice control mode. 10525 * @param { boolean } enable - Indicates whether to switch on/off this mode. 10526 * @returns { boolean } Indicates whether the mode has been successfully set. 10527 * @throws { BusinessError } 202 - Caller is not a system application. 10528 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10529 * 1.Mandatory parameters unspecified. 10530 * 2.Incorrect parameter types. 10531 * @throws { BusinessError } 6800101 - Parameter verification failed. 10532 * @throws { BusinessError } 6800104 - Operation not allowed. 10533 * @syscap SystemCapability.Multimedia.Audio.Capturer 10534 * @systemapi 10535 * @since 12 10536 */ 10537 setAsrVoiceControlMode(mode: AsrVoiceControlMode, enable: boolean): boolean; 10538 10539 /** 10540 * Set ASR voice mute mode. 10541 * @param { AsrVoiceMuteMode } mode - ASR voice mute mode. 10542 * @param { boolean } enable - Indicates whether to switch on/off this mode. 10543 * @returns { boolean } Indicates whether the mode has been successfully set. 10544 * @throws { BusinessError } 202 - Caller is not a system application. 10545 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10546 * 1.Mandatory parameters unspecified. 10547 * 2.Incorrect parameter types. 10548 * @throws { BusinessError } 6800101 - Parameter verification failed. 10549 * @throws { BusinessError } 6800104 - Operation not allowed. 10550 * @syscap SystemCapability.Multimedia.Audio.Capturer 10551 * @systemapi 10552 * @since 12 10553 */ 10554 setAsrVoiceMuteMode(mode: AsrVoiceMuteMode, enable: boolean): boolean; 10555 10556 /** 10557 * Set ASR whisper detection mode. 10558 * @param { AsrWhisperDetectionMode } mode - ASR whisper detection mode. 10559 * @returns { boolean } Indicates whether the mode has been successfully set. 10560 * @throws { BusinessError } 202 - Caller is not a system application. 10561 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10562 * 1.Mandatory parameters unspecified. 10563 * 2.Incorrect parameter types. 10564 * @throws { BusinessError } 6800101 - Parameter verification failed. 10565 * @throws { BusinessError } 6800104 - Operation not allowed. 10566 * @syscap SystemCapability.Multimedia.Audio.Capturer 10567 * @systemapi 10568 * @since 12 10569 */ 10570 setAsrWhisperDetectionMode(mode: AsrWhisperDetectionMode): boolean; 10571 10572 /** 10573 * Get ASR whisper detection mode. 10574 * @returns { AsrWhisperDetectionMode } ASR whisper detection mode. 10575 * @throws { BusinessError } 202 - Caller is not a system application. 10576 * @throws { BusinessError } 6800104 - Operation not allowed. 10577 * @syscap SystemCapability.Multimedia.Audio.Capturer 10578 * @systemapi 10579 * @since 12 10580 */ 10581 getAsrWhisperDetectionMode(): AsrWhisperDetectionMode; 10582 } 10583 10584 /** 10585 * Create ASR processing controller on one audio capturer. 10586 * @param { AudioCapturer } audioCapturer - The audio capturer whose ASR processing will be controlled. The source 10587 * type of this capturer must be {@link SourceType#SOURCE_TYPE_VOICE_RECOGNITION}. 10588 * @returns { AsrProcessingController } ASR Processing Controller. 10589 * @throws { BusinessError } 202 - Caller is not a system application. 10590 * @throws { BusinessError } 401 - Parameter error. Possible causes: 10591 * 1.Mandatory parameters are left unspecified; 10592 * 2.Incorrect parameter types. 10593 * @throws { BusinessError } 6800101 - Parameter verification failed. 10594 * @throws { BusinessError } 6800104 - Operation not allowed. e.g. the source type of the input audio capturer is not 10595 * {@link SourceType#SOURCE_TYPE_VOICE_RECOGNITION} or {@link SourceType#SOURCE_TYPE_WAKEUP}, or this audio capturer 10596 * is already released. 10597 * @syscap SystemCapability.Multimedia.Audio.Capturer 10598 * @systemapi 10599 * @since 12 10600 */ 10601 function createAsrProcessingController(audioCapturer: AudioCapturer): AsrProcessingController; 10602 10603 /** 10604 * Enumerates tone types for player. 10605 * @enum { number } 10606 * @syscap SystemCapability.Multimedia.Audio.Tone 10607 * @systemapi 10608 * @since 9 10609 */ 10610 enum ToneType { 10611 /** 10612 * Dial tone for key 0. 10613 * @syscap SystemCapability.Multimedia.Audio.Tone 10614 * @systemapi 10615 * @since 9 10616 */ 10617 TONE_TYPE_DIAL_0 = 0, 10618 /** 10619 * Dial tone for key 1. 10620 * @syscap SystemCapability.Multimedia.Audio.Tone 10621 * @systemapi 10622 * @since 9 10623 */ 10624 TONE_TYPE_DIAL_1 = 1, 10625 /** 10626 * Dial tone for key 2. 10627 * @syscap SystemCapability.Multimedia.Audio.Tone 10628 * @systemapi 10629 * @since 9 10630 */ 10631 TONE_TYPE_DIAL_2 = 2, 10632 /** 10633 * Dial tone for key 3. 10634 * @syscap SystemCapability.Multimedia.Audio.Tone 10635 * @systemapi 10636 * @since 9 10637 */ 10638 TONE_TYPE_DIAL_3 = 3, 10639 /** 10640 * Dial tone for key 4. 10641 * @syscap SystemCapability.Multimedia.Audio.Tone 10642 * @systemapi 10643 * @since 9 10644 */ 10645 TONE_TYPE_DIAL_4 = 4, 10646 /** 10647 * Dial tone for key 5. 10648 * @syscap SystemCapability.Multimedia.Audio.Tone 10649 * @systemapi 10650 * @since 9 10651 */ 10652 TONE_TYPE_DIAL_5 = 5, 10653 /** 10654 * Dial tone for key 6. 10655 * @syscap SystemCapability.Multimedia.Audio.Tone 10656 * @systemapi 10657 * @since 9 10658 */ 10659 TONE_TYPE_DIAL_6 = 6, 10660 /** 10661 * Dial tone for key 7. 10662 * @syscap SystemCapability.Multimedia.Audio.Tone 10663 * @systemapi 10664 * @since 9 10665 */ 10666 TONE_TYPE_DIAL_7 = 7, 10667 /** 10668 * Dial tone for key 8. 10669 * @syscap SystemCapability.Multimedia.Audio.Tone 10670 * @systemapi 10671 * @since 9 10672 */ 10673 TONE_TYPE_DIAL_8 = 8, 10674 /** 10675 * Dial tone for key 9. 10676 * @syscap SystemCapability.Multimedia.Audio.Tone 10677 * @systemapi 10678 * @since 9 10679 */ 10680 TONE_TYPE_DIAL_9 = 9, 10681 /** 10682 * Dial tone for key *. 10683 * @syscap SystemCapability.Multimedia.Audio.Tone 10684 * @systemapi 10685 * @since 9 10686 */ 10687 TONE_TYPE_DIAL_S = 10, 10688 /** 10689 * Dial tone for key #. 10690 * @syscap SystemCapability.Multimedia.Audio.Tone 10691 * @systemapi 10692 * @since 9 10693 */ 10694 TONE_TYPE_DIAL_P = 11, 10695 /** 10696 * Dial tone for key A. 10697 * @syscap SystemCapability.Multimedia.Audio.Tone 10698 * @systemapi 10699 * @since 9 10700 */ 10701 TONE_TYPE_DIAL_A = 12, 10702 /** 10703 * Dial tone for key B. 10704 * @syscap SystemCapability.Multimedia.Audio.Tone 10705 * @systemapi 10706 * @since 9 10707 */ 10708 TONE_TYPE_DIAL_B = 13, 10709 /** 10710 * Dial tone for key C. 10711 * @syscap SystemCapability.Multimedia.Audio.Tone 10712 * @systemapi 10713 * @since 9 10714 */ 10715 TONE_TYPE_DIAL_C = 14, 10716 /** 10717 * Dial tone for key D. 10718 * @syscap SystemCapability.Multimedia.Audio.Tone 10719 * @systemapi 10720 * @since 9 10721 */ 10722 TONE_TYPE_DIAL_D = 15, 10723 /** 10724 * Supervisory tone for dial. 10725 * @syscap SystemCapability.Multimedia.Audio.Tone 10726 * @systemapi 10727 * @since 9 10728 */ 10729 TONE_TYPE_COMMON_SUPERVISORY_DIAL = 100, 10730 /** 10731 * Supervisory tone for busy. 10732 * @syscap SystemCapability.Multimedia.Audio.Tone 10733 * @systemapi 10734 * @since 9 10735 */ 10736 TONE_TYPE_COMMON_SUPERVISORY_BUSY = 101, 10737 /** 10738 * Supervisory tone for dial. 10739 * @syscap SystemCapability.Multimedia.Audio.Tone 10740 * @systemapi 10741 * @since 9 10742 */ 10743 TONE_TYPE_COMMON_SUPERVISORY_CONGESTION = 102, 10744 /** 10745 * Supervisory tone for radio path acknowledgment. 10746 * @syscap SystemCapability.Multimedia.Audio.Tone 10747 * @systemapi 10748 * @since 9 10749 */ 10750 TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK = 103, 10751 /** 10752 * Supervisory tone for radio path not available. 10753 * @syscap SystemCapability.Multimedia.Audio.Tone 10754 * @systemapi 10755 * @since 9 10756 */ 10757 TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE = 104, 10758 /** 10759 * Supervisory tone for call waiting. 10760 * @syscap SystemCapability.Multimedia.Audio.Tone 10761 * @systemapi 10762 * @since 9 10763 */ 10764 TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING = 106, 10765 /** 10766 * Supervisory tone for ringtone. 10767 * @syscap SystemCapability.Multimedia.Audio.Tone 10768 * @systemapi 10769 * @since 9 10770 */ 10771 TONE_TYPE_COMMON_SUPERVISORY_RINGTONE = 107, 10772 /** 10773 * Supervisory tone for call holding. 10774 * @syscap SystemCapability.Multimedia.Audio.Tone 10775 * @systemapi 10776 * @since 18 10777 */ 10778 TONE_TYPE_COMMON_SUPERVISORY_CALL_HOLDING = 108, 10779 /** 10780 * Proprietary tone for beep. 10781 * @syscap SystemCapability.Multimedia.Audio.Tone 10782 * @systemapi 10783 * @since 9 10784 */ 10785 TONE_TYPE_COMMON_PROPRIETARY_BEEP = 200, 10786 /** 10787 * Proprietary tone for positive acknowledgment. 10788 * @syscap SystemCapability.Multimedia.Audio.Tone 10789 * @systemapi 10790 * @since 9 10791 */ 10792 TONE_TYPE_COMMON_PROPRIETARY_ACK = 201, 10793 /** 10794 * Proprietary tone for prompt. 10795 * @syscap SystemCapability.Multimedia.Audio.Tone 10796 * @systemapi 10797 * @since 9 10798 */ 10799 TONE_TYPE_COMMON_PROPRIETARY_PROMPT = 203, 10800 /** 10801 * Proprietary tone for double beep. 10802 * @syscap SystemCapability.Multimedia.Audio.Tone 10803 * @systemapi 10804 * @since 9 10805 */ 10806 TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP = 204, 10807 } 10808 10809 /** 10810 * Provides APIs for tone playing. 10811 * @typedef TonePlayer 10812 * @syscap SystemCapability.Multimedia.Audio.Tone 10813 * @systemapi 10814 * @since 9 10815 */ 10816 interface TonePlayer { 10817 /** 10818 * Loads tone. This method uses an asynchronous callback to return the result. 10819 * @param { ToneType } type - Tone type to play. 10820 * @param { AsyncCallback<void> } callback - Callback used to return the result. 10821 * @syscap SystemCapability.Multimedia.Audio.Tone 10822 * @systemapi 10823 * @since 9 10824 */ 10825 load(type: ToneType, callback: AsyncCallback<void>): void; 10826 /** 10827 * Loads tone. This method uses a promise to return the result. 10828 * @param { ToneType } type - Tone type to play. 10829 * @returns { Promise<void> } Promise used to return the result. 10830 * @syscap SystemCapability.Multimedia.Audio.Tone 10831 * @systemapi 10832 * @since 9 10833 */ 10834 load(type: ToneType): Promise<void>; 10835 10836 /** 10837 * Starts player. This method uses an asynchronous callback to return the result. 10838 * @param { AsyncCallback<void> } callback - Callback used to return the result. 10839 * @syscap SystemCapability.Multimedia.Audio.Tone 10840 * @systemapi 10841 * @since 9 10842 */ 10843 start(callback: AsyncCallback<void>): void; 10844 /** 10845 * Starts player. This method uses a promise to return the result. 10846 * @returns { Promise<void> }Promise used to return the result. 10847 * @syscap SystemCapability.Multimedia.Audio.Tone 10848 * @systemapi 10849 * @since 9 10850 */ 10851 start(): Promise<void>; 10852 10853 /** 10854 * Stops player. This method uses an asynchronous callback to return the result. 10855 * @param { AsyncCallback<void> } callback - Callback used to return the result. 10856 * @syscap SystemCapability.Multimedia.Audio.Tone 10857 * @systemapi 10858 * @since 9 10859 */ 10860 stop(callback: AsyncCallback<void>): void; 10861 /** 10862 * Stops player. This method uses a promise to return the result. 10863 * @returns { Promise<void> } Promise used to return the result. 10864 * @syscap SystemCapability.Multimedia.Audio.Tone 10865 * @systemapi 10866 * @since 9 10867 */ 10868 stop(): Promise<void>; 10869 10870 /** 10871 * Releases the player. This method uses an asynchronous callback to return the result. 10872 * @param { AsyncCallback<void> } callback - Callback used to return the result. 10873 * @syscap SystemCapability.Multimedia.Audio.Tone 10874 * @systemapi 10875 * @since 9 10876 */ 10877 release(callback: AsyncCallback<void>): void; 10878 /** 10879 * Releases the player. This method uses a promise to return the result. 10880 * @returns { Promise<void> } Promise used to return the result. 10881 * @syscap SystemCapability.Multimedia.Audio.Tone 10882 * @systemapi 10883 * @since 9 10884 */ 10885 release(): Promise<void>; 10886 } 10887 10888 /** 10889 * Array of AudioEffectMode, which is read-only. 10890 * @typedef { Array<Readonly<AudioEffectMode>> } AudioEffectInfoArray 10891 * @syscap SystemCapability.Multimedia.Audio.Renderer 10892 * @since 10 10893 */ 10894 type AudioEffectInfoArray = Array<Readonly<AudioEffectMode>>; 10895 10896 /** 10897 * Describes an audio effect mode group. 10898 * @enum { number } 10899 * @syscap SystemCapability.Multimedia.Audio.Renderer 10900 * @since 10 10901 */ 10902 /** 10903 * Describes an audio effect mode group. 10904 * @enum { number } 10905 * @syscap SystemCapability.Multimedia.Audio.Renderer 10906 * @atomicservice 10907 * @since 12 10908 */ 10909 enum AudioEffectMode { 10910 /** 10911 * Audio Effect Mode effect none. 10912 * @syscap SystemCapability.Multimedia.Audio.Renderer 10913 * @since 10 10914 */ 10915 /** 10916 * Audio Effect Mode effect none. This effect mode will disable audio effect process for current audio renderer. 10917 * @syscap SystemCapability.Multimedia.Audio.Renderer 10918 * @atomicservice 10919 * @since 12 10920 */ 10921 EFFECT_NONE = 0, 10922 /** 10923 * Audio Effect Mode effect default. 10924 * @syscap SystemCapability.Multimedia.Audio.Renderer 10925 * @since 10 10926 */ 10927 /** 10928 * Audio Effect Mode effect default. 10929 * @syscap SystemCapability.Multimedia.Audio.Renderer 10930 * @atomicservice 10931 * @since 12 10932 */ 10933 EFFECT_DEFAULT = 1, 10934 } 10935 10936 /** 10937 * Describes spatial device state. 10938 * @typedef AudioSpatialDeviceState 10939 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10940 * @systemapi 10941 * @since 11 10942 */ 10943 interface AudioSpatialDeviceState { 10944 /** 10945 * Spatial device address. 10946 * @type { string } 10947 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10948 * @systemapi 10949 * @since 11 10950 */ 10951 address: string; 10952 10953 /** 10954 * Whether the spatial device supports spatial rendering. 10955 * @type { boolean } 10956 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10957 * @systemapi 10958 * @since 11 10959 */ 10960 isSpatializationSupported: boolean; 10961 10962 /** 10963 * Whether the spatial device supports head tracking. 10964 * @type { boolean } 10965 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10966 * @systemapi 10967 * @since 11 10968 */ 10969 isHeadTrackingSupported: boolean; 10970 10971 /** 10972 * Spatial device type. 10973 * @type { AudioSpatialDeviceType } 10974 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10975 * @systemapi 10976 * @since 11 10977 */ 10978 spatialDeviceType: AudioSpatialDeviceType; 10979 } 10980 10981 /** 10982 * Describes a spatial device type group. 10983 * @enum { number } 10984 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10985 * @systemapi 10986 * @since 11 10987 */ 10988 enum AudioSpatialDeviceType { 10989 /** 10990 * Audio Spatial Device Type none. 10991 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10992 * @systemapi 10993 * @since 11 10994 */ 10995 SPATIAL_DEVICE_TYPE_NONE = 0, 10996 /** 10997 * Audio Spatial Device Type in-ear headphone. 10998 * @syscap SystemCapability.Multimedia.Audio.Spatialization 10999 * @systemapi 11000 * @since 11 11001 */ 11002 SPATIAL_DEVICE_TYPE_IN_EAR_HEADPHONE = 1, 11003 /** 11004 * Audio Spatial Device Type half-in-ear headphone. 11005 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11006 * @systemapi 11007 * @since 11 11008 */ 11009 SPATIAL_DEVICE_TYPE_HALF_IN_EAR_HEADPHONE = 2, 11010 /** 11011 * Audio Spatial Device Type over-ear headphone. 11012 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11013 * @systemapi 11014 * @since 11 11015 */ 11016 SPATIAL_DEVICE_TYPE_OVER_EAR_HEADPHONE = 3, 11017 /** 11018 * Audio Spatial Device Type glasses. 11019 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11020 * @systemapi 11021 * @since 11 11022 */ 11023 SPATIAL_DEVICE_TYPE_GLASSES = 4, 11024 /** 11025 * Audio Spatial Device Type others. 11026 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11027 * @systemapi 11028 * @since 11 11029 */ 11030 SPATIAL_DEVICE_TYPE_OTHERS = 5, 11031 } 11032 11033 /** 11034 * Describes a spatialization scene type group. 11035 * @enum { number } 11036 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11037 * @systemapi 11038 * @since 12 11039 */ 11040 enum AudioSpatializationSceneType { 11041 /** 11042 * Audio Spatialization Scene Type Default. 11043 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11044 * @systemapi 11045 * @since 12 11046 */ 11047 DEFAULT = 0, 11048 /** 11049 * Audio Spatialization Scene Type Music. 11050 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11051 * @systemapi 11052 * @since 12 11053 */ 11054 MUSIC = 1, 11055 /** 11056 * Audio Spatialization Scene Type Movie. 11057 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11058 * @systemapi 11059 * @since 12 11060 */ 11061 MOVIE = 2, 11062 /** 11063 * Audio Spatialization Scene Type Audio Book. 11064 * @syscap SystemCapability.Multimedia.Audio.Spatialization 11065 * @systemapi 11066 * @since 12 11067 */ 11068 AUDIOBOOK = 3, 11069 } 11070 11071 /** 11072 * Audio AudioChannel Layout 11073 * A 64-bit integer indicates that the appearance and order of the speakers for recording or playback. 11074 * @enum { number } 11075 * @syscap SystemCapability.Multimedia.Audio.Core 11076 * @since 11 11077 */ 11078 /** 11079 * Audio AudioChannel Layout 11080 * A 64-bit integer indicates that the appearance and order of the speakers for recording or playback. 11081 * @enum { number } 11082 * @syscap SystemCapability.Multimedia.Audio.Core 11083 * @crossplatform 11084 * @since 12 11085 */ 11086 enum AudioChannelLayout { 11087 /** 11088 * Unknown Channel Layout 11089 * @syscap SystemCapability.Multimedia.Audio.Core 11090 * @since 11 11091 */ 11092 /** 11093 * Unknown Channel Layout 11094 * @syscap SystemCapability.Multimedia.Audio.Core 11095 * @crossplatform 11096 * @since 12 11097 */ 11098 CH_LAYOUT_UNKNOWN = 0x0, 11099 /** 11100 * Channel Layout For Mono, 1 channel in total 11101 * Speaker layout: front center(FC) 11102 * @syscap SystemCapability.Multimedia.Audio.Core 11103 * @since 11 11104 */ 11105 /** 11106 * Channel Layout For Mono, 1 channel in total 11107 * Speaker layout: front center(FC) 11108 * @syscap SystemCapability.Multimedia.Audio.Core 11109 * @crossplatform 11110 * @since 12 11111 */ 11112 CH_LAYOUT_MONO = 0x4, 11113 /** 11114 * Channel Layout For Stereo, 2 channels in total 11115 * Speaker layout: front left(FL), front right(FR) 11116 * @syscap SystemCapability.Multimedia.Audio.Core 11117 * @since 11 11118 */ 11119 /** 11120 * Channel Layout For Stereo, 2 channels in total 11121 * Speaker layout: front left(FL), front right(FR) 11122 * @syscap SystemCapability.Multimedia.Audio.Core 11123 * @crossplatform 11124 * @since 12 11125 */ 11126 CH_LAYOUT_STEREO = 0x3, 11127 /** 11128 * Channel Layout For Stereo-Downmix, 2 channels in total 11129 * Speaker layout: Stereo left, stereo right 11130 * @syscap SystemCapability.Multimedia.Audio.Core 11131 * @since 11 11132 */ 11133 CH_LAYOUT_STEREO_DOWNMIX = 0x60000000, 11134 /** 11135 * Channel Layout For 2.1, 3 channels in total 11136 * Speaker layout: Stereo plus low-frequency effects(LFE) 11137 * @syscap SystemCapability.Multimedia.Audio.Core 11138 * @since 11 11139 */ 11140 /** 11141 * Channel Layout For 2.1, 3 channels in total 11142 * Speaker layout: Stereo plus low-frequency effects(LFE) 11143 * @syscap SystemCapability.Multimedia.Audio.Core 11144 * @crossplatform 11145 * @since 12 11146 */ 11147 CH_LAYOUT_2POINT1 = 0xB, 11148 /** 11149 * Channel Layout For 3.0, 3 channels in total 11150 * Speaker layout: Stereo plus back center(BC) 11151 * @syscap SystemCapability.Multimedia.Audio.Core 11152 * @since 11 11153 */ 11154 /** 11155 * Channel Layout For 3.0, 3 channels in total 11156 * Speaker layout: Stereo plus back center(BC) 11157 * @syscap SystemCapability.Multimedia.Audio.Core 11158 * @crossplatform 11159 * @since 12 11160 */ 11161 CH_LAYOUT_3POINT0 = 0x103, 11162 /** 11163 * Channel Layout For Surround, 3 channels in total 11164 * Speaker layout: Stereo plus FC 11165 * @syscap SystemCapability.Multimedia.Audio.Core 11166 * @since 11 11167 */ 11168 /** 11169 * Channel Layout For Surround, 3 channels in total 11170 * Speaker layout: Stereo plus FC 11171 * @syscap SystemCapability.Multimedia.Audio.Core 11172 * @crossplatform 11173 * @since 12 11174 */ 11175 CH_LAYOUT_SURROUND = 0x7, 11176 /** 11177 * Channel Layout For 3.1, 4 channels in total 11178 * Speaker layout: Surround plus LFE 11179 * @syscap SystemCapability.Multimedia.Audio.Core 11180 * @since 11 11181 */ 11182 /** 11183 * Channel Layout For 3.1, 4 channels in total 11184 * Speaker layout: Surround plus LFE 11185 * @syscap SystemCapability.Multimedia.Audio.Core 11186 * @crossplatform 11187 * @since 12 11188 */ 11189 CH_LAYOUT_3POINT1 = 0xF, 11190 /** 11191 * Channel Layout For 4.0, 4 channels in total 11192 * Speaker layout: Surround plus BC 11193 * @syscap SystemCapability.Multimedia.Audio.Core 11194 * @since 11 11195 */ 11196 /** 11197 * Channel Layout For 4.0, 4 channels in total 11198 * Speaker layout: Surround plus BC 11199 * @syscap SystemCapability.Multimedia.Audio.Core 11200 * @crossplatform 11201 * @since 12 11202 */ 11203 CH_LAYOUT_4POINT0 = 0x107, 11204 /** 11205 * Channel Layout For Quad, 4 channels in total 11206 * Speaker layout: Stereo plus left and right back speakers 11207 * @syscap SystemCapability.Multimedia.Audio.Core 11208 * @since 11 11209 */ 11210 /** 11211 * Channel Layout For Quad, 4 channels in total 11212 * Speaker layout: Stereo plus left and right back speakers 11213 * @syscap SystemCapability.Multimedia.Audio.Core 11214 * @crossplatform 11215 * @since 12 11216 */ 11217 CH_LAYOUT_QUAD = 0x33, 11218 /** 11219 * Channel Layout For Quad-Side, 4 channels in total 11220 * Speaker layout: Stereo plus left and right side speakers(SL, SR) 11221 * @syscap SystemCapability.Multimedia.Audio.Core 11222 * @since 11 11223 */ 11224 CH_LAYOUT_QUAD_SIDE = 0x603, 11225 /** 11226 * Channel Layout For 2.0.2, 4 channels in total 11227 * Speaker layout: Stereo plus left and right top side speakers 11228 * @syscap SystemCapability.Multimedia.Audio.Core 11229 * @since 11 11230 */ 11231 /** 11232 * Channel Layout For 2.0.2, 4 channels in total 11233 * Speaker layout: Stereo plus left and right top side speakers 11234 * @syscap SystemCapability.Multimedia.Audio.Core 11235 * @crossplatform 11236 * @since 12 11237 */ 11238 CH_LAYOUT_2POINT0POINT2 = 0x3000000003, 11239 /** 11240 * Channel Layout For ORDER1-ACN-N3D First Order Ambisonic(FOA), 4 channels in total 11241 * First order, Ambisonic Channel Number(ACN) format, Normalization of three-D(N3D) 11242 * @syscap SystemCapability.Multimedia.Audio.Core 11243 * @since 11 11244 */ 11245 CH_LAYOUT_AMB_ORDER1_ACN_N3D = 0x100000000001, 11246 /** 11247 * Channel Layout For ORDER1-ACN-SN3D FOA, 4 channels in total 11248 * First order, ACN format, Semi-Normalization of three-D(SN3D) 11249 * @syscap SystemCapability.Multimedia.Audio.Core 11250 * @since 11 11251 */ 11252 CH_LAYOUT_AMB_ORDER1_ACN_SN3D = 0x100000001001, 11253 /** 11254 * Channel Layout For ORDER1-FUMA FOA, 4 channels in total 11255 * First order, Furse-Malham(FuMa) format 11256 * @syscap SystemCapability.Multimedia.Audio.Core 11257 * @since 11 11258 */ 11259 CH_LAYOUT_AMB_ORDER1_FUMA = 0x100000000101, 11260 /** 11261 * Channel Layout For 4.1, 5 channels in total 11262 * Speaker layout: 4.0 plus LFE 11263 * @syscap SystemCapability.Multimedia.Audio.Core 11264 * @since 11 11265 */ 11266 /** 11267 * Channel Layout For 4.1, 5 channels in total 11268 * Speaker layout: 4.0 plus LFE 11269 * @syscap SystemCapability.Multimedia.Audio.Core 11270 * @crossplatform 11271 * @since 12 11272 */ 11273 CH_LAYOUT_4POINT1 = 0x10F, 11274 /** 11275 * Channel Layout For 5.0, 5 channels in total 11276 * Speaker layout: Surround plus two side speakers 11277 * @syscap SystemCapability.Multimedia.Audio.Core 11278 * @since 11 11279 */ 11280 /** 11281 * Channel Layout For 5.0, 5 channels in total 11282 * Speaker layout: Surround plus two side speakers 11283 * @syscap SystemCapability.Multimedia.Audio.Core 11284 * @crossplatform 11285 * @since 12 11286 */ 11287 CH_LAYOUT_5POINT0 = 0x607, 11288 /** 11289 * Channel Layout For 5.0-Back, 5 channels in total 11290 * Speaker layout: Surround plus two back speakers 11291 * @syscap SystemCapability.Multimedia.Audio.Core 11292 * @since 11 11293 */ 11294 CH_LAYOUT_5POINT0_BACK = 0x37, 11295 /** 11296 * Channel Layout For 2.1.2, 5 channels in total 11297 * Speaker layout: 2.0.2 plus LFE 11298 * @syscap SystemCapability.Multimedia.Audio.Core 11299 * @since 11 11300 */ 11301 CH_LAYOUT_2POINT1POINT2 = 0x300000000B, 11302 /** 11303 * Channel Layout For 3.0.2, 5 channels in total 11304 * Speaker layout: 2.0.2 plus FC 11305 * @syscap SystemCapability.Multimedia.Audio.Core 11306 * @since 11 11307 */ 11308 CH_LAYOUT_3POINT0POINT2 = 0x3000000007, 11309 /** 11310 * Channel Layout For 5.1, 6 channels in total 11311 * Speaker layout: 5.0 plus LFE 11312 * @syscap SystemCapability.Multimedia.Audio.Core 11313 * @since 11 11314 */ 11315 /** 11316 * Channel Layout For 5.1, 6 channels in total 11317 * Speaker layout: 5.0 plus LFE 11318 * @syscap SystemCapability.Multimedia.Audio.Core 11319 * @crossplatform 11320 * @since 12 11321 */ 11322 CH_LAYOUT_5POINT1 = 0x60F, 11323 /** 11324 * Channel Layout For 5.1-Back, 6 channels in total 11325 * Speaker layout: 5.0-Back plus LFE 11326 * @syscap SystemCapability.Multimedia.Audio.Core 11327 * @since 11 11328 */ 11329 CH_LAYOUT_5POINT1_BACK = 0x3F, 11330 /** 11331 * Channel Layout For 6.0, 6 channels in total 11332 * Speaker layout: 5.0 plus BC 11333 * @syscap SystemCapability.Multimedia.Audio.Core 11334 * @since 11 11335 */ 11336 /** 11337 * Channel Layout For 6.0, 6 channels in total 11338 * Speaker layout: 5.0 plus BC 11339 * @syscap SystemCapability.Multimedia.Audio.Core 11340 * @crossplatform 11341 * @since 12 11342 */ 11343 CH_LAYOUT_6POINT0 = 0x707, 11344 /** 11345 * Channel Layout For Hexagonal, 6 channels in total 11346 * Speaker layout: 5.0-Back plus BC 11347 * @syscap SystemCapability.Multimedia.Audio.Core 11348 * @since 11 11349 */ 11350 /** 11351 * Channel Layout For Hexagonal, 6 channels in total 11352 * Speaker layout: 5.0-Back plus BC 11353 * @syscap SystemCapability.Multimedia.Audio.Core 11354 * @crossplatform 11355 * @since 12 11356 */ 11357 CH_LAYOUT_HEXAGONAL = 0x137, 11358 /** 11359 * Channel Layout For 3.1.2, 6 channels in total 11360 * Speaker layout: 3.1 plus two top front speakers(TFL, TFR) 11361 * @syscap SystemCapability.Multimedia.Audio.Core 11362 * @since 11 11363 */ 11364 CH_LAYOUT_3POINT1POINT2 = 0x500F, 11365 /** 11366 * Channel Layout For 6.0-Front, 6 channels in total 11367 * Speaker layout: Quad-Side plus left and right front center speakers(FLC, FRC) 11368 * @syscap SystemCapability.Multimedia.Audio.Core 11369 * @since 11 11370 */ 11371 CH_LAYOUT_6POINT0_FRONT = 0x6C3, 11372 /** 11373 * Channel Layout For 6.1, 7 channels in total 11374 * Speaker layout: 5.1 plus BC 11375 * @syscap SystemCapability.Multimedia.Audio.Core 11376 * @since 11 11377 */ 11378 /** 11379 * Channel Layout For 6.1, 7 channels in total 11380 * Speaker layout: 5.1 plus BC 11381 * @syscap SystemCapability.Multimedia.Audio.Core 11382 * @crossplatform 11383 * @since 12 11384 */ 11385 CH_LAYOUT_6POINT1 = 0x70F, 11386 /** 11387 * Channel Layout For 6.1-Back, 7 channels in total 11388 * Speaker layout: 5.1-Back plus BC 11389 * @syscap SystemCapability.Multimedia.Audio.Core 11390 * @since 11 11391 */ 11392 CH_LAYOUT_6POINT1_BACK = 0x13F, 11393 /** 11394 * Channel Layout For 6.1-Front, 7 channels in total 11395 * Speaker layout: 6.0-Front plus LFE 11396 * @syscap SystemCapability.Multimedia.Audio.Core 11397 * @since 11 11398 */ 11399 CH_LAYOUT_6POINT1_FRONT = 0x6CB, 11400 /** 11401 * Channel Layout For 7.0, 7 channels in total 11402 * Speaker layout: 5.0 plus two back speakers 11403 * @syscap SystemCapability.Multimedia.Audio.Core 11404 * @since 11 11405 */ 11406 /** 11407 * Channel Layout For 7.0, 7 channels in total 11408 * Speaker layout: 5.0 plus two back speakers 11409 * @syscap SystemCapability.Multimedia.Audio.Core 11410 * @crossplatform 11411 * @since 12 11412 */ 11413 CH_LAYOUT_7POINT0 = 0x637, 11414 /** 11415 * Channel Layout For 7.0-Front, 7 channels in total 11416 * Speaker layout: 5.0 plus left and right front center speakers 11417 * @syscap SystemCapability.Multimedia.Audio.Core 11418 * @since 11 11419 */ 11420 /** 11421 * Channel Layout For 7.0-Front, 7 channels in total 11422 * Speaker layout: 5.0 plus left and right front center speakers 11423 * @syscap SystemCapability.Multimedia.Audio.Core 11424 * @crossplatform 11425 * @since 12 11426 */ 11427 CH_LAYOUT_7POINT0_FRONT = 0x6C7, 11428 /** 11429 * Channel Layout For 7.1, 8 channels in total 11430 * Speaker layout: 5.1 plus two back speakers 11431 * @syscap SystemCapability.Multimedia.Audio.Core 11432 * @since 11 11433 */ 11434 /** 11435 * Channel Layout For 7.1, 8 channels in total 11436 * Speaker layout: 5.1 plus two back speakers 11437 * @syscap SystemCapability.Multimedia.Audio.Core 11438 * @crossplatform 11439 * @since 12 11440 */ 11441 CH_LAYOUT_7POINT1 = 0x63F, 11442 /** 11443 * Channel Layout For Octagonal, 8 channels in total 11444 * Speaker layout: 5.0 plus BL, BR and BC. 11445 * @syscap SystemCapability.Multimedia.Audio.Core 11446 * @since 11 11447 */ 11448 /** 11449 * Channel Layout For Octagonal, 8 channels in total 11450 * Speaker layout: 5.0 plus BL, BR and BC. 11451 * @syscap SystemCapability.Multimedia.Audio.Core 11452 * @crossplatform 11453 * @since 12 11454 */ 11455 CH_LAYOUT_OCTAGONAL = 0x737, 11456 /** 11457 * Channel Layout For 5.1.2, 8 channels in total 11458 * Speaker layout: 5.1 plus two top side speakers. 11459 * @syscap SystemCapability.Multimedia.Audio.Core 11460 * @since 11 11461 */ 11462 /** 11463 * Channel Layout For 5.1.2, 8 channels in total 11464 * Speaker layout: 5.1 plus two top side speakers. 11465 * @syscap SystemCapability.Multimedia.Audio.Core 11466 * @crossplatform 11467 * @since 12 11468 */ 11469 CH_LAYOUT_5POINT1POINT2 = 0x300000060F, 11470 /** 11471 * Channel Layout For 7.1-Wide, 8 channels in total 11472 * Speaker layout: 5.1 plus left and right front center speakers. 11473 * @syscap SystemCapability.Multimedia.Audio.Core 11474 * @since 11 11475 */ 11476 CH_LAYOUT_7POINT1_WIDE = 0x6CF, 11477 /** 11478 * Channel Layout For 7.1-Wide, 8 channels in total 11479 * Speaker layout: 5.1-Back plus left and right front center speakers. 11480 * @syscap SystemCapability.Multimedia.Audio.Core 11481 * @since 11 11482 */ 11483 CH_LAYOUT_7POINT1_WIDE_BACK = 0xFF, 11484 /** 11485 * Channel Layout For ORDER2-ACN-N3D Higher Order Ambisonics(HOA), 9 channels in total 11486 * Second order, ACN format, N3D 11487 * @syscap SystemCapability.Multimedia.Audio.Core 11488 * @since 11 11489 */ 11490 CH_LAYOUT_AMB_ORDER2_ACN_N3D = 0x100000000002, 11491 /** 11492 * Channel Layout For ORDER2-ACN-SN3D HOA, 9 channels in total 11493 * Second order, ACN format, SN3D 11494 * @syscap SystemCapability.Multimedia.Audio.Core 11495 * @since 11 11496 */ 11497 CH_LAYOUT_AMB_ORDER2_ACN_SN3D = 0x100000001002, 11498 /** 11499 * Channel Layout For ORDER2-FUMA HOA, 9 channels in total 11500 * Second order, FuMa format 11501 * @syscap SystemCapability.Multimedia.Audio.Core 11502 * @since 11 11503 */ 11504 CH_LAYOUT_AMB_ORDER2_FUMA = 0x100000000102, 11505 /** 11506 * Channel Layout For 5.1.4, 10 channels in total 11507 * Speaker layout: 5.1 plus four top speakers(TFL, TFR, TBL, TBR) 11508 * @syscap SystemCapability.Multimedia.Audio.Core 11509 * @since 11 11510 */ 11511 /** 11512 * Channel Layout For 5.1.4, 10 channels in total 11513 * Speaker layout: 5.1 plus four top speakers(TFL, TFR, TBL, TBR) 11514 * @syscap SystemCapability.Multimedia.Audio.Core 11515 * @crossplatform 11516 * @since 12 11517 */ 11518 CH_LAYOUT_5POINT1POINT4 = 0x2D60F, 11519 /** 11520 * Channel Layout For 7.1.2, 10 channels in total 11521 * Speaker layout: 7.1 plus two top side speakers 11522 * @syscap SystemCapability.Multimedia.Audio.Core 11523 * @since 11 11524 */ 11525 /** 11526 * Channel Layout For 7.1.2, 10 channels in total 11527 * Speaker layout: 7.1 plus two top side speakers 11528 * @syscap SystemCapability.Multimedia.Audio.Core 11529 * @crossplatform 11530 * @since 12 11531 */ 11532 CH_LAYOUT_7POINT1POINT2 = 0x300000063F, 11533 /** 11534 * Channel Layout For 7.1.4, 12 channels in total 11535 * Speaker layout: 7.1 plus four top speakers 11536 * @syscap SystemCapability.Multimedia.Audio.Core 11537 * @since 11 11538 */ 11539 /** 11540 * Channel Layout For 7.1.4, 12 channels in total 11541 * Speaker layout: 7.1 plus four top speakers 11542 * @syscap SystemCapability.Multimedia.Audio.Core 11543 * @crossplatform 11544 * @since 12 11545 */ 11546 CH_LAYOUT_7POINT1POINT4 = 0x2D63F, 11547 /** 11548 * Channel Layout For 10.2, 12 channels in total 11549 * Speaker layout: FL, FR, FC, TFL, TFR, BL, BR, BC, SL, SR, wide left(WL), and wide right(WR) 11550 * @syscap SystemCapability.Multimedia.Audio.Core 11551 * @since 11 11552 */ 11553 /** 11554 * Channel Layout For 10.2, 12 channels in total 11555 * Speaker layout: FL, FR, FC, TFL, TFR, BL, BR, BC, SL, SR, wide left(WL), and wide right(WR) 11556 * @syscap SystemCapability.Multimedia.Audio.Core 11557 * @crossplatform 11558 * @since 12 11559 */ 11560 CH_LAYOUT_10POINT2 = 0x180005737, 11561 /** 11562 * Channel Layout For 9.1.4, 14 channels in total 11563 * Speaker layout: 7.1.4 plus two wide speakers(WL, WR) 11564 * @syscap SystemCapability.Multimedia.Audio.Core 11565 * @since 11 11566 */ 11567 CH_LAYOUT_9POINT1POINT4 = 0x18002D63F, 11568 /** 11569 * Channel Layout For 9.1.6, 16 channels in total 11570 * Speaker layout: 9.1.4 plus two top side speakers 11571 * @syscap SystemCapability.Multimedia.Audio.Core 11572 * @since 11 11573 */ 11574 /** 11575 * Channel Layout For 9.1.6, 16 channels in total 11576 * Speaker layout: 9.1.4 plus two top side speakers 11577 * @syscap SystemCapability.Multimedia.Audio.Core 11578 * @crossplatform 11579 * @since 12 11580 */ 11581 CH_LAYOUT_9POINT1POINT6 = 0x318002D63F, 11582 /** 11583 * Channel Layout For Hexadecagonal, 16 channels in total 11584 * Speaker layout: Octagonal plus two wide speakers, six top speakers(TFL, TFR, TFC, TBL, TBR, TBC) 11585 * @syscap SystemCapability.Multimedia.Audio.Core 11586 * @since 11 11587 */ 11588 /** 11589 * Channel Layout For Hexadecagonal, 16 channels in total 11590 * Speaker layout: Octagonal plus two wide speakers, six top speakers(TFL, TFR, TFC, TBL, TBR, TBC) 11591 * @syscap SystemCapability.Multimedia.Audio.Core 11592 * @crossplatform 11593 * @since 12 11594 */ 11595 CH_LAYOUT_HEXADECAGONAL = 0x18003F737, 11596 /** 11597 * Channel Layout For ORDER3-ACN-N3D HOA, 16 channels in total 11598 * Third order, ACN format, N3D 11599 * @syscap SystemCapability.Multimedia.Audio.Core 11600 * @since 11 11601 */ 11602 /** 11603 * Channel Layout For ORDER3-ACN-N3D HOA, 16 channels in total 11604 * Third order, ACN format, N3D 11605 * @syscap SystemCapability.Multimedia.Audio.Core 11606 * @crossplatform 11607 * @since 12 11608 */ 11609 CH_LAYOUT_AMB_ORDER3_ACN_N3D = 0x100000000003, 11610 /** 11611 * Channel Layout For ORDER3-ACN-SN3D HOA, 16 channels in total 11612 * Third order, ACN format, N3D 11613 * @syscap SystemCapability.Multimedia.Audio.Core 11614 * @since 11 11615 */ 11616 /** 11617 * Channel Layout For ORDER3-ACN-SN3D HOA, 16 channels in total 11618 * Third order, ACN format, N3D 11619 * @syscap SystemCapability.Multimedia.Audio.Core 11620 * @crossplatform 11621 * @since 12 11622 */ 11623 CH_LAYOUT_AMB_ORDER3_ACN_SN3D = 0x100000001003, 11624 /** 11625 * Channel Layout For ORDER3-FUMA HOA, 16 channels in total 11626 * Third order, FuMa format 11627 * @syscap SystemCapability.Multimedia.Audio.Core 11628 * @since 11 11629 */ 11630 CH_LAYOUT_AMB_ORDER3_FUMA = 0x100000000103 11631 } 11632 11633 /** 11634 * Enumerates audio effect flags. 11635 * @enum { number } 11636 * @syscap SystemCapability.Multimedia.Audio.Core 11637 * @systemapi 11638 * @since 18 11639 */ 11640 enum EffectFlag { 11641 /** 11642 * Audio render effect. 11643 * @syscap SystemCapability.Multimedia.Audio.Core 11644 * @systemapi 11645 * @since 18 11646 */ 11647 RENDER_EFFECT_FLAG = 0, 11648 11649 /** 11650 * Audio capture effect. 11651 * @syscap SystemCapability.Multimedia.Audio.Core 11652 * @systemapi 11653 * @since 18 11654 */ 11655 CAPTURE_EFFECT_FLAG = 1 11656 } 11657 11658 /** 11659 * Describes an audio effect property. 11660 * @typedef AudioEffectProperty 11661 * @syscap SystemCapability.Multimedia.Audio.Core 11662 * @systemapi 11663 * @since 18 11664 */ 11665 interface AudioEffectProperty { 11666 /** 11667 * Name of effect property. 11668 * @type { string } 11669 * @syscap SystemCapability.Multimedia.Audio.Core 11670 * @systemapi 11671 * @since 18 11672 */ 11673 name: string; 11674 11675 /** 11676 * Effect category this effect property belongs to. 11677 * @type { string } 11678 * @syscap SystemCapability.Multimedia.Audio.Core 11679 * @systemapi 11680 * @since 18 11681 */ 11682 category: string; 11683 11684 /** 11685 * Effect flag of this effect property. 11686 * @type { EffectFlag } 11687 * @syscap SystemCapability.Multimedia.Audio.Core 11688 * @systemapi 11689 * @since 18 11690 */ 11691 flag: EffectFlag; 11692 } 11693 11694 /** 11695 * Provides APIs for audio loopback. 11696 * When audio loopback is enabled, the system creates fast playback and recording streams to implement low-latency in-ear 11697 * monitoring. The recorded audio is directly routed back to the playback device internally. For the renderer, its audio 11698 * focus strategy matches that of {@link StreamUsage#STREAM_USAGE_MUSIC}. For the capturer, its audio focus strategy matches 11699 * that of {@link SourceType#SOURCE_TYPE_MIC}. The input and output devices are automatically selected by the system. 11700 * If the current input or output does not support low latency, audio loopback fails to be enabled. During operation, 11701 * if the audio focus is preempted by another audio stream or the input or output device switches to one that does not support 11702 * low latency, the system automatically disables audio loopback. 11703 * 11704 * @typedef AudioLoopback 11705 * @syscap SystemCapability.Multimedia.Audio.Capturer 11706 * @since 20 11707 */ 11708 interface AudioLoopback { 11709 /** 11710 * Obtains the status of audio loopback. 11711 * @returns { Promise<AudioLoopbackStatus> } Promise used to return the audio loopback status. 11712 * @syscap SystemCapability.Multimedia.Audio.Capturer 11713 * @since 20 11714 */ 11715 getStatus(): Promise<AudioLoopbackStatus>; 11716 11717 /** 11718 * Sets the volume for a audio loopback. This volume does not affect other audio streams or the system volume. 11719 * @param { number } volume - Volume to set. The value type is float, ranging form 0.0 to 1.0. 11720 * @returns { Promise<void> } Promise used to return the result. 11721 * @throws { BusinessError } 6800101 - Parameter verification failed, form 0.0 to 1.0. 11722 * @syscap SystemCapability.Multimedia.Audio.Capturer 11723 * @since 20 11724 */ 11725 setVolume(volume: number): Promise<void>; 11726 11727 /** 11728 * Subscribes to audio loopback status changes. 11729 * @param { 'statusChange' } type Type of the event to listen for. Only the statusChange event is supported. 11730 * @param { Callback<AudioLoopbackStatus> } callback Callback used to return the audio loopback status 11731 * change event. 11732 * @throws { BusinessError } 6800101 - Parameter verification failed. 11733 * @syscap SystemCapability.Multimedia.Audio.Capturer 11734 * @since 20 11735 */ 11736 on(type: 'statusChange', callback: Callback<AudioLoopbackStatus>): void; 11737 11738 /** 11739 * Unsubscribes audio loopback status change event callback. 11740 * @param { 'statusChange' } type - Type of the event to listen for. 11741 * @param { Callback<AudioLoopbackStatus> } callback - Callback used to listen for the audio loopback status 11742 * change event. 11743 * @throws { BusinessError } 6800101 - Parameter verification failed. 11744 * @syscap SystemCapability.Multimedia.Audio.Capturer 11745 * @since 20 11746 */ 11747 off(type: 'statusChange', callback?: Callback<AudioLoopbackStatus>): void; 11748 11749 /** 11750 * Enable or disable audio loopback. 11751 * When audio loopback is enabled, the system automatically creates fast playback and recording streams 11752 * to implement low-latency in-ear monitoring. When audio loopback is disabled, the audio stream is destroyed. 11753 * If enabling audio loopback fails, you can use {@link AudioLoopback#getStatus} to query the cause. After audio 11754 * loopback is enabled, you can subscribe to the statusChange event to listen for audio loopback status changes. 11755 * 11756 * @permission ohos.permission.MICROPHONE 11757 * @param { boolean } enable - Whether to enable or disable audio loopback. 11758 * @returns { Promise<boolean> } Promise used to return the result. 11759 * The value <b>true</b> means that audio loopback is enabled, and <b>false</b> means the opposite. 11760 * @throws { BusinessError } 201 - Permission denied. 11761 * @throws { BusinessError } 6800101 - Parameter verification failed. 11762 * @syscap SystemCapability.Multimedia.Audio.Capturer 11763 * @since 20 11764 */ 11765 enable(enable: boolean): Promise<boolean>; 11766 } 11767} 11768 11769export default audio; 11770