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 16import { ErrorCallback, AsyncCallback, Callback } from './@ohos.base'; 17 18/** 19 * @namespace audio 20 * @since 7 21 */ 22declare namespace audio { 23 /** 24 * Enumerates audio errors. 25 * @enum {number} 26 * @syscap SystemCapability.Multimedia.Audio.Core 27 * @since 9 28 */ 29 enum AudioErrors { 30 /** 31 * Invalid parameter. 32 * @syscap SystemCapability.Multimedia.Audio.Core 33 * @since 9 34 */ 35 ERROR_INVALID_PARAM = 6800101, 36 /** 37 * Allocate memory failed. 38 * @syscap SystemCapability.Multimedia.Audio.Core 39 * @since 9 40 */ 41 ERROR_NO_MEMORY = 6800102, 42 /** 43 * Operation not permit at current state. 44 * @syscap SystemCapability.Multimedia.Audio.Core 45 * @since 9 46 */ 47 ERROR_ILLEGAL_STATE = 6800103, 48 /** 49 * Unsupported option. 50 * @syscap SystemCapability.Multimedia.Audio.Core 51 * @since 9 52 */ 53 ERROR_UNSUPPORTED = 6800104, 54 /** 55 * Time out. 56 * @syscap SystemCapability.Multimedia.Audio.Core 57 * @since 9 58 */ 59 ERROR_TIMEOUT = 6800105, 60 /** 61 * Audio specific errors. 62 * @syscap SystemCapability.Multimedia.Audio.Core 63 * @since 9 64 */ 65 ERROR_STREAM_LIMIT = 6800201, 66 /** 67 * Default error. 68 * @syscap SystemCapability.Multimedia.Audio.Core 69 * @since 9 70 */ 71 ERROR_SYSTEM = 6800301 72 } 73 74 /** 75 * Define local device network id for audio 76 * @constant 77 * @syscap SystemCapability.Multimedia.Audio.Device 78 * @systemapi 79 * @since 9 80 */ 81 const LOCAL_NETWORK_ID: string; 82 83 /** 84 * Define default volume group id for audio 85 * @constant 86 * @syscap SystemCapability.Multimedia.Audio.Volume 87 * @since 9 88 */ 89 const DEFAULT_VOLUME_GROUP_ID: number; 90 91 /** 92 * Define default interrupt group id for audio 93 * @constant 94 * @syscap SystemCapability.Multimedia.Audio.Interrupt 95 * @since 9 96 */ 97 const DEFAULT_INTERRUPT_GROUP_ID: number; 98 99 /** 100 * Obtains an {@link AudioManager} instance. 101 * @returns { AudioManager } this {@link AudioManager} object. 102 * @syscap SystemCapability.Multimedia.Audio.Core 103 * @since 7 104 */ 105 function getAudioManager(): AudioManager; 106 107 /** 108 * Obtains an {@link AudioCapturer} instance. This method uses an asynchronous callback to return the capturer instance. 109 * @param { AudioCapturerOptions } options - Capturer configurations. 110 * @param { AsyncCallback<AudioCapturer> } callback - Callback used to return the audio capturer instance. 111 * @syscap SystemCapability.Multimedia.Audio.Capturer 112 * @since 8 113 */ 114 function createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<AudioCapturer>): void; 115 116 /** 117 * Obtains an {@link AudioCapturer} instance. This method uses a promise to return the capturer instance. 118 * @param { AudioCapturerOptions } options - Capturer configurations. 119 * @returns { Promise<AudioCapturer> } Promise used to return the audio capturer instance. 120 * @syscap SystemCapability.Multimedia.Audio.Capturer 121 * @since 8 122 */ 123 function createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer>; 124 125 /** 126 * Obtains an {@link AudioRenderer} instance. This method uses an asynchronous callback to return the renderer instance. 127 * @param { AudioRendererOptions } options - Renderer configurations. 128 * @param { AsyncCallback<AudioRenderer> } callback - Callback used to return the audio renderer instance. 129 * @syscap SystemCapability.Multimedia.Audio.Renderer 130 * @since 8 131 */ 132 function createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback<AudioRenderer>): void; 133 134 /** 135 * Obtains an {@link AudioRenderer} instance. This method uses a promise to return the renderer instance. 136 * @param { AudioRendererOptions } options - Renderer configurations. 137 * @returns { Promise<AudioRenderer> } Promise used to return the audio renderer instance. 138 * @syscap SystemCapability.Multimedia.Audio.Renderer 139 * @since 8 140 */ 141 function createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer>; 142 143 /** 144 * Obtains a {@link TonePlayer} instance. This method uses an asynchronous callback to return the renderer instance. 145 * @param { AudioRendererInfo } options - Tone playing attribute. 146 * @param { AsyncCallback<TonePlayer> } callback - Callback used to return the tonePlayer instance. 147 * @syscap SystemCapability.Multimedia.Audio.Tone 148 * @systemapi 149 * @since 9 150 */ 151 function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback<TonePlayer>): void; 152 153 /** 154 * Obtains a {@link TonePlayer} instance. This method uses a promise to return the renderer instance. 155 * @param { AudioRendererInfo } options - Tone playing attribute. 156 * @returns { Promise<TonePlayer> } Promise used to return the tonePlayer instance. 157 * @syscap SystemCapability.Multimedia.Audio.Tone 158 * @systemapi 159 * @since 9 160 */ 161 function createTonePlayer(options: AudioRendererInfo): Promise<TonePlayer>; 162 163 /** 164 * Enumerates the audio states. 165 * @enum { number } 166 * @syscap SystemCapability.Multimedia.Audio.Core 167 * @since 8 168 */ 169 enum AudioState { 170 /** 171 * Invalid state. 172 * @syscap SystemCapability.Multimedia.Audio.Core 173 * @since 8 174 */ 175 STATE_INVALID = -1, 176 /** 177 * Create new instance state. 178 * @syscap SystemCapability.Multimedia.Audio.Core 179 * @since 8 180 */ 181 STATE_NEW = 0, 182 /** 183 * Prepared state. 184 * @syscap SystemCapability.Multimedia.Audio.Core 185 * @since 8 186 */ 187 STATE_PREPARED = 1, 188 /** 189 * Running state. 190 * @syscap SystemCapability.Multimedia.Audio.Core 191 * @since 8 192 */ 193 STATE_RUNNING = 2, 194 /** 195 * Stopped state. 196 * @syscap SystemCapability.Multimedia.Audio.Core 197 * @since 8 198 */ 199 STATE_STOPPED = 3, 200 /** 201 * Released state. 202 * @syscap SystemCapability.Multimedia.Audio.Core 203 * @since 8 204 */ 205 STATE_RELEASED = 4, 206 /** 207 * Paused state. 208 * @syscap SystemCapability.Multimedia.Audio.Core 209 * @since 8 210 */ 211 STATE_PAUSED = 5 212 } 213 214 /** 215 * Enumerates audio stream types. 216 * @enum { number } 217 * @syscap SystemCapability.Multimedia.Audio.Volume 218 * @since 7 219 */ 220 enum AudioVolumeType { 221 /** 222 * Audio streams for voice calls. 223 * @syscap SystemCapability.Multimedia.Audio.Volume 224 * @since 8 225 */ 226 VOICE_CALL = 0, 227 /** 228 * Audio streams for ringtones. 229 * @syscap SystemCapability.Multimedia.Audio.Volume 230 * @since 7 231 */ 232 RINGTONE = 2, 233 /** 234 * Audio streams for media purpose. 235 * @syscap SystemCapability.Multimedia.Audio.Volume 236 * @since 7 237 */ 238 MEDIA = 3, 239 /** 240 * Audio stream for voice assistant. 241 * Audio volume for alarm purpose. 242 * @syscap SystemCapability.Multimedia.Audio.Volume 243 * @since 10 244 */ 245 ALARM = 4, 246 /** 247 * Audio volume for accessibility purpose. 248 * @syscap SystemCapability.Multimedia.Audio.Volume 249 * @since 10 250 */ 251 ACCESSIBILITY = 5, 252 /** 253 * Audio stream for voice assistant. 254 * @syscap SystemCapability.Multimedia.Audio.Volume 255 * @since 8 256 */ 257 VOICE_ASSISTANT = 9, 258 /** 259 * Audio volume for ultrasonic. 260 * @syscap SystemCapability.Multimedia.Audio.Volume 261 * @systemapi 262 * @since 10 263 */ 264 ULTRASONIC = 10, 265 /** 266 * Audio stream for all common. 267 * @syscap SystemCapability.Multimedia.Audio.Volume 268 * @systemapi 269 * @since 9 270 */ 271 ALL = 100, 272 } 273 274 /** 275 * Enumerates audio device flags. 276 * @enum { number } 277 * @syscap SystemCapability.Multimedia.Audio.Device 278 * @since 7 279 */ 280 enum DeviceFlag { 281 /** 282 * None devices. 283 * @syscap SystemCapability.Multimedia.Audio.Device 284 * @systemapi 285 * @since 9 286 */ 287 NONE_DEVICES_FLAG = 0, 288 /** 289 * Output devices. 290 * @syscap SystemCapability.Multimedia.Audio.Device 291 * @since 7 292 */ 293 OUTPUT_DEVICES_FLAG = 1, 294 /** 295 * Input devices. 296 * @syscap SystemCapability.Multimedia.Audio.Device 297 * @since 7 298 */ 299 INPUT_DEVICES_FLAG = 2, 300 /** 301 * All devices. 302 * @syscap SystemCapability.Multimedia.Audio.Device 303 * @since 7 304 */ 305 ALL_DEVICES_FLAG = 3, 306 /** 307 * Distributed output devices. 308 * @syscap SystemCapability.Multimedia.Audio.Device 309 * @systemapi 310 * @since 9 311 */ 312 DISTRIBUTED_OUTPUT_DEVICES_FLAG = 4, 313 /** 314 * Distributed input devices. 315 * @syscap SystemCapability.Multimedia.Audio.Device 316 * @systemapi 317 * @since 9 318 */ 319 DISTRIBUTED_INPUT_DEVICES_FLAG = 8, 320 /** 321 * All Distributed devices. 322 * @syscap SystemCapability.Multimedia.Audio.Device 323 * @systemapi 324 * @since 9 325 */ 326 ALL_DISTRIBUTED_DEVICES_FLAG = 12, 327 } 328 329 /** 330 * Enumerates device roles. 331 * @enum { number } 332 * @syscap SystemCapability.Multimedia.Audio.Device 333 * @since 7 334 */ 335 enum DeviceRole { 336 /** 337 * Input role. 338 * @syscap SystemCapability.Multimedia.Audio.Device 339 * @since 7 340 */ 341 INPUT_DEVICE = 1, 342 /** 343 * Output role. 344 * @syscap SystemCapability.Multimedia.Audio.Device 345 * @since 7 346 */ 347 OUTPUT_DEVICE = 2, 348 } 349 350 /** 351 * Enumerates device types. 352 * @enum { number } 353 * @syscap SystemCapability.Multimedia.Audio.Device 354 * @since 7 355 */ 356 enum DeviceType { 357 /** 358 * Invalid device. 359 * @syscap SystemCapability.Multimedia.Audio.Device 360 * @since 7 361 */ 362 INVALID = 0, 363 /** 364 * Built-in earpiece. 365 * @syscap SystemCapability.Multimedia.Audio.Device 366 * @since 7 367 */ 368 EARPIECE = 1, 369 /** 370 * Built-in speaker. 371 * @syscap SystemCapability.Multimedia.Audio.Device 372 * @since 7 373 */ 374 SPEAKER = 2, 375 /** 376 * Wired headset, which is a combination of a pair of earpieces and a microphone. 377 * @syscap SystemCapability.Multimedia.Audio.Device 378 * @since 7 379 */ 380 WIRED_HEADSET = 3, 381 /** 382 * A pair of wired headphones. 383 * @syscap SystemCapability.Multimedia.Audio.Device 384 * @since 7 385 */ 386 WIRED_HEADPHONES = 4, 387 /** 388 * Bluetooth device using the synchronous connection oriented link (SCO). 389 * @syscap SystemCapability.Multimedia.Audio.Device 390 * @since 7 391 */ 392 BLUETOOTH_SCO = 7, 393 /** 394 * Bluetooth device using advanced audio distribution profile (A2DP). 395 * @syscap SystemCapability.Multimedia.Audio.Device 396 * @since 7 397 */ 398 BLUETOOTH_A2DP = 8, 399 /** 400 * Built-in microphone. 401 * @syscap SystemCapability.Multimedia.Audio.Device 402 * @since 7 403 */ 404 MIC = 15, 405 /** 406 * USB audio headset. 407 * @syscap SystemCapability.Multimedia.Audio.Device 408 * @since 7 409 */ 410 USB_HEADSET = 22, 411 /** 412 * Default device type. 413 * @syscap SystemCapability.Multimedia.Audio.Device 414 * @since 9 415 */ 416 DEFAULT = 1000, 417 } 418 419 /** 420 * Enumerates the active device types. 421 * @enum { number } 422 * @syscap SystemCapability.Multimedia.Audio.Device 423 * @since 7 424 * @deprecated since 9 425 * @useinstead ohos.multimedia.audio.CommunicationDeviceType 426 */ 427 enum ActiveDeviceType { 428 /** 429 * Speaker. 430 * @syscap SystemCapability.Multimedia.Audio.Device 431 * @since 7 432 * @deprecated since 9 433 * @useinstead ohos.multimedia.audio.CommunicationDeviceType.SPEAKER 434 */ 435 SPEAKER = 2, 436 /** 437 * Bluetooth device using the SCO link. 438 * @syscap SystemCapability.Multimedia.Audio.Device 439 * @since 7 440 * @deprecated since 9 441 */ 442 BLUETOOTH_SCO = 7, 443 } 444 445 /** 446 * Enumerates the available device types for communication. 447 * @enum { number } 448 * @syscap SystemCapability.Multimedia.Audio.Communication 449 * @since 9 450 */ 451 enum CommunicationDeviceType { 452 /** 453 * Speaker. 454 * @syscap SystemCapability.Multimedia.Audio.Communication 455 * @since 9 456 */ 457 SPEAKER = 2 458 } 459 460 /** 461 * Enumerates ringer modes. 462 * @enum { number } 463 * @syscap SystemCapability.Multimedia.Audio.Communication 464 * @since 7 465 */ 466 enum AudioRingMode { 467 /** 468 * Silent mode. 469 * @syscap SystemCapability.Multimedia.Audio.Communication 470 * @since 7 471 */ 472 RINGER_MODE_SILENT = 0, 473 /** 474 * Vibration mode. 475 * @syscap SystemCapability.Multimedia.Audio.Communication 476 * @since 7 477 */ 478 RINGER_MODE_VIBRATE = 1, 479 /** 480 * Normal mode. 481 * @syscap SystemCapability.Multimedia.Audio.Communication 482 * @since 7 483 */ 484 RINGER_MODE_NORMAL = 2, 485 } 486 487 /** 488 * Enumerates the audio sample formats. 489 * @enum { number } 490 * @syscap SystemCapability.Multimedia.Audio.Core 491 * @since 8 492 */ 493 enum AudioSampleFormat { 494 /** 495 * Invalid format. 496 * @syscap SystemCapability.Multimedia.Audio.Core 497 * @since 8 498 */ 499 SAMPLE_FORMAT_INVALID = -1, 500 /** 501 * Unsigned 8 format. 502 * @syscap SystemCapability.Multimedia.Audio.Core 503 * @since 8 504 */ 505 SAMPLE_FORMAT_U8 = 0, 506 /** 507 * Signed 16 bit integer, little endian. 508 * @syscap SystemCapability.Multimedia.Audio.Core 509 * @since 8 510 */ 511 SAMPLE_FORMAT_S16LE = 1, 512 /** 513 * Signed 24 bit integer, little endian. 514 * @syscap SystemCapability.Multimedia.Audio.Core 515 * @since 8 516 */ 517 SAMPLE_FORMAT_S24LE = 2, 518 /** 519 * Signed 32 bit integer, little endian. 520 * @syscap SystemCapability.Multimedia.Audio.Core 521 * @since 8 522 */ 523 SAMPLE_FORMAT_S32LE = 3, 524 /** 525 * Signed 32 bit float, little endian. 526 * @syscap SystemCapability.Multimedia.Audio.Core 527 * @since 9 528 */ 529 SAMPLE_FORMAT_F32LE = 4, 530 } 531 532 /** 533 * Enumerates the audio channel. 534 * @enum { number } 535 * @syscap SystemCapability.Multimedia.Audio.Core 536 * @since 8 537 */ 538 enum AudioChannel { 539 /** 540 * Channel 1. 541 * @syscap SystemCapability.Multimedia.Audio.Core 542 * @since 8 543 */ 544 CHANNEL_1 = 0x1 << 0, 545 /** 546 * Channel 2. 547 * @syscap SystemCapability.Multimedia.Audio.Core 548 * @since 8 549 */ 550 CHANNEL_2 = 0x1 << 1 551 } 552 553 /** 554 * Enumerates the audio sampling rate. 555 * @enum { number } 556 * @syscap SystemCapability.Multimedia.Audio.Core 557 * @since 8 558 */ 559 enum AudioSamplingRate { 560 /** 561 * 8kHz sample rate. 562 * @syscap SystemCapability.Multimedia.Audio.Core 563 * @since 8 564 */ 565 SAMPLE_RATE_8000 = 8000, 566 /** 567 * 11.025kHz sample rate. 568 * @syscap SystemCapability.Multimedia.Audio.Core 569 * @since 8 570 */ 571 SAMPLE_RATE_11025 = 11025, 572 /** 573 * 12kHz sample rate. 574 * @syscap SystemCapability.Multimedia.Audio.Core 575 * @since 8 576 */ 577 SAMPLE_RATE_12000 = 12000, 578 /** 579 * 16kHz sample rate. 580 * @syscap SystemCapability.Multimedia.Audio.Core 581 * @since 8 582 */ 583 SAMPLE_RATE_16000 = 16000, 584 /** 585 * 22.05kHz sample rate. 586 * @syscap SystemCapability.Multimedia.Audio.Core 587 * @since 8 588 */ 589 SAMPLE_RATE_22050 = 22050, 590 /** 591 * 24kHz sample rate. 592 * @syscap SystemCapability.Multimedia.Audio.Core 593 * @since 8 594 */ 595 SAMPLE_RATE_24000 = 24000, 596 /** 597 * 32kHz sample rate. 598 * @syscap SystemCapability.Multimedia.Audio.Core 599 * @since 8 600 */ 601 SAMPLE_RATE_32000 = 32000, 602 /** 603 * 44.1kHz sample rate. 604 * @syscap SystemCapability.Multimedia.Audio.Core 605 * @since 8 606 */ 607 SAMPLE_RATE_44100 = 44100, 608 /** 609 * 48kHz sample rate. 610 * @syscap SystemCapability.Multimedia.Audio.Core 611 * @since 8 612 */ 613 SAMPLE_RATE_48000 = 48000, 614 /** 615 * 64kHz sample rate. 616 * @syscap SystemCapability.Multimedia.Audio.Core 617 * @since 8 618 */ 619 SAMPLE_RATE_64000 = 64000, 620 /** 621 * 96kHz sample rate. 622 * @syscap SystemCapability.Multimedia.Audio.Core 623 * @since 8 624 */ 625 SAMPLE_RATE_96000 = 96000 626 } 627 628 /** 629 * Enumerates the audio encoding type. 630 * @enum { number } 631 * @syscap SystemCapability.Multimedia.Audio.Core 632 * @since 8 633 */ 634 enum AudioEncodingType { 635 /** 636 * Invalid type. 637 * @syscap SystemCapability.Multimedia.Audio.Core 638 * @since 8 639 */ 640 ENCODING_TYPE_INVALID = -1, 641 /** 642 * PCM encoding. 643 * @syscap SystemCapability.Multimedia.Audio.Core 644 * @since 8 645 */ 646 ENCODING_TYPE_RAW = 0 647 } 648 649 /** 650 * Enumerates the audio content type. 651 * @enum { number } 652 * @syscap SystemCapability.Multimedia.Audio.Core 653 * @since 7 654 * @deprecated since 10 655 * @useinstead ohos.multimedia.audio.StreamUsage 656 */ 657 enum ContentType { 658 /** 659 * Unknown content. 660 * @syscap SystemCapability.Multimedia.Audio.Core 661 * @since 7 662 * @deprecated since 10 663 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_UNKNOWN 664 */ 665 CONTENT_TYPE_UNKNOWN = 0, 666 /** 667 * Speech content. 668 * @syscap SystemCapability.Multimedia.Audio.Core 669 * @since 7 670 * @deprecated since 10 671 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION 672 */ 673 CONTENT_TYPE_SPEECH = 1, 674 /** 675 * Music content. 676 * @syscap SystemCapability.Multimedia.Audio.Core 677 * @since 7 678 * @deprecated since 10 679 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MUSIC 680 */ 681 CONTENT_TYPE_MUSIC = 2, 682 /** 683 * Movie content. 684 * @syscap SystemCapability.Multimedia.Audio.Core 685 * @since 7 686 * @deprecated since 10 687 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MOVIE 688 */ 689 CONTENT_TYPE_MOVIE = 3, 690 /** 691 * Notification content. 692 * @syscap SystemCapability.Multimedia.Audio.Core 693 * @since 7 694 * @deprecated since 10 695 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_NOTIFICATION 696 */ 697 CONTENT_TYPE_SONIFICATION = 4, 698 /** 699 * Ringtone content. 700 * @syscap SystemCapability.Multimedia.Audio.Core 701 * @since 8 702 * @deprecated since 10 703 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_RINGTONE 704 */ 705 CONTENT_TYPE_RINGTONE = 5, 706 } 707 708 /** 709 * Enumerates the stream usage. 710 * @enum { number } 711 * @syscap SystemCapability.Multimedia.Audio.Core 712 * @since 7 713 */ 714 enum StreamUsage { 715 /** 716 * Unknown usage. 717 * @syscap SystemCapability.Multimedia.Audio.Core 718 * @since 7 719 */ 720 STREAM_USAGE_UNKNOWN = 0, 721 /** 722 * Media usage. 723 * @syscap SystemCapability.Multimedia.Audio.Core 724 * @since 7 725 * @deprecated since 10 726 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MUSIC or 727 * ohos.multimedia.audio.StreamUsage.STREAM_USAGE_MOVIE or 728 * ohos.multimedia.audio.StreamUsage.STREAM_USAGE_GAME or 729 * ohos.multimedia.audio.StreamUsage.STREAM_USAGE_AUDIOBOOK 730 */ 731 STREAM_USAGE_MEDIA = 1, 732 /** 733 * Music usage. 734 * @syscap SystemCapability.Multimedia.Audio.Core 735 * @since 10 736 */ 737 STREAM_USAGE_MUSIC = 1, 738 /** 739 * Voice communication usage. 740 * @syscap SystemCapability.Multimedia.Audio.Core 741 * @since 7 742 */ 743 STREAM_USAGE_VOICE_COMMUNICATION = 2, 744 /** 745 * Voice assistant broadcast usage. 746 * @syscap SystemCapability.Multimedia.Audio.Core 747 * @since 9 748 */ 749 STREAM_USAGE_VOICE_ASSISTANT = 3, 750 /** 751 * Alarm usage. 752 * @syscap SystemCapability.Multimedia.Audio.Core 753 * @since 10 754 */ 755 STREAM_USAGE_ALARM = 4, 756 /** 757 * Voice message usage. 758 * @syscap SystemCapability.Multimedia.Audio.Core 759 * @since 10 760 */ 761 STREAM_USAGE_VOICE_MESSAGE = 5, 762 /** 763 * Notification or ringtone usage. 764 * @syscap SystemCapability.Multimedia.Audio.Core 765 * @since 7 766 * @deprecated since 10 767 * @useinstead ohos.multimedia.audio.StreamUsage.STREAM_USAGE_RINGTONE 768 */ 769 STREAM_USAGE_NOTIFICATION_RINGTONE = 6, 770 /** 771 * Ringtone usage. 772 * @syscap SystemCapability.Multimedia.Audio.Core 773 * @since 10 774 */ 775 STREAM_USAGE_RINGTONE = 6, 776 /** 777 * Notification usage. 778 * @syscap SystemCapability.Multimedia.Audio.Core 779 * @since 10 780 */ 781 STREAM_USAGE_NOTIFICATION = 7, 782 /** 783 * Accessibility usage, such as screen reader. 784 * @syscap SystemCapability.Multimedia.Audio.Core 785 * @since 10 786 */ 787 STREAM_USAGE_ACCESSIBILITY = 8, 788 /** 789 * System usage, such as screen lock or key click. 790 * @syscap SystemCapability.Multimedia.Audio.Core 791 * @systemapi 792 * @since 10 793 */ 794 STREAM_USAGE_SYSTEM = 9, 795 /** 796 * Movie or video usage. 797 * @syscap SystemCapability.Multimedia.Audio.Core 798 * @since 10 799 */ 800 STREAM_USAGE_MOVIE = 10, 801 /** 802 * Game sound effect usage. 803 * @syscap SystemCapability.Multimedia.Audio.Core 804 * @since 10 805 */ 806 STREAM_USAGE_GAME = 11, 807 /** 808 * Audiobook usage. 809 * @syscap SystemCapability.Multimedia.Audio.Core 810 * @since 10 811 */ 812 STREAM_USAGE_AUDIOBOOK = 12, 813 /** 814 * Navigation usage. 815 * @syscap SystemCapability.Multimedia.Audio.Core 816 * @since 10 817 */ 818 STREAM_USAGE_NAVIGATION = 13, 819 /** 820 * DTMF dial tone usage. 821 * @syscap SystemCapability.Multimedia.Audio.Core 822 * @systemapi 823 * @since 10 824 */ 825 STREAM_USAGE_DTMF = 14, 826 /** 827 * Enforced tone usage, such as camera shutter. 828 * @syscap SystemCapability.Multimedia.Audio.Core 829 * @systemapi 830 * @since 10 831 */ 832 STREAM_USAGE_ENFORCED_TONE = 15, 833 /** 834 * Ultrasonic playing usage. 835 * @syscap SystemCapability.Multimedia.Audio.Core 836 * @systemapi 837 * @since 10 838 */ 839 STREAM_USAGE_ULTRASONIC = 16, 840 } 841 842 /** 843 * Enumerates the audio interrupt request type. 844 * @enum { number } 845 * @syscap SystemCapability.Multimedia.Audio.Interrupt 846 * @systemapi 847 * @since 9 848 */ 849 enum InterruptRequestType { 850 /** 851 * Default type to request audio interrupt. 852 * @syscap SystemCapability.Multimedia.Audio.Interrupt 853 * @systemapi 854 * @since 9 855 */ 856 INTERRUPT_REQUEST_TYPE_DEFAULT = 0, 857 } 858 859 /** 860 * Describes audio stream information. 861 * @typedef AudioStreamInfo 862 * @syscap SystemCapability.Multimedia.Audio.Core 863 * @since 8 864 */ 865 interface AudioStreamInfo { 866 /** 867 * Sampling rate. 868 * @syscap SystemCapability.Multimedia.Audio.Core 869 * @since 8 870 */ 871 samplingRate: AudioSamplingRate; 872 /** 873 * Audio channels. 874 * @syscap SystemCapability.Multimedia.Audio.Core 875 * @since 8 876 */ 877 channels: AudioChannel; 878 /** 879 * Audio sample format. 880 * @syscap SystemCapability.Multimedia.Audio.Core 881 * @since 8 882 */ 883 sampleFormat: AudioSampleFormat; 884 /** 885 * Audio encoding type. 886 * @syscap SystemCapability.Multimedia.Audio.Core 887 * @since 8 888 */ 889 encodingType: AudioEncodingType; 890 } 891 892 /** 893 * Describes audio renderer information. 894 * @typedef AudioRendererInfo 895 * @syscap SystemCapability.Multimedia.Audio.Core 896 * @since 8 897 */ 898 interface AudioRendererInfo { 899 /** 900 * Content type. 901 * @type { ContentType } 902 * @syscap SystemCapability.Multimedia.Audio.Core 903 * @since 8 904 * @deprecated since 10 905 * @useinstead ohos.multimedia.audio.AudioRendererInfo#usage 906 */ 907 /** 908 * Content type. 909 * @type { ?ContentType } 910 * @syscap SystemCapability.Multimedia.Audio.Core 911 * @since 10 912 */ 913 content?: ContentType; 914 /** 915 * Stream usage. 916 * @syscap SystemCapability.Multimedia.Audio.Core 917 * @since 8 918 */ 919 usage: StreamUsage; 920 /** 921 * Audio renderer flags. 922 * @syscap SystemCapability.Multimedia.Audio.Core 923 * @since 8 924 */ 925 rendererFlags: number; 926 } 927 928 /** 929 * Describes audio renderer filter. 930 * @typedef AudioRendererFilter 931 * @syscap SystemCapability.Multimedia.Audio.Core 932 * @systemapi 933 * @since 9 934 */ 935 interface AudioRendererFilter { 936 /** 937 * Application uid. 938 * @syscap SystemCapability.Multimedia.Audio.Core 939 * @systemapi 940 * @since 9 941 */ 942 uid?: number; 943 /** 944 * Renderer information. 945 * @syscap SystemCapability.Multimedia.Audio.Renderer 946 * @systemapi 947 * @since 9 948 */ 949 rendererInfo?: AudioRendererInfo; 950 /** 951 * AudioRenderer id. 952 * @syscap SystemCapability.Multimedia.Audio.Renderer 953 * @systemapi 954 * @since 9 955 */ 956 rendererId?: number; 957 } 958 959 /** 960 * Describes audio renderer configuration options. 961 * @typedef AudioRendererOptions 962 * @syscap SystemCapability.Multimedia.Audio.Renderer 963 * @since 8 964 */ 965 interface AudioRendererOptions { 966 /** 967 * Stream information. 968 * @syscap SystemCapability.Multimedia.Audio.Renderer 969 * @since 8 970 */ 971 streamInfo: AudioStreamInfo; 972 /** 973 * Renderer information. 974 * @syscap SystemCapability.Multimedia.Audio.Renderer 975 * @since 8 976 */ 977 rendererInfo: AudioRendererInfo; 978 /** 979 * Privacy configuration. 980 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 981 * @since 10 982 */ 983 privacyType?: AudioPrivacyType; 984 } 985 986 /** 987 * Enumerates audio stream privacy type for playback capture. 988 * @enum { number } 989 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 990 * @since 10 991 */ 992 enum AudioPrivacyType { 993 /** 994 * Privacy type that stream can be captured by third party applications. 995 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 996 * @since 10 997 */ 998 PRIVACY_TYPE_PUBLIC = 0, 999 1000 /** 1001 * Privacy type that stream can not be captured. 1002 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 1003 * @since 10 1004 */ 1005 PRIVACY_TYPE_PRIVATE = 1, 1006 } 1007 1008 /** 1009 * Enumerates the interrupt modes. 1010 * @enum { number } 1011 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1012 * @since 9 1013 */ 1014 enum InterruptMode { 1015 /** 1016 * Mode that different stream share one interrupt unit. 1017 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1018 * @since 9 1019 */ 1020 SHARE_MODE = 0, 1021 /** 1022 * Mode that each stream has independent interrupt unit. 1023 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1024 * @since 9 1025 */ 1026 INDEPENDENT_MODE = 1 1027 } 1028 1029 /** 1030 * Enumerates the audio renderer rates. 1031 * @enum { number } 1032 * @syscap SystemCapability.Multimedia.Audio.Renderer 1033 * @since 8 1034 */ 1035 enum AudioRendererRate { 1036 /** 1037 * Normal rate. 1038 * @syscap SystemCapability.Multimedia.Audio.Renderer 1039 * @since 8 1040 */ 1041 RENDER_RATE_NORMAL = 0, 1042 /** 1043 * Double rate. 1044 * @syscap SystemCapability.Multimedia.Audio.Renderer 1045 * @since 8 1046 */ 1047 RENDER_RATE_DOUBLE = 1, 1048 /** 1049 * Half rate. 1050 * @syscap SystemCapability.Multimedia.Audio.Renderer 1051 * @since 8 1052 */ 1053 RENDER_RATE_HALF = 2 1054 } 1055 1056 /** 1057 * Enumerates the interrupt types. 1058 * @enum { number } 1059 * @syscap SystemCapability.Multimedia.Audio.Renderer 1060 * @since 7 1061 */ 1062 enum InterruptType { 1063 /** 1064 * Audio playback interruption started. 1065 * @syscap SystemCapability.Multimedia.Audio.Renderer 1066 * @since 7 1067 */ 1068 INTERRUPT_TYPE_BEGIN = 1, 1069 1070 /** 1071 * Audio playback interruption ended. 1072 * @syscap SystemCapability.Multimedia.Audio.Renderer 1073 * @since 7 1074 */ 1075 INTERRUPT_TYPE_END = 2 1076 } 1077 1078 /** 1079 * Enumerates the interrupt hints. 1080 * @enum { number } 1081 * @syscap SystemCapability.Multimedia.Audio.Renderer 1082 * @since 7 1083 */ 1084 enum InterruptHint { 1085 /** 1086 * None. 1087 * @syscap SystemCapability.Multimedia.Audio.Renderer 1088 * @since 8 1089 */ 1090 INTERRUPT_HINT_NONE = 0, 1091 /** 1092 * Resume the playback. 1093 * @syscap SystemCapability.Multimedia.Audio.Renderer 1094 * @since 7 1095 */ 1096 INTERRUPT_HINT_RESUME = 1, 1097 1098 /** 1099 * Paused/Pause the playback. 1100 * @syscap SystemCapability.Multimedia.Audio.Renderer 1101 * @since 7 1102 */ 1103 INTERRUPT_HINT_PAUSE = 2, 1104 1105 /** 1106 * Stopped/Stop the playback. 1107 * @syscap SystemCapability.Multimedia.Audio.Renderer 1108 * @since 7 1109 */ 1110 INTERRUPT_HINT_STOP = 3, 1111 1112 /** 1113 * Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.) 1114 * @syscap SystemCapability.Multimedia.Audio.Renderer 1115 * @since 7 1116 */ 1117 INTERRUPT_HINT_DUCK = 4, 1118 1119 /** 1120 * Unducked the playback. 1121 * @syscap SystemCapability.Multimedia.Audio.Renderer 1122 * @since 8 1123 */ 1124 INTERRUPT_HINT_UNDUCK = 5, 1125 } 1126 1127 /** 1128 * Enumerates the interrupt force types. 1129 * @enum { number } 1130 * @syscap SystemCapability.Multimedia.Audio.Renderer 1131 * @since 9 1132 */ 1133 enum InterruptForceType { 1134 /** 1135 * Forced action taken by system. 1136 * @syscap SystemCapability.Multimedia.Audio.Renderer 1137 * @since 9 1138 */ 1139 INTERRUPT_FORCE = 0, 1140 /** 1141 * Share type, application can choose to take action or ignore. 1142 * @syscap SystemCapability.Multimedia.Audio.Renderer 1143 * @since 9 1144 */ 1145 INTERRUPT_SHARE = 1 1146 } 1147 1148 /** 1149 * Describes the interrupt event received by the app when playback is interrupted. 1150 * @typedef InterruptEvent 1151 * @syscap SystemCapability.Multimedia.Audio.Renderer 1152 * @since 9 1153 */ 1154 interface InterruptEvent { 1155 /** 1156 * Indicates whether the interruption has started or finished. 1157 * @syscap SystemCapability.Multimedia.Audio.Renderer 1158 * @since 9 1159 */ 1160 eventType: InterruptType; 1161 1162 /** 1163 * Indicates whether the action is taken by system or to be taken by the app. 1164 * @syscap SystemCapability.Multimedia.Audio.Renderer 1165 * @since 9 1166 */ 1167 forceType: InterruptForceType; 1168 1169 /** 1170 * Indicates the kind of action. 1171 * @syscap SystemCapability.Multimedia.Audio.Renderer 1172 * @since 9 1173 */ 1174 hintType: InterruptHint; 1175 } 1176 1177 /** 1178 * Enumerates interrupt action types. 1179 * @enum { number } 1180 * @syscap SystemCapability.Multimedia.Audio.Renderer 1181 * @since 7 1182 * @deprecated since 9 1183 */ 1184 enum InterruptActionType { 1185 1186 /** 1187 * Focus gain event. 1188 * @syscap SystemCapability.Multimedia.Audio.Renderer 1189 * @since 7 1190 * @deprecated since 9 1191 */ 1192 TYPE_ACTIVATED = 0, 1193 1194 /** 1195 * Audio interruption event. 1196 * @syscap SystemCapability.Multimedia.Audio.Renderer 1197 * @since 7 1198 * @deprecated since 9 1199 */ 1200 TYPE_INTERRUPT = 1 1201 } 1202 1203 /** 1204 * Enumerates device change types. 1205 * @enum { number } 1206 * @syscap SystemCapability.Multimedia.Audio.Device 1207 * @since 7 1208 */ 1209 enum DeviceChangeType { 1210 /** 1211 * Device connection. 1212 * @syscap SystemCapability.Multimedia.Audio.Device 1213 * @since 7 1214 */ 1215 CONNECT = 0, 1216 1217 /** 1218 * Device disconnection. 1219 * @syscap SystemCapability.Multimedia.Audio.Device 1220 * @since 7 1221 */ 1222 DISCONNECT = 1, 1223 } 1224 1225 /** 1226 * Enumerates audio scenes. 1227 * @enum { number } 1228 * @syscap SystemCapability.Multimedia.Audio.Communication 1229 * @since 8 1230 */ 1231 enum AudioScene { 1232 /** 1233 * Default audio scene 1234 * @syscap SystemCapability.Multimedia.Audio.Communication 1235 * @since 8 1236 */ 1237 AUDIO_SCENE_DEFAULT = 0, 1238 /** 1239 * Ringing audio scene 1240 * @syscap SystemCapability.Multimedia.Audio.Communication 1241 * @systemapi 1242 * @since 8 1243 */ 1244 AUDIO_SCENE_RINGING = 1, 1245 /** 1246 * Phone call audio scene 1247 * @syscap SystemCapability.Multimedia.Audio.Communication 1248 * @systemapi 1249 * @since 8 1250 */ 1251 AUDIO_SCENE_PHONE_CALL = 2, 1252 /** 1253 * Voice chat audio scene 1254 * @syscap SystemCapability.Multimedia.Audio.Communication 1255 * @since 8 1256 */ 1257 AUDIO_SCENE_VOICE_CHAT = 3 1258 } 1259 1260 /** 1261 * Enumerates volume adjustment types. 1262 * @enum { number } 1263 * @syscap SystemCapability.Multimedia.Audio.Volume 1264 * @systemapi 1265 * @since 10 1266 */ 1267 enum VolumeAdjustType { 1268 /** 1269 * Adjust volume up. 1270 * @syscap SystemCapability.Multimedia.Audio.Volume 1271 * @systemapi 1272 * @since 10 1273 */ 1274 VOLUME_UP = 0, 1275 /** 1276 * Adjust volume down. 1277 * @syscap SystemCapability.Multimedia.Audio.Volume 1278 * @systemapi 1279 * @since 10 1280 */ 1281 VOLUME_DOWN = 1, 1282 } 1283 1284 /** 1285 * Implements audio volume and audio device management. 1286 * @typedef AudioManager 1287 * @syscap SystemCapability.Multimedia.Audio.Core 1288 * @since 7 1289 */ 1290 interface AudioManager { 1291 /** 1292 * Sets the volume for a stream. This method uses an asynchronous callback to return the result. 1293 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1294 * @param { AudioVolumeType } volumeType - Audio stream type. 1295 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 1296 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1297 * @syscap SystemCapability.Multimedia.Audio.Volume 1298 * @since 7 1299 * @deprecated since 9 1300 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume 1301 */ 1302 setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void; 1303 /** 1304 * Sets the volume for a stream. This method uses a promise to return the result. 1305 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1306 * @param { AudioVolumeType } volumeType - Audio stream type. 1307 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 1308 * @returns { Promise<void> } Promise used to return the result. 1309 * @syscap SystemCapability.Multimedia.Audio.Volume 1310 * @since 7 1311 * @deprecated since 9 1312 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume 1313 */ 1314 setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>; 1315 /** 1316 * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. 1317 * @param { AudioVolumeType } volumeType - Audio stream type. 1318 * @param { AsyncCallback<number> } callback - Callback used to return the volume. 1319 * @syscap SystemCapability.Multimedia.Audio.Volume 1320 * @since 7 1321 * @deprecated since 9 1322 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume 1323 */ 1324 getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1325 /** 1326 * Obtains the volume of a stream. This method uses a promise to return the query result. 1327 * @param { AudioVolumeType } volumeType - Audio stream type. 1328 * @returns { Promise<number> } Promise used to return the volume. 1329 * @syscap SystemCapability.Multimedia.Audio.Volume 1330 * @since 7 1331 * @deprecated since 9 1332 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume 1333 */ 1334 getVolume(volumeType: AudioVolumeType): Promise<number>; 1335 /** 1336 * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 1337 * @param { AudioVolumeType } volumeType - Audio stream type. 1338 * @param { AsyncCallback<number> } callback - Callback used to return the minimum volume. 1339 * @syscap SystemCapability.Multimedia.Audio.Volume 1340 * @since 7 1341 * @deprecated since 9 1342 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume 1343 */ 1344 getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1345 /** 1346 * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. 1347 * @param { AudioVolumeType } volumeType - Audio stream type. 1348 * @returns { Promise<number> } Promise used to return the minimum volume. 1349 * @syscap SystemCapability.Multimedia.Audio.Volume 1350 * @since 7 1351 * @deprecated since 9 1352 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume 1353 */ 1354 getMinVolume(volumeType: AudioVolumeType): Promise<number>; 1355 /** 1356 * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 1357 * @param { AudioVolumeType } volumeType - Audio stream type. 1358 * @param { AsyncCallback<number> } callback - Callback used to return the maximum volume. 1359 * @syscap SystemCapability.Multimedia.Audio.Volume 1360 * @since 7 1361 * @deprecated since 9 1362 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume 1363 */ 1364 getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1365 /** 1366 * Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result. 1367 * @param { AudioVolumeType } volumeType - Audio stream type. 1368 * @returns { Promise<number> } Promise used to return the maximum volume. 1369 * @syscap SystemCapability.Multimedia.Audio.Volume 1370 * @since 7 1371 * @deprecated since 9 1372 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume 1373 */ 1374 getMaxVolume(volumeType: AudioVolumeType): Promise<number>; 1375 /** 1376 * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. 1377 * @param { DeviceFlag } deviceFlag - Audio device flag. 1378 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the device list. 1379 * @syscap SystemCapability.Multimedia.Audio.Device 1380 * @since 7 1381 * @deprecated since 9 1382 * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices 1383 */ 1384 getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void; 1385 /** 1386 * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. 1387 * @param { DeviceFlag } deviceFlag - Audio device flag. 1388 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the device list. 1389 * @syscap SystemCapability.Multimedia.Audio.Device 1390 * @since 7 1391 * @deprecated since 9 1392 * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices 1393 */ 1394 getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>; 1395 /** 1396 * Mutes a stream. This method uses an asynchronous callback to return the result. 1397 * @param { AudioVolumeType } volumeType - Audio stream type. 1398 * @param { boolean } mute - Mute status to set. The value true means to mute the stream, and false means the opposite. 1399 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1400 * @syscap SystemCapability.Multimedia.Audio.Volume 1401 * @since 7 1402 * @deprecated since 9 1403 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute 1404 */ 1405 mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void; 1406 /** 1407 * Mutes a stream. This method uses a promise to return the result. 1408 * @param { AudioVolumeType } volumeType - Audio stream type. 1409 * @param { boolean } mute - Mute status to set. The value true means to mute the stream, and false means the opposite. 1410 * @returns { Promise<void> } Promise used to return the result. 1411 * @syscap SystemCapability.Multimedia.Audio.Volume 1412 * @since 7 1413 * @deprecated since 9 1414 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute 1415 */ 1416 mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>; 1417 /** 1418 * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. 1419 * @param { AudioVolumeType } volumeType - Audio stream type. 1420 * @param { AsyncCallback<boolean> } callback - Callback used to return the mute status of the stream. 1421 * The value true means that the stream is muted, and false means the opposite. 1422 * @syscap SystemCapability.Multimedia.Audio.Volume 1423 * @since 7 1424 * @deprecated since 9 1425 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute 1426 */ 1427 isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 1428 /** 1429 * Checks whether a stream is muted. This method uses a promise to return the result. 1430 * @param { AudioVolumeType } volumeType - Audio stream type. 1431 * @returns { Promise<boolean> } Promise used to return the mute status of the stream. The value true means 1432 * that the stream is muted, and false means the opposite. 1433 * @syscap SystemCapability.Multimedia.Audio.Volume 1434 * @since 7 1435 * @deprecated since 9 1436 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute 1437 */ 1438 isMute(volumeType: AudioVolumeType): Promise<boolean>; 1439 /** 1440 * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. 1441 * @param { AudioVolumeType } volumeType - Audio stream type. 1442 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the stream. 1443 * The value true means that the stream is active, and false means the opposite. 1444 * @syscap SystemCapability.Multimedia.Audio.Volume 1445 * @since 7 1446 * @deprecated since 9 1447 * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive 1448 */ 1449 isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 1450 /** 1451 * Checks whether a stream is active. This method uses a promise to return the query result. 1452 * @param { AudioVolumeType } volumeType - Audio stream type. 1453 * @returns { Promise<boolean> } Promise used to return the active status of the stream. The value true means 1454 * that the stream is active, and false means the opposite. 1455 * @syscap SystemCapability.Multimedia.Audio.Volume 1456 * @since 7 1457 * @deprecated since 9 1458 * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive 1459 */ 1460 isActive(volumeType: AudioVolumeType): Promise<boolean>; 1461 /** 1462 * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. 1463 * @permission ohos.permission.MICROPHONE 1464 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 1465 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1466 * @syscap SystemCapability.Multimedia.Audio.Device 1467 * @since 7 1468 * @deprecated since 9 1469 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute 1470 */ 1471 setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void; 1472 /** 1473 * Mutes or unmutes the microphone. This method uses a promise to return the result. 1474 * @permission ohos.permission.MICROPHONE 1475 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 1476 * @returns { Promise<void> } Promise used to return the result. 1477 * @syscap SystemCapability.Multimedia.Audio.Device 1478 * @since 7 1479 * @deprecated since 9 1480 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute 1481 */ 1482 setMicrophoneMute(mute: boolean): Promise<void>; 1483 /** 1484 * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. 1485 * @permission ohos.permission.MICROPHONE 1486 * @param { AsyncCallback<boolean> } callback - used to return the mute status of the microphone. The value 1487 * true means that the microphone is muted, and false means the opposite. 1488 * @syscap SystemCapability.Multimedia.Audio.Device 1489 * @since 7 1490 * @deprecated since 9 1491 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute 1492 */ 1493 isMicrophoneMute(callback: AsyncCallback<boolean>): void; 1494 /** 1495 * Checks whether the microphone is muted. This method uses a promise to return the query result. 1496 * @permission ohos.permission.MICROPHONE 1497 * @returns { Promise<boolean> } Promise used to return the mute status of the microphone. The value 1498 * true means that the microphone is muted, and false means the opposite. 1499 * @syscap SystemCapability.Multimedia.Audio.Device 1500 * @since 7 1501 * @deprecated since 9 1502 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute 1503 */ 1504 isMicrophoneMute(): Promise<boolean>; 1505 /** 1506 * Sets the ringer mode. This method uses an asynchronous callback to return the result. 1507 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1508 * @param { AudioRingMode } mode - Ringer mode. 1509 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1510 * @syscap SystemCapability.Multimedia.Audio.Communication 1511 * @since 7 1512 * @deprecated since 9 1513 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode 1514 */ 1515 setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void; 1516 /** 1517 * Sets the ringer mode. This method uses a promise to return the result. 1518 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1519 * @param { AudioRingMode } mode - Ringer mode. 1520 * @returns { Promise<void> } Promise used to return the result. 1521 * @syscap SystemCapability.Multimedia.Audio.Communication 1522 * @since 7 1523 * @deprecated since 9 1524 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode 1525 */ 1526 setRingerMode(mode: AudioRingMode): Promise<void>; 1527 /** 1528 * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. 1529 * @param { AsyncCallback<AudioRingMode> } callback - Callback used to return the ringer mode. 1530 * @syscap SystemCapability.Multimedia.Audio.Communication 1531 * @since 7 1532 * @deprecated since 9 1533 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode 1534 */ 1535 getRingerMode(callback: AsyncCallback<AudioRingMode>): void; 1536 /** 1537 * Obtains the ringer mode. This method uses a promise to return the query result. 1538 * @returns { Promise<AudioRingMode> } Promise used to return the ringer mode. 1539 * @syscap SystemCapability.Multimedia.Audio.Communication 1540 * @since 7 1541 * @deprecated since 9 1542 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode 1543 */ 1544 getRingerMode(): Promise<AudioRingMode>; 1545 /** 1546 * Sets an audio parameter. This method uses an asynchronous callback to return the result. 1547 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 1548 * @param { string } key - Key of the audio parameter to set. 1549 * @param { string } value - Value of the audio parameter to set. 1550 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1551 * @syscap SystemCapability.Multimedia.Audio.Core 1552 * @since 7 1553 */ 1554 setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void; 1555 /** 1556 * Sets an audio parameter. This method uses a promise to return the result. 1557 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 1558 * @param { string } key - Key of the audio parameter to set. 1559 * @param { string } value - Value of the audio parameter to set. 1560 * @returns { Promise<void> } Promise used to return the result. 1561 * @syscap SystemCapability.Multimedia.Audio.Core 1562 * @since 7 1563 */ 1564 setAudioParameter(key: string, value: string): Promise<void>; 1565 /** 1566 * Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. 1567 * @param { string } key - Key of the audio parameter whose value is to be obtained. 1568 * @param { AsyncCallback<string> } callback - Callback used to return the value of the audio parameter. 1569 * @syscap SystemCapability.Multimedia.Audio.Core 1570 * @since 7 1571 */ 1572 getAudioParameter(key: string, callback: AsyncCallback<string>): void; 1573 /** 1574 * Obtains the value of an audio parameter. This method uses a promise to return the query result. 1575 * @param { string } key - Key of the audio parameter whose value is to be obtained. 1576 * @returns { Promise<string> } Promise used to return the value of the audio parameter. 1577 * @syscap SystemCapability.Multimedia.Audio.Core 1578 * @since 7 1579 */ 1580 getAudioParameter(key: string): Promise<string>; 1581 /** 1582 * Sets a device to the active state. This method uses an asynchronous callback to return the result. 1583 * @param { ActiveDeviceType } deviceType - Audio device type. 1584 * @param { boolean } active - Active status to set. The value true means to set the device to the active 1585 * status, and false means the opposite. 1586 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1587 * @syscap SystemCapability.Multimedia.Audio.Device 1588 * @since 7 1589 * @deprecated since 9 1590 * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice 1591 */ 1592 setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback<void>): void; 1593 /** 1594 * Sets a device to the active state. This method uses a promise to return the result. 1595 * @param { ActiveDeviceType } deviceType - Audio device type. 1596 * @param { boolean } active - Active status to set. The value true means to set the device to the active 1597 * status, and false means the opposite. 1598 * @returns { Promise<void> } Promise used to return the result. 1599 * @syscap SystemCapability.Multimedia.Audio.Device 1600 * @since 7 1601 * @deprecated since 9 1602 * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice 1603 */ 1604 setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void>; 1605 /** 1606 * Checks whether a device is active. This method uses an asynchronous callback to return the query result. 1607 * @param { ActiveDeviceType } deviceType - Audio device type. 1608 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the device. 1609 * @syscap SystemCapability.Multimedia.Audio.Device 1610 * @since 7 1611 * @deprecated since 9 1612 * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive 1613 */ 1614 isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean>): void; 1615 /** 1616 * Checks whether a device is active. This method uses a promise to return the query result. 1617 * @param { ActiveDeviceType } deviceType - Audio device type. 1618 * @returns { Promise<boolean> } Promise used to return the active status of the device. 1619 * @syscap SystemCapability.Multimedia.Audio.Device 1620 * @since 7 1621 * @deprecated since 9 1622 * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive 1623 */ 1624 isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean>; 1625 /** 1626 * Listens for system volume change events. This method uses a callback to get volume change events. 1627 * @param { 'volumeChange' } type - Type of the event to listen for. Only the volumeChange event is supported. 1628 * @param { Callback<VolumeEvent> } callback - Callback used to get the system volume change event. 1629 * @syscap SystemCapability.Multimedia.Audio.Volume 1630 * @systemapi 1631 * @since 8 1632 * @deprecated since 9 1633 * @useinstead ohos.multimedia.audio.AudioVolumeManager#event:volumeChange 1634 */ 1635 on(type: 'volumeChange', callback: Callback<VolumeEvent>): void; 1636 /** 1637 * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. 1638 * @param { 'ringerModeChange' } type - Type of the event to listen for. Only the ringerModeChange event is supported. 1639 * @param { Callback<AudioRingMode> } callback - Callback used to get the updated ringer mode. 1640 * @syscap SystemCapability.Multimedia.Audio.Communication 1641 * @systemapi 1642 * @since 8 1643 * @deprecated since 9 1644 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#event:ringerModeChange 1645 */ 1646 on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void; 1647 /** 1648 * Sets the audio scene mode to change audio strategies. This method uses an asynchronous callback to return the 1649 * result. 1650 * @param { AudioScene } scene - Audio scene mode. 1651 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1652 * @syscap SystemCapability.Multimedia.Audio.Communication 1653 * @systemapi 1654 * @since 8 1655 */ 1656 setAudioScene(scene: AudioScene, callback: AsyncCallback<void>): void; 1657 /** 1658 * Sets the audio scene mode to change audio strategies. This method uses a promise to return the result. 1659 * @param { AudioScene } scene - Audio scene mode. 1660 * @returns { Promise<void> } Promise used to return the result. 1661 * @syscap SystemCapability.Multimedia.Audio.Communication 1662 * @systemapi 1663 * @since 8 1664 */ 1665 setAudioScene(scene: AudioScene): Promise<void>; 1666 /** 1667 * Obtains the audio scene mode. This method uses an asynchronous callback to return the query result. 1668 * @param { AsyncCallback<AudioScene> } callback - Callback used to return the audio scene mode. 1669 * @syscap SystemCapability.Multimedia.Audio.Communication 1670 * @since 8 1671 */ 1672 getAudioScene(callback: AsyncCallback<AudioScene>): void; 1673 /** 1674 * Obtains the audio scene mode. This method uses a promise to return the query result. 1675 * @returns { Promise<AudioScene> } Promise used to return the audio scene mode. 1676 * @syscap SystemCapability.Multimedia.Audio.Communication 1677 * @since 8 1678 */ 1679 getAudioScene(): Promise<AudioScene>; 1680 /** 1681 * Obtains the audio scene mode. 1682 * @returns { AudioScene } Current audio scene mode. 1683 * @syscap SystemCapability.Multimedia.Audio.Communication 1684 * @since 10 1685 */ 1686 getAudioSceneSync(): AudioScene; 1687 1688 /** 1689 * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive 1690 * the callback. 1691 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 1692 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 1693 * @syscap SystemCapability.Multimedia.Audio.Device 1694 * @since 7 1695 * @deprecated since 9 1696 * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange 1697 */ 1698 on(type: 'deviceChange', callback: Callback<DeviceChangeAction>): void; 1699 1700 /** 1701 * UnSubscribes to device change events. 1702 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 1703 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 1704 * @syscap SystemCapability.Multimedia.Audio.Device 1705 * @since 7 1706 * @deprecated since 9 1707 * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange 1708 */ 1709 off(type: 'deviceChange', callback?: Callback<DeviceChangeAction>): void; 1710 1711 /** 1712 * Listens for audio interruption events. When the audio of an application is interrupted by another application, 1713 * the callback is invoked to notify the former application. 1714 * @param { 'interrupt' } type - Type of the event to listen for. Only the interrupt event is supported. 1715 * @param { AudioInterrupt } interrupt - Parameters of the audio interruption event type. 1716 * @param { Callback<InterruptAction> } callback - Callback invoked for the audio interruption event. 1717 * @syscap SystemCapability.Multimedia.Audio.Renderer 1718 * @since 7 1719 */ 1720 on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback<InterruptAction>): void; 1721 1722 /** 1723 * Cancels the listening of audio interruption events. 1724 * @param { 'interrupt' } type - Type of the event to listen for. Only the interrupt event is supported. 1725 * @param { AudioInterrupt } interrupt - Input parameters of the audio interruption event. 1726 * @param { Callback<InterruptAction> } callback - Callback invoked for the audio interruption event. 1727 * @syscap SystemCapability.Multimedia.Audio.Renderer 1728 * @since 7 1729 */ 1730 off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback<InterruptAction>): void; 1731 1732 /** 1733 * Obtains an {@link AudioVolumeManager} instance. 1734 * @returns { AudioVolumeManager } AudioVolumeManager instance. 1735 * @syscap SystemCapability.Multimedia.Audio.Volume 1736 * @since 9 1737 */ 1738 getVolumeManager(): AudioVolumeManager; 1739 1740 /** 1741 * Obtains an {@link AudioStreamManager} instance. 1742 * @returns { AudioStreamManager } AudioStreamManager instance. 1743 * @syscap SystemCapability.Multimedia.Audio.Core 1744 * @since 9 1745 */ 1746 getStreamManager(): AudioStreamManager; 1747 1748 /** 1749 * Obtains an {@link AudioRoutingManager} instance. 1750 * @returns { AudioRoutingManager } AudioRoutingManager instance. 1751 * @syscap SystemCapability.Multimedia.Audio.Device 1752 * @since 9 1753 */ 1754 getRoutingManager(): AudioRoutingManager; 1755 } 1756 1757 /** 1758 * Enumerates audio interrupt request result type. 1759 * @enum { number } 1760 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1761 * @systemapi 1762 * @since 9 1763 */ 1764 enum InterruptRequestResultType { 1765 /** 1766 * Request audio interrupt success 1767 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1768 * @systemapi 1769 * @since 9 1770 */ 1771 INTERRUPT_REQUEST_GRANT = 0, 1772 /** 1773 * Request audio interrupt fail, may have higher priority type 1774 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1775 * @systemapi 1776 * @since 9 1777 */ 1778 INTERRUPT_REQUEST_REJECT = 1 1779 } 1780 1781 /** 1782 * Describes audio interrupt operation results. 1783 * @typedef InterruptResult 1784 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1785 * @systemapi 1786 * @since 9 1787 */ 1788 interface InterruptResult { 1789 /** 1790 * Interrupt request or abandon result. 1791 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1792 * @systemapi 1793 * @since 9 1794 */ 1795 requestResult: InterruptRequestResultType; 1796 /** 1797 * Interrupt node as a unit to receive interrupt change event. 1798 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1799 * @systemapi 1800 * @since 9 1801 */ 1802 interruptNode: number; 1803 } 1804 1805 /** 1806 * Implements audio router management. 1807 * @typedef AudioRoutingManager 1808 * @syscap SystemCapability.Multimedia.Audio.Device 1809 * @since 9 1810 */ 1811 interface AudioRoutingManager { 1812 /** 1813 * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. 1814 * @param { DeviceFlag } deviceFlag - Audio device flag. 1815 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the device list. 1816 * @syscap SystemCapability.Multimedia.Audio.Device 1817 * @since 9 1818 */ 1819 getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void; 1820 /** 1821 * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. 1822 * @param { DeviceFlag } deviceFlag - Audio device flag. 1823 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the device list. 1824 * @syscap SystemCapability.Multimedia.Audio.Device 1825 * @since 9 1826 */ 1827 getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>; 1828 /** 1829 * Obtains the audio devices with a specific flag. 1830 * @param { DeviceFlag } deviceFlag - Audio device flag. 1831 * @returns { AudioDeviceDescriptors } The device list. 1832 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 1833 * @throws { BusinessError } 6800101 - Invalid parameter error. 1834 * @syscap SystemCapability.Multimedia.Audio.Device 1835 * @since 10 1836 */ 1837 getDevicesSync(deviceFlag: DeviceFlag): AudioDeviceDescriptors; 1838 1839 /** 1840 * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive 1841 * the callback. 1842 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 1843 * @param { DeviceFlag } deviceFlag - Audio device flag. 1844 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 1845 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1846 * @throws { BusinessError } 6800101 - if input parameter value error 1847 * @syscap SystemCapability.Multimedia.Audio.Device 1848 * @since 9 1849 */ 1850 on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback<DeviceChangeAction>): void; 1851 1852 /** 1853 * UnSubscribes to device change events. 1854 * @param { 'deviceChange' } type - Type of the event to listen for. Only the deviceChange event is supported. 1855 * @param { Callback<DeviceChangeAction> } callback - Callback used to obtain the device update details. 1856 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1857 * @throws { BusinessError } 6800101 - if input parameter value error 1858 * @syscap SystemCapability.Multimedia.Audio.Device 1859 * @since 9 1860 */ 1861 off(type: 'deviceChange', callback?: Callback<DeviceChangeAction>): void; 1862 1863 /** 1864 * Sets a device to the active state. This method uses an asynchronous callback to return the result. 1865 * @param { CommunicationDeviceType } deviceType - Audio device type. 1866 * @param { boolean } active - Active status to set. The value true means to set the device to 1867 * the active status, and false means the opposite. 1868 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1869 * @syscap SystemCapability.Multimedia.Audio.Communication 1870 * @since 9 1871 */ 1872 setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean, callback: AsyncCallback<void>): void; 1873 /** 1874 * Sets a device to the active state. This method uses a promise to return the result. 1875 * @param { CommunicationDeviceType } deviceType - Audio device type. 1876 * @param { boolean } active - Active status to set. The value true means to set the device to the active status, 1877 * and false means the opposite. 1878 * @returns { Promise<void> } Promise used to return the result. 1879 * @syscap SystemCapability.Multimedia.Audio.Communication 1880 * @since 9 1881 */ 1882 setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean): Promise<void>; 1883 1884 /** 1885 * Checks whether a device is active. This method uses an asynchronous callback to return the query result. 1886 * @param { CommunicationDeviceType } deviceType - Audio device type. 1887 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the device. 1888 * @syscap SystemCapability.Multimedia.Audio.Communication 1889 * @since 9 1890 */ 1891 isCommunicationDeviceActive(deviceType: CommunicationDeviceType, callback: AsyncCallback<boolean>): void; 1892 /** 1893 * Checks whether a device is active. This method uses a promise to return the query result. 1894 * @param { CommunicationDeviceType } deviceType - Audio device type. 1895 * @returns { Promise<boolean> } Promise used to return the active status of the device. 1896 * @syscap SystemCapability.Multimedia.Audio.Communication 1897 * @since 9 1898 */ 1899 isCommunicationDeviceActive(deviceType: CommunicationDeviceType): Promise<boolean>; 1900 /** 1901 * Checks whether a device is active. 1902 * @param { CommunicationDeviceType } deviceType - Audio device type. 1903 * @returns { boolean } The active status of the device. 1904 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 1905 * @throws { BusinessError } 6800101 - Invalid parameter error. 1906 * @syscap SystemCapability.Multimedia.Audio.Communication 1907 * @since 10 1908 */ 1909 isCommunicationDeviceActiveSync(deviceType: CommunicationDeviceType): boolean; 1910 1911 /** 1912 * Select the output device. This method uses an asynchronous callback to return the result. 1913 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description 1914 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1915 * @syscap SystemCapability.Multimedia.Audio.Device 1916 * @systemapi 1917 * @since 9 1918 */ 1919 selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 1920 /** 1921 * Select the output device. This method uses a promise to return the result. 1922 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description 1923 * @returns { Promise<void> } Promise used to return the result. 1924 * @syscap SystemCapability.Multimedia.Audio.Device 1925 * @systemapi 1926 * @since 9 1927 */ 1928 selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void>; 1929 1930 /** 1931 * Select the output device with desired AudioRenderer. This method uses an asynchronous callback to return the result. 1932 * @param { AudioRendererFilter } filter - Filter for AudioRenderer. 1933 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description. 1934 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1935 * @syscap SystemCapability.Multimedia.Audio.Device 1936 * @systemapi 1937 * @since 9 1938 */ 1939 selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 1940 /** 1941 * Select the output device with desired AudioRenderer. This method uses a promise to return the result. 1942 * @param { AudioRendererFilter } filter - Filter for AudioRenderer. 1943 * @param { AudioDeviceDescriptors } outputAudioDevices - Audio device description 1944 * @returns { Promise<void> } Promise used to return the result. 1945 * @syscap SystemCapability.Multimedia.Audio.Device 1946 * @systemapi 1947 * @since 9 1948 */ 1949 selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise<void>; 1950 1951 /** 1952 * Select the input device. This method uses an asynchronous callback to return the result. 1953 * @param { AudioDeviceDescriptors } inputAudioDevices - Audio device description 1954 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1955 * @syscap SystemCapability.Multimedia.Audio.Device 1956 * @systemapi 1957 * @since 9 1958 */ 1959 selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 1960 /** 1961 * Select the input device. This method uses a promise to return the result. 1962 * @param { AudioDeviceDescriptors } inputAudioDevices - Audio device description 1963 * @returns { Promise<void> } Promise used to return the result. 1964 * @syscap SystemCapability.Multimedia.Audio.Device 1965 * @systemapi 1966 * @since 9 1967 */ 1968 selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void>; 1969 1970 /** 1971 * Get output device for target audio renderer info. 1972 * @param { AudioRendererInfo } rendererInfo - Audio renderer information 1973 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 1974 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 1975 * @throws { BusinessError } 6800101 - Input parameter value error. Return by callback. 1976 * @throws { BusinessError } 6800301 - System error. Return by callback. 1977 * @syscap SystemCapability.Multimedia.Audio.Device 1978 * @since 10 1979 */ 1980 getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo, callback: AsyncCallback<AudioDeviceDescriptors>): void; 1981 /** 1982 * Get output device for target audio renderer info. 1983 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 1984 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 1985 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 1986 * @throws { BusinessError } 6800101 - Input parameter value error. Return by promise. 1987 * @throws { BusinessError } 6800301 - System error. Return by promise. 1988 * @syscap SystemCapability.Multimedia.Audio.Device 1989 * @since 10 1990 */ 1991 getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo): Promise<AudioDeviceDescriptors>; 1992 1993 /** 1994 * Gets preferred output device for target audio renderer info. 1995 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 1996 * @returns { AudioDeviceDescriptors } The preferred devices. 1997 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 1998 * @throws { BusinessError } 6800101 - Invalid parameter error. 1999 * @syscap SystemCapability.Multimedia.Audio.Device 2000 * @since 10 2001 */ 2002 getPreferredOutputDeviceForRendererInfoSync(rendererInfo: AudioRendererInfo): AudioDeviceDescriptors; 2003 2004 /** 2005 * Subscribes to prefer output device change events. When prefer device for target audio renderer info changes, 2006 * registered clients will receive the callback. 2007 * @param { 'preferOutputDeviceChangeForRendererInfo' } type - Type of the event to listen for. Only the 2008 * preferOutputDeviceChangeForRendererInfo event is supported. 2009 * @param { AudioRendererInfo } rendererInfo - Audio renderer information. 2010 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed prefer devices information. 2011 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2012 * @throws { BusinessError } 6800101 - Input parameter value error. 2013 * @syscap SystemCapability.Multimedia.Audio.Device 2014 * @since 10 2015 */ 2016 on(type: 'preferOutputDeviceChangeForRendererInfo', rendererInfo: AudioRendererInfo, callback: Callback<AudioDeviceDescriptors>): void; 2017 /** 2018 * UnSubscribes to prefer output device change events. 2019 * @param { 'preferOutputDeviceChangeForRendererInfo' } type - Type of the event to listen for. Only the 2020 * preferOutputDeviceChangeForRendererInfo event is supported. 2021 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed prefer devices in subscribe. 2022 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2023 * @throws { BusinessError } 6800101 - Input parameter value error. 2024 * @syscap SystemCapability.Multimedia.Audio.Device 2025 * @since 10 2026 */ 2027 off(type: 'preferOutputDeviceChangeForRendererInfo', callback?: Callback<AudioDeviceDescriptors>): void; 2028 2029 /** 2030 * Get input device for target audio capturer info. 2031 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 2032 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 2033 * @throws { BusinessError } 401 - If input parameter type or number mismatch. 2034 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by callback. 2035 * @throws { BusinessError } 6800301 - System error. Return by callback. 2036 * @syscap SystemCapability.Multimedia.Audio.Device 2037 * @since 10 2038 */ 2039 getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo, callback: AsyncCallback<AudioDeviceDescriptors>): void; 2040 /** 2041 * Get input device for target audio capturer info. 2042 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 2043 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 2044 * @throws { BusinessError } 401 - If input parameter type or number mismatch. 2045 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by promise. 2046 * @throws { BusinessError } 6800301 - System error. Return by promise. 2047 * @syscap SystemCapability.Multimedia.Audio.Device 2048 * @since 10 2049 */ 2050 getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo): Promise<AudioDeviceDescriptors>; 2051 2052 /** 2053 * Subscribes to preferred input device change events. When preferred device for target audio capturer info changes, 2054 * registered clients will receive the callback. 2055 * @param { 'preferredInputDeviceChangeForCapturerInfo' } type - Type of the event to listen for. 2056 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 2057 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed preferred devices information. 2058 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2059 * @throws { BusinessError } 6800101 - if input parameter value error 2060 * @syscap SystemCapability.Multimedia.Audio.Device 2061 * @since 10 2062 */ 2063 on(type: 'preferredInputDeviceChangeForCapturerInfo', capturerInfo: AudioCapturerInfo, callback: Callback<AudioDeviceDescriptors>): void; 2064 /** 2065 * Unsubscribes to preferred input device change events. 2066 * @param { 'preferredInputDeviceChangeForCapturerInfo' } type - Type of the event to listen for. 2067 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to obtain the changed preferred devices in subscribe. 2068 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2069 * @throws { BusinessError } 6800101 - if input parameter value error 2070 * @syscap SystemCapability.Multimedia.Audio.Device 2071 * @since 10 2072 */ 2073 off(type: 'preferredInputDeviceChangeForCapturerInfo', callback?: Callback<AudioDeviceDescriptors>): void; 2074 2075 /** 2076 * Gets preferred input device for target audio capturer info. 2077 * @param { AudioCapturerInfo } capturerInfo - Audio capturer information. 2078 * @returns { AudioDeviceDescriptors } The preferred devices. 2079 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2080 * @throws { BusinessError } 6800101 - Invalid parameter error. 2081 * @syscap SystemCapability.Multimedia.Audio.Device 2082 * @since 10 2083 */ 2084 getPreferredInputDeviceForCapturerInfoSync(capturerInfo: AudioCapturerInfo): AudioDeviceDescriptors; 2085 } 2086 2087 /** 2088 * Implements audio stream management. 2089 * @typedef AudioStreamManager 2090 * @syscap SystemCapability.Multimedia.Audio.Core 2091 * @since 9 2092 */ 2093 interface AudioStreamManager { 2094 /** 2095 * Get information of current existing audio renderers. 2096 * @param { AsyncCallback<AudioRendererChangeInfoArray> } callback - Callback used to return the information 2097 * of current existing audio renderers. 2098 * @syscap SystemCapability.Multimedia.Audio.Renderer 2099 * @since 9 2100 */ 2101 getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeInfoArray>): void; 2102 /** 2103 * Get information of current existing audio renderers. 2104 * @returns { Promise<AudioRendererChangeInfoArray> } Promise used to return the information of current 2105 * existing audio renderers. 2106 * @syscap SystemCapability.Multimedia.Audio.Renderer 2107 * @since 9 2108 */ 2109 getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray>; 2110 /** 2111 * Get information of current existing audio renderers. 2112 * @returns { AudioRendererChangeInfoArray } The information of current existing audio renderers. 2113 * @syscap SystemCapability.Multimedia.Audio.Renderer 2114 * @since 10 2115 */ 2116 getCurrentAudioRendererInfoArraySync(): AudioRendererChangeInfoArray; 2117 2118 /** 2119 * Get information of current existing audio capturers. 2120 * @param { AsyncCallback<AudioCapturerChangeInfoArray> } callback - Callback used to return the information 2121 * of current existing audio capturers. 2122 * @syscap SystemCapability.Multimedia.Audio.Renderer 2123 * @since 9 2124 */ 2125 getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeInfoArray>): void; 2126 /** 2127 * Get information of current existing audio capturers. 2128 * @returns { Promise<AudioCapturerChangeInfoArray> } Promise used to return the information of current existing 2129 * audio capturers. 2130 * @syscap SystemCapability.Multimedia.Audio.Renderer 2131 * @since 9 2132 */ 2133 getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray>; 2134 /** 2135 * Get information of current existing audio capturers. 2136 * @returns { AudioCapturerChangeInfoArray } The information of current existing audio capturers. 2137 * @syscap SystemCapability.Multimedia.Audio.Capturer 2138 * @since 10 2139 */ 2140 getCurrentAudioCapturerInfoArraySync(): AudioCapturerChangeInfoArray; 2141 2142 /** 2143 * Gets information of audio effects. 2144 * @param { StreamUsage } usage - Stream usage. 2145 * @param { AsyncCallback<AudioEffectInfoArray> } callback - Callback used to return the information of audio effects. 2146 * @throws { BusinessError } 401 - Parameter error. Return by callback. 2147 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by callback. 2148 * @syscap SystemCapability.Multimedia.Audio.Renderer 2149 * @since 10 2150 */ 2151 getAudioEffectInfoArray(usage: StreamUsage, callback: AsyncCallback<AudioEffectInfoArray>): void; 2152 /** 2153 * Gets information of audio effects. 2154 * @param { StreamUsage } usage - Stream usage. 2155 * @returns { Promise<AudioEffectInfoArray> } Promise used to return the information of audio effects. 2156 * @throws { BusinessError } 401 - Parameter error. Return by promise. 2157 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by promise. 2158 * @syscap SystemCapability.Multimedia.Audio.Renderer 2159 * @since 10 2160 */ 2161 getAudioEffectInfoArray(usage: StreamUsage): Promise<AudioEffectInfoArray>; 2162 /** 2163 * Gets information of audio effects. 2164 * @param { StreamUsage } usage - Stream usage. 2165 * @returns { AudioEffectInfoArray } The information of audio effects. 2166 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2167 * @throws { BusinessError } 6800101 - Invalid parameter error. 2168 * @syscap SystemCapability.Multimedia.Audio.Renderer 2169 * @since 10 2170 */ 2171 getAudioEffectInfoArraySync(usage: StreamUsage): AudioEffectInfoArray; 2172 2173 /** 2174 * Listens for audio renderer change events. When there is any audio renderer change, 2175 * registered clients will receive the callback. 2176 * @param { 'audioRendererChange' } type - Type of the event to listen for. Only the audioRendererChange event is supported. 2177 * @param { Callback<AudioRendererChangeInfoArray> } callback - Callback invoked for the audio renderer change event. 2178 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2179 * @throws { BusinessError } 6800101 - if input parameter value error 2180 * @syscap SystemCapability.Multimedia.Audio.Renderer 2181 * @since 9 2182 */ 2183 on(type: 'audioRendererChange', callback: Callback<AudioRendererChangeInfoArray>): void; 2184 2185 /** 2186 * UnSubscribes to audio renderer change events. 2187 * @param { 'audioRendererChange' } type - Type of the event to listen for. Only the audioRendererChange event is supported. 2188 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2189 * @throws { BusinessError } 6800101 - if input parameter value error 2190 * @syscap SystemCapability.Multimedia.Audio.Renderer 2191 * @since 9 2192 */ 2193 off(type: 'audioRendererChange'): void; 2194 2195 /** 2196 * Listens for audio capturer change events. When there is any audio capturer change, 2197 * registered clients will receive the callback. 2198 * @param { 'audioCapturerChange' } type - Type of the event to listen for. Only the audioCapturerChange event is supported. 2199 * @param { Callback<AudioCapturerChangeInfoArray> } callback - Callback invoked for the audio capturer change event. 2200 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2201 * @throws { BusinessError } 6800101 - if input parameter value error 2202 * @syscap SystemCapability.Multimedia.Audio.Capturer 2203 * @since 9 2204 */ 2205 on(type: 'audioCapturerChange', callback: Callback<AudioCapturerChangeInfoArray>): void; 2206 2207 /** 2208 * UnSubscribes to audio capturer change events. 2209 * @param { 'audioCapturerChange' } type - Type of the event to listen for. Only the audioCapturerChange event is supported. 2210 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2211 * @throws { BusinessError } 6800101 - if input parameter value error 2212 * @syscap SystemCapability.Multimedia.Audio.Capturer 2213 * @since 9 2214 */ 2215 off(type: 'audioCapturerChange'): void; 2216 2217 /** 2218 * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. 2219 * @param { AudioVolumeType } volumeType - Audio stream type. 2220 * @param { AsyncCallback<boolean> } callback - Callback used to return the active status of the stream. 2221 * The value true means that the stream is active, and false means the opposite. 2222 * @syscap SystemCapability.Multimedia.Audio.Renderer 2223 * @since 9 2224 */ 2225 isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 2226 /** 2227 * Checks whether a stream is active. This method uses a promise to return the query result. 2228 * @param { AudioVolumeType } volumeType - Audio stream type. 2229 * @returns { Promise<boolean> } Promise used to return the active status of the stream. The value 2230 * true means that the stream is active, and false means the opposite. 2231 * @syscap SystemCapability.Multimedia.Audio.Renderer 2232 * @since 9 2233 */ 2234 isActive(volumeType: AudioVolumeType): Promise<boolean>; 2235 /** 2236 * Checks whether a stream is active. 2237 * @param { AudioVolumeType } volumeType - Audio stream type. 2238 * @returns { boolean } The active status of the stream. 2239 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2240 * @throws { BusinessError } 6800101 - Invalid parameter error. 2241 * @syscap SystemCapability.Multimedia.Audio.Renderer 2242 * @since 10 2243 */ 2244 isActiveSync(volumeType: AudioVolumeType): boolean; 2245 } 2246 2247 /** 2248 * Implements audio volume management. 2249 * @typedef AudioVolumeManager 2250 * @syscap SystemCapability.Multimedia.Audio.Volume 2251 * @since 9 2252 */ 2253 interface AudioVolumeManager { 2254 /** 2255 * Get the volume group list for a networkId. This method uses an asynchronous callback to return the result. 2256 * @param { string } networkId - Distributed deice net work id 2257 * @param { AsyncCallback<VolumeGroupInfos> } callback - Callback used to return the result. 2258 * @syscap SystemCapability.Multimedia.Audio.Volume 2259 * @systemapi 2260 * @since 9 2261 */ 2262 getVolumeGroupInfos(networkId: string, callback: AsyncCallback<VolumeGroupInfos>): void; 2263 /** 2264 * Get the volume group list for a networkId. This method uses a promise to return the result. 2265 * @param { string } networkId - Distributed deice net work id 2266 * @returns { Promise<VolumeGroupInfos> } Promise used to return the result. 2267 * @syscap SystemCapability.Multimedia.Audio.Volume 2268 * @systemapi 2269 * @since 9 2270 */ 2271 getVolumeGroupInfos(networkId: string): Promise<VolumeGroupInfos>; 2272 /** 2273 * Get the volume group list for a networkId. 2274 * @param { string } networkId - Distributed deice net work id 2275 * @returns { VolumeGroupInfos } Volume group info list. 2276 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2277 * @throws { BusinessError } 6800101 - Invalid parameter error. 2278 * @syscap SystemCapability.Multimedia.Audio.Volume 2279 * @systemapi 2280 * @since 10 2281 */ 2282 getVolumeGroupInfosSync(networkId: string): VolumeGroupInfos; 2283 2284 /** 2285 * Obtains an AudioVolumeGroupManager instance. This method uses an asynchronous callback to return the result. 2286 * @param { number } groupId - volume group id, use LOCAL_VOLUME_GROUP_ID in default 2287 * @param { AsyncCallback<AudioVolumeGroupManager> } callback - Callback used to return the result. 2288 * @syscap SystemCapability.Multimedia.Audio.Volume 2289 * @since 9 2290 */ 2291 getVolumeGroupManager(groupId: number, callback: AsyncCallback<AudioVolumeGroupManager>): void; 2292 /** 2293 * Obtains an AudioVolumeGroupManager instance. This method uses a promise to return the result. 2294 * @param { number } groupId - volume group id, use LOCAL_VOLUME_GROUP_ID in default 2295 * @returns { Promise<AudioVolumeGroupManager> } Promise used to return the result. 2296 * @syscap SystemCapability.Multimedia.Audio.Volume 2297 * @since 9 2298 */ 2299 getVolumeGroupManager(groupId: number): Promise<AudioVolumeGroupManager>; 2300 /** 2301 * Obtains an AudioVolumeGroupManager instance. 2302 * @param { number } groupId - volume group id, use LOCAL_VOLUME_GROUP_ID in default 2303 * @returns { AudioVolumeGroupManager } The audio volume group manager instance. 2304 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2305 * @throws { BusinessError } 6800101 - Invalid parameter error. 2306 * @syscap SystemCapability.Multimedia.Audio.Volume 2307 * @since 10 2308 */ 2309 getVolumeGroupManagerSync(groupId: number): AudioVolumeGroupManager; 2310 2311 /** 2312 * Listens for system volume change events. This method uses a callback to get volume change events. 2313 * @param { 'volumeChange' } type - Type of the event to listen for. Only the volumeChange event is supported. 2314 * @param { Callback<VolumeEvent> } callback - Callback used to get the system volume change event. 2315 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2316 * @throws { BusinessError } 6800101 - if input parameter value error 2317 * @syscap SystemCapability.Multimedia.Audio.Volume 2318 * @since 9 2319 */ 2320 on(type: 'volumeChange', callback: Callback<VolumeEvent>): void; 2321 } 2322 2323 /** 2324 * Implements audio volume group management. 2325 * @typedef AudioVolumeGroupManager 2326 * @syscap SystemCapability.Multimedia.Audio.Volume 2327 * @since 9 2328 */ 2329 interface AudioVolumeGroupManager { 2330 /** 2331 * Sets the volume for a stream. This method uses an asynchronous callback to return the result. 2332 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2333 * @param { AudioVolumeType } volumeType - Audio stream type. 2334 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 2335 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2336 * @syscap SystemCapability.Multimedia.Audio.Volume 2337 * @systemapi 2338 * @since 9 2339 */ 2340 setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void; 2341 /** 2342 * Sets the volume for a stream. This method uses a promise to return the result. 2343 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2344 * @param { AudioVolumeType } volumeType - Audio stream type. 2345 * @param { number } volume - Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 2346 * @returns { Promise<void> } Promise used to return the result. 2347 * @syscap SystemCapability.Multimedia.Audio.Volume 2348 * @systemapi 2349 * @since 9 2350 */ 2351 setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>; 2352 2353 /** 2354 * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. 2355 * @param { AudioVolumeType } volumeType - Audio stream type. 2356 * @param { AsyncCallback<number> } callback - Callback used to return the volume. 2357 * @syscap SystemCapability.Multimedia.Audio.Volume 2358 * @since 9 2359 */ 2360 getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 2361 /** 2362 * Obtains the volume of a stream. This method uses a promise to return the query result. 2363 * @param { AudioVolumeType } volumeType - Audio stream type. 2364 * @returns { Promise<number> } Promise used to return the volume. 2365 * @syscap SystemCapability.Multimedia.Audio.Volume 2366 * @since 9 2367 */ 2368 getVolume(volumeType: AudioVolumeType): Promise<number>; 2369 /** 2370 * Obtains the volume of a stream. 2371 * @param { AudioVolumeType } volumeType - Audio stream type. 2372 * @returns { number } Current system volume level. 2373 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2374 * @throws { BusinessError } 6800101 - Invalid parameter error. 2375 * @syscap SystemCapability.Multimedia.Audio.Volume 2376 * @since 10 2377 */ 2378 getVolumeSync(volumeType: AudioVolumeType): number; 2379 2380 /** 2381 * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 2382 * @param { AudioVolumeType } volumeType - Audio stream type. 2383 * @param { AsyncCallback<number> } callback - Callback used to return the minimum volume. 2384 * @syscap SystemCapability.Multimedia.Audio.Volume 2385 * @since 9 2386 */ 2387 getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 2388 /** 2389 * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. 2390 * @param { AudioVolumeType } volumeType - Audio stream type. 2391 * @returns { Promise<number> } Promise used to return the minimum volume. 2392 * @syscap SystemCapability.Multimedia.Audio.Volume 2393 * @since 9 2394 */ 2395 getMinVolume(volumeType: AudioVolumeType): Promise<number>; 2396 /** 2397 * Obtains the minimum volume allowed for a stream. 2398 * @param { AudioVolumeType } volumeType - Audio stream type. 2399 * @returns { number } Min volume level. 2400 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2401 * @throws { BusinessError } 6800101 - Invalid parameter error. 2402 * @syscap SystemCapability.Multimedia.Audio.Volume 2403 * @since 10 2404 */ 2405 getMinVolumeSync(volumeType: AudioVolumeType): number; 2406 2407 /** 2408 * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 2409 * @param { AudioVolumeType } volumeType - Audio stream type. 2410 * @param { AsyncCallback<number> } callback - Callback used to return the maximum volume. 2411 * @syscap SystemCapability.Multimedia.Audio.Volume 2412 * @since 9 2413 */ 2414 getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 2415 /** 2416 * Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result. 2417 * @param { AudioVolumeType } volumeType - Audio stream type. 2418 * @returns { Promise<number> } Promise used to return the maximum volume. 2419 * @syscap SystemCapability.Multimedia.Audio.Volume 2420 * @since 9 2421 */ 2422 getMaxVolume(volumeType: AudioVolumeType): Promise<number>; 2423 /** 2424 * Obtains the maximum volume allowed for a stream. 2425 * @param { AudioVolumeType } volumeType - Audio stream type. 2426 * @returns { number } Max volume level. 2427 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2428 * @throws { BusinessError } 6800101 - Invalid parameter error. 2429 * @syscap SystemCapability.Multimedia.Audio.Volume 2430 * @since 10 2431 */ 2432 getMaxVolumeSync(volumeType: AudioVolumeType): number; 2433 2434 /** 2435 * Mutes a stream. This method uses an asynchronous callback to return the result. 2436 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2437 * @param { AudioVolumeType } volumeType - Audio stream type. 2438 * @param { boolean } mute - Mute status to set. The value true means to mute the stream, and false means the opposite. 2439 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2440 * @syscap SystemCapability.Multimedia.Audio.Volume 2441 * @systemapi 2442 * @since 9 2443 */ 2444 mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void; 2445 /** 2446 * Mutes a stream. This method uses a promise to return the result. 2447 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2448 * @param { AudioVolumeType } volumeType - Audio stream type. 2449 * @param { boolean } mute - Mute status to set. The value true means to mute the stream, and false means the opposite. 2450 * @returns { Promise<void> } Promise used to return the result. 2451 * @syscap SystemCapability.Multimedia.Audio.Volume 2452 * @systemapi 2453 * @since 9 2454 */ 2455 mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>; 2456 2457 /** 2458 * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. 2459 * @param { AudioVolumeType } volumeType - Audio stream type. 2460 * @param { AsyncCallback<boolean> } callback - Callback used to return the mute status of the stream. The 2461 * value true means that the stream is muted, and false means the opposite. 2462 * @syscap SystemCapability.Multimedia.Audio.Volume 2463 * @since 9 2464 */ 2465 isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 2466 /** 2467 * Checks whether a stream is muted. This method uses a promise to return the result. 2468 * @param { AudioVolumeType } volumeType - Audio stream type. 2469 * @returns { Promise<boolean> } Promise used to return the mute status of the stream. The value true 2470 * means that the stream is muted, and false means the opposite. 2471 * @syscap SystemCapability.Multimedia.Audio.Volume 2472 * @since 9 2473 */ 2474 isMute(volumeType: AudioVolumeType): Promise<boolean>; 2475 /** 2476 * Checks whether a stream is muted. 2477 * @param { AudioVolumeType } volumeType - Audio stream type. 2478 * @returns { boolean } The mute status of the stream. The value true 2479 * means that the stream is muted, and false means the opposite. 2480 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2481 * @throws { BusinessError } 6800101 - Invalid parameter error. 2482 * @syscap SystemCapability.Multimedia.Audio.Volume 2483 * @since 10 2484 */ 2485 isMuteSync(volumeType: AudioVolumeType): boolean; 2486 2487 /** 2488 * Sets the ringer mode. This method uses an asynchronous callback to return the result. 2489 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2490 * @param { AudioRingMode } mode - Ringer mode. 2491 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2492 * @syscap SystemCapability.Multimedia.Audio.Volume 2493 * @systemapi 2494 * @since 9 2495 */ 2496 setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void; 2497 /** 2498 * Sets the ringer mode. This method uses a promise to return the result. 2499 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2500 * @param { AudioRingMode } mode - Ringer mode. 2501 * @returns { Promise<void> } Promise used to return the result. 2502 * @syscap SystemCapability.Multimedia.Audio.Volume 2503 * @systemapi 2504 * @since 9 2505 */ 2506 setRingerMode(mode: AudioRingMode): Promise<void>; 2507 2508 /** 2509 * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. 2510 * @param { AsyncCallback<AudioRingMode> } callback - Callback used to return the ringer mode. 2511 * @syscap SystemCapability.Multimedia.Audio.Volume 2512 * @since 9 2513 */ 2514 getRingerMode(callback: AsyncCallback<AudioRingMode>): void; 2515 /** 2516 * Obtains the ringer mode. This method uses a promise to return the query result. 2517 * @returns { Promise<AudioRingMode> } Promise used to return the ringer mode. 2518 * @syscap SystemCapability.Multimedia.Audio.Volume 2519 * @since 9 2520 */ 2521 getRingerMode(): Promise<AudioRingMode>; 2522 /** 2523 * Obtains the ringer mode. 2524 * @returns { AudioRingMode } Current ringer mode. 2525 * @syscap SystemCapability.Multimedia.Audio.Volume 2526 * @since 10 2527 */ 2528 getRingerModeSync(): AudioRingMode; 2529 2530 /** 2531 * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. 2532 * @param { 'ringerModeChange' } type - Type of the event to listen for. Only the ringerModeChange event is supported. 2533 * @param { Callback<AudioRingMode> } callback - Callback used to get the updated ringer mode. 2534 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2535 * @throws { BusinessError } 6800101 - if input parameter value error 2536 * @syscap SystemCapability.Multimedia.Audio.Volume 2537 * @since 9 2538 */ 2539 on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void; 2540 2541 /** 2542 * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. 2543 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 2544 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 2545 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2546 * @syscap SystemCapability.Multimedia.Audio.Volume 2547 * @since 9 2548 */ 2549 setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void; 2550 /** 2551 * Mutes or unmutes the microphone. This method uses a promise to return the result. 2552 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 2553 * @param { boolean } mute - Mute status to set. The value true means to mute the microphone, and false means the opposite. 2554 * @returns { Promise<void> } Promise used to return the result. 2555 * @syscap SystemCapability.Multimedia.Audio.Volume 2556 * @since 9 2557 */ 2558 setMicrophoneMute(mute: boolean): Promise<void>; 2559 2560 /** 2561 * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. 2562 * @param { AsyncCallback<boolean> } callback - used to return the mute status of the microphone. The value 2563 * true means that the microphone is muted, and false means the opposite. 2564 * @syscap SystemCapability.Multimedia.Audio.Volume 2565 * @since 9 2566 */ 2567 isMicrophoneMute(callback: AsyncCallback<boolean>): void; 2568 /** 2569 * Checks whether the microphone is muted. This method uses a promise to return the query result. 2570 * @returns { Promise<boolean> } Promise used to return the mute status of the microphone. The value true 2571 * means that the microphone is muted, and false means the opposite. 2572 * @syscap SystemCapability.Multimedia.Audio.Volume 2573 * @since 9 2574 */ 2575 isMicrophoneMute(): Promise<boolean>; 2576 /** 2577 * Checks whether the microphone is muted. 2578 * @returns { boolean } The mute status of the microphone. The value true 2579 * means that the microphone is muted, and false means the opposite. 2580 * @syscap SystemCapability.Multimedia.Audio.Volume 2581 * @since 10 2582 */ 2583 isMicrophoneMuteSync(): boolean; 2584 2585 /** 2586 * Listens for system microphone state change events. This method uses a callback to get microphone change events. 2587 * @param { 'micStateChange' } type - Type of the event to listen for. Only the micStateChange event is supported. 2588 * @param { Callback<MicStateChangeEvent> } callback - Callback used to get the system microphone state change event. 2589 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2590 * @throws { BusinessError } 6800101 - if input parameter value error 2591 * @syscap SystemCapability.Multimedia.Audio.Volume 2592 * @since 9 2593 */ 2594 on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void; 2595 2596 /** 2597 * Gets if this volume group is volume unadjustable. 2598 * @returns { boolean } Whether it is volume unadjustable. 2599 * @syscap SystemCapability.Multimedia.Audio.Volume 2600 * @since 10 2601 */ 2602 isVolumeUnadjustable(): boolean; 2603 2604 /** 2605 * Adjusts system volume by step, volume type is decided by system. 2606 * This method uses an asynchronous callback to return the result. 2607 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2608 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 2609 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2610 * @throws { BusinessError } 201 - Permission denied. Return by callback. 2611 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2612 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by callback. 2613 * @throws { BusinessError } 6800301 - System error. Return by callback. 2614 * @syscap SystemCapability.Multimedia.Audio.Volume 2615 * @systemapi 2616 * @since 10 2617 */ 2618 adjustVolumeByStep(adjustType: VolumeAdjustType, callback: AsyncCallback<void>): void; 2619 /** 2620 * Adjusts system volume by step, volume type is decided by system. 2621 * This method uses a promise to return the result. 2622 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2623 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 2624 * @returns { Promise<void> } Promise used to return the result. 2625 * @throws { BusinessError } 201 - Permission denied. Return by promise. 2626 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2627 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by promise. 2628 * @throws { BusinessError } 6800301 - System error. Return by promise. 2629 * @syscap SystemCapability.Multimedia.Audio.Volume 2630 * @systemapi 2631 * @since 10 2632 */ 2633 adjustVolumeByStep(adjustType: VolumeAdjustType): Promise<void>; 2634 2635 /** 2636 * Adjusts system volume by step for target volume type. 2637 * This method uses an asynchronous callback to return the result. 2638 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2639 * @param { AudioVolumeType } volumeType - Audio volume type. 2640 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 2641 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2642 * @throws { BusinessError } 201 - Permission denied. Return by callback. 2643 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2644 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by callback. 2645 * @throws { BusinessError } 6800301 - System error. Return by callback. 2646 * @syscap SystemCapability.Multimedia.Audio.Volume 2647 * @systemapi 2648 * @since 10 2649 */ 2650 adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType, callback: AsyncCallback<void>): void; 2651 /** 2652 * Adjusts system volume by step for target volume type. 2653 * This method uses a promise to return the result. 2654 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2655 * @param { AudioVolumeType } volumeType - Audio volume type. 2656 * @param { VolumeAdjustType } adjustType - Volume adjustment type. 2657 * @returns { Promise<void> } Promise used to return the result. 2658 * @throws { BusinessError } 201 - Permission denied. Return by promise. 2659 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2660 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by promise. 2661 * @throws { BusinessError } 6800301 - System error. Return by promise. 2662 * @syscap SystemCapability.Multimedia.Audio.Volume 2663 * @systemapi 2664 * @since 10 2665 */ 2666 adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType): Promise<void>; 2667 2668 /** 2669 * Gets the volume db value that system calculate by volume type, volume level and device type. 2670 * This method uses an asynchronous callback to return the result. 2671 * @param { AudioVolumeType } volumeType - Audio volume type. 2672 * @param { number } volumeLevel - Volume level to set. 2673 * @param { DeviceType } device - Output device type. 2674 * @param { AsyncCallback<number> } callback - Callback used to return the result. 2675 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2676 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by callback. 2677 * @throws { BusinessError } 6800301 - System error. Return by callback. 2678 * @syscap SystemCapability.Multimedia.Audio.Volume 2679 * @since 10 2680 */ 2681 getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType, callback: AsyncCallback<number>): void; 2682 /** 2683 * Gets the volume db value that system calculate by volume type, volume level and device type. 2684 * This method uses a promise to return the result. 2685 * @param { AudioVolumeType } volumeType - Audio volume type. 2686 * @param { number } volumeLevel - Volume level to set. 2687 * @param { DeviceType } device - Output device type. 2688 * @returns { Promise<number> } Promise used to return the result. 2689 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2690 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by promise. 2691 * @throws { BusinessError } 6800301 - System error. Return by promise. 2692 * @syscap SystemCapability.Multimedia.Audio.Volume 2693 * @since 10 2694 */ 2695 getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType): Promise<number>; 2696 /** 2697 * Gets the volume db value that system calculate by volume type, volume level and device type. 2698 * @param { AudioVolumeType } volumeType - Audio volume type. 2699 * @param { number } volumeLevel - Volume level to set. 2700 * @param { DeviceType } device - Output device type. 2701 * @returns { number } The system volume in dB. 2702 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 2703 * @throws { BusinessError } 6800101 - Invalid parameter error. 2704 * @syscap SystemCapability.Multimedia.Audio.Volume 2705 * @since 10 2706 */ 2707 getSystemVolumeInDbSync(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType): number; 2708 } 2709 2710 /** 2711 * Describes an audio volume group. 2712 * @enum { number } 2713 * @syscap SystemCapability.Multimedia.Audio.Volume 2714 * @systemapi 2715 * @since 9 2716 */ 2717 enum ConnectType { 2718 /** 2719 * Connect type for local device. 2720 * @syscap SystemCapability.Multimedia.Audio.Volume 2721 * @systemapi 2722 * @since 9 2723 */ 2724 CONNECT_TYPE_LOCAL = 1, 2725 2726 /** 2727 * Connect type for distributed device. 2728 * @syscap SystemCapability.Multimedia.Audio.Volume 2729 * @systemapi 2730 * @since 9 2731 */ 2732 CONNECT_TYPE_DISTRIBUTED = 2 2733 } 2734 2735 /** 2736 * Describes an audio volume group. 2737 * @typedef VolumeGroupInfo 2738 * @syscap SystemCapability.Multimedia.Audio.Volume 2739 * @systemapi 2740 * @since 9 2741 */ 2742 interface VolumeGroupInfo { 2743 /** 2744 * Device network id. 2745 * @syscap SystemCapability.Multimedia.Audio.Volume 2746 * @systemapi 2747 * @since 9 2748 */ 2749 readonly networkId: string; 2750 2751 /** 2752 * Volume group id. 2753 * @syscap SystemCapability.Multimedia.Audio.Volume 2754 * @systemapi 2755 * @since 9 2756 */ 2757 readonly groupId: number; 2758 2759 /** 2760 * Volume mapping group id. 2761 * @syscap SystemCapability.Multimedia.Audio.Volume 2762 * @systemapi 2763 * @since 9 2764 */ 2765 readonly mappingId: number; 2766 2767 /** 2768 * Volume group name. 2769 * @syscap SystemCapability.Multimedia.Audio.Volume 2770 * @systemapi 2771 * @since 9 2772 */ 2773 readonly groupName: string; 2774 2775 /** 2776 * Connect type of device for this group. 2777 * @syscap SystemCapability.Multimedia.Audio.Volume 2778 * @systemapi 2779 * @since 9 2780 */ 2781 readonly type: ConnectType; 2782 } 2783 2784 /** 2785 * Array of VolumeGroupInfos, which is read-only. 2786 * @syscap SystemCapability.Multimedia.Audio.Volume 2787 * @systemapi 2788 * @since 9 2789 */ 2790 type VolumeGroupInfos = Array<Readonly<VolumeGroupInfo>>; 2791 2792 /** 2793 * Array of AudioRendererChangeInfo, which is read-only. 2794 * @syscap SystemCapability.Multimedia.Audio.Renderer 2795 * @since 9 2796 */ 2797 type AudioRendererChangeInfoArray = Array<Readonly<AudioRendererChangeInfo>>; 2798 2799 /** 2800 * Describes audio renderer change information. 2801 * @typedef AudioRendererChangeInfo 2802 * @syscap SystemCapability.Multimedia.Audio.Renderer 2803 * @since 9 2804 */ 2805 interface AudioRendererChangeInfo { 2806 /** 2807 * Audio stream unique id. 2808 * @syscap SystemCapability.Multimedia.Audio.Renderer 2809 * @since 9 2810 */ 2811 readonly streamId: number; 2812 2813 /** 2814 * Uid for audio renderer client application. 2815 * @syscap SystemCapability.Multimedia.Audio.Renderer 2816 * @systemapi 2817 * @since 9 2818 */ 2819 readonly clientUid: number; 2820 2821 /** 2822 * Audio renderer information. 2823 * @syscap SystemCapability.Multimedia.Audio.Renderer 2824 * @since 9 2825 */ 2826 readonly rendererInfo: AudioRendererInfo; 2827 2828 /** 2829 * Audio state. 2830 * @syscap SystemCapability.Multimedia.Audio.Renderer 2831 * @systemapi 2832 * @since 9 2833 */ 2834 readonly rendererState: AudioState; 2835 2836 /** 2837 * Audio output devices. 2838 * @syscap SystemCapability.Multimedia.Audio.Renderer 2839 * @since 9 2840 */ 2841 readonly deviceDescriptors: AudioDeviceDescriptors; 2842 } 2843 2844 /** 2845 * Array of AudioCapturerChangeInfo, which is read-only. 2846 * @syscap SystemCapability.Multimedia.Audio.Capturer 2847 * @since 9 2848 */ 2849 type AudioCapturerChangeInfoArray = Array<Readonly<AudioCapturerChangeInfo>>; 2850 2851 /** 2852 * Describes audio capturer change information. 2853 * @typedef AudioCapturerChangeInfo 2854 * @syscap SystemCapability.Multimedia.Audio.Capturer 2855 * @since 9 2856 */ 2857 interface AudioCapturerChangeInfo { 2858 /** 2859 * Audio stream unique id. 2860 * @syscap SystemCapability.Multimedia.Audio.Capturer 2861 * @since 9 2862 */ 2863 readonly streamId: number; 2864 2865 /** 2866 * Uid for audio capturer client application. 2867 * @syscap SystemCapability.Multimedia.Audio.Capturer 2868 * @systemapi 2869 * @since 9 2870 */ 2871 readonly clientUid: number; 2872 2873 /** 2874 * Audio capturer information. 2875 * @syscap SystemCapability.Multimedia.Audio.Capturer 2876 * @since 9 2877 */ 2878 readonly capturerInfo: AudioCapturerInfo; 2879 2880 /** 2881 * Audio state. 2882 * @syscap SystemCapability.Multimedia.Audio.Capturer 2883 * @systemapi 2884 * @since 9 2885 */ 2886 readonly capturerState: AudioState; 2887 2888 /** 2889 * Audio input devices. 2890 * @syscap SystemCapability.Multimedia.Audio.Capturer 2891 * @since 9 2892 */ 2893 readonly deviceDescriptors: AudioDeviceDescriptors; 2894 } 2895 2896 /** 2897 * Describes an audio device. 2898 * @typedef AudioDeviceDescriptor 2899 * @syscap SystemCapability.Multimedia.Audio.Device 2900 * @since 7 2901 */ 2902 interface AudioDeviceDescriptor { 2903 /** 2904 * Audio device role. 2905 * @syscap SystemCapability.Multimedia.Audio.Device 2906 * @since 7 2907 */ 2908 readonly deviceRole: DeviceRole; 2909 2910 /** 2911 * Audio device type. 2912 * @syscap SystemCapability.Multimedia.Audio.Device 2913 * @since 7 2914 */ 2915 readonly deviceType: DeviceType; 2916 2917 /** 2918 * Audio device id. 2919 * @syscap SystemCapability.Multimedia.Audio.Device 2920 * @since 9 2921 */ 2922 readonly id: number; 2923 2924 /** 2925 * Audio device name. 2926 * @syscap SystemCapability.Multimedia.Audio.Device 2927 * @since 9 2928 */ 2929 readonly name: string; 2930 2931 /** 2932 * Audio device address. 2933 * @syscap SystemCapability.Multimedia.Audio.Device 2934 * @since 9 2935 */ 2936 readonly address: string; 2937 2938 /** 2939 * Supported sampling rates. 2940 * @syscap SystemCapability.Multimedia.Audio.Device 2941 * @since 9 2942 */ 2943 readonly sampleRates: Array<number>; 2944 2945 /** 2946 * Supported channel counts. 2947 * @syscap SystemCapability.Multimedia.Audio.Device 2948 * @since 9 2949 */ 2950 readonly channelCounts: Array<number>; 2951 2952 /** 2953 * Supported channel masks. 2954 * @syscap SystemCapability.Multimedia.Audio.Device 2955 * @since 9 2956 */ 2957 readonly channelMasks: Array<number>; 2958 /** 2959 * Device network id 2960 * @syscap SystemCapability.Multimedia.Audio.Device 2961 * @systemapi 2962 * @since 9 2963 */ 2964 readonly networkId: string; 2965 /** 2966 * Interrupt group id 2967 * @syscap SystemCapability.Multimedia.Audio.Device 2968 * @systemapi 2969 * @since 9 2970 */ 2971 readonly interruptGroupId: number; 2972 /** 2973 * Volume group id 2974 * @syscap SystemCapability.Multimedia.Audio.Device 2975 * @systemapi 2976 * @since 9 2977 */ 2978 readonly volumeGroupId: number; 2979 /** 2980 * Name used to display, considering distributed device situation. 2981 * @syscap SystemCapability.Multimedia.Audio.Device 2982 * @since 10 2983 */ 2984 readonly displayName: string; 2985 } 2986 2987 /** 2988 * Array of AudioDeviceDescriptors, which is read-only. 2989 * @syscap SystemCapability.Multimedia.Audio.Device 2990 * @since 7 2991 */ 2992 type AudioDeviceDescriptors = Array<Readonly<AudioDeviceDescriptor>>; 2993 2994 /** 2995 * Describes the volume event received by the app when the volume is changed. 2996 * @typedef VolumeEvent 2997 * @syscap SystemCapability.Multimedia.Audio.Volume 2998 * @since 9 2999 */ 3000 interface VolumeEvent { 3001 /** 3002 * Volume type of the current stream. 3003 * @syscap SystemCapability.Multimedia.Audio.Volume 3004 * @since 9 3005 */ 3006 volumeType: AudioVolumeType; 3007 /** 3008 * Volume level. 3009 * @syscap SystemCapability.Multimedia.Audio.Volume 3010 * @since 9 3011 */ 3012 volume: number; 3013 /** 3014 * Whether to show the volume change in UI. 3015 * @syscap SystemCapability.Multimedia.Audio.Volume 3016 * @since 9 3017 */ 3018 updateUi: boolean; 3019 /** 3020 * volumeGroup id 3021 * @syscap SystemCapability.Multimedia.Audio.Volume 3022 * @systemapi 3023 * @since 9 3024 */ 3025 volumeGroupId: number; 3026 /** 3027 * Device network id 3028 * @syscap SystemCapability.Multimedia.Audio.Volume 3029 * @systemapi 3030 * @since 9 3031 */ 3032 networkId: string; 3033 } 3034 3035 /** 3036 * Describes the callback invoked for audio interruption or focus gain events.When the audio of an application 3037 * is interrupted by another application, the callback is invoked to notify the former application. 3038 * @typedef InterruptAction 3039 * @syscap SystemCapability.Multimedia.Audio.Renderer 3040 * @since 7 3041 * @deprecated since 9 3042 * @useinstead ohos.multimedia.audio.InterruptEvent 3043 */ 3044 interface InterruptAction { 3045 3046 /** 3047 * Event type. 3048 * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. 3049 * @syscap SystemCapability.Multimedia.Audio.Renderer 3050 * @since 7 3051 * @deprecated since 9 3052 */ 3053 actionType: InterruptActionType; 3054 3055 /** 3056 * Type of the audio interruption event. 3057 * @syscap SystemCapability.Multimedia.Audio.Renderer 3058 * @since 7 3059 * @deprecated since 9 3060 */ 3061 type?: InterruptType; 3062 3063 /** 3064 * Hint for the audio interruption event. 3065 * @syscap SystemCapability.Multimedia.Audio.Renderer 3066 * @since 7 3067 * @deprecated since 9 3068 */ 3069 hint?: InterruptHint; 3070 3071 /** 3072 * Whether the focus is gained or released. The value true means that the focus is gained or released, 3073 * and false means that the focus fails to be gained or released. 3074 * @syscap SystemCapability.Multimedia.Audio.Renderer 3075 * @since 7 3076 * @deprecated since 9 3077 */ 3078 activated?: boolean; 3079 } 3080 3081 /** 3082 * Describes input parameters of audio listening events. 3083 * @typedef AudioInterrupt 3084 * @syscap SystemCapability.Multimedia.Audio.Renderer 3085 * @since 7 3086 * @deprecated since 9 3087 */ 3088 interface AudioInterrupt { 3089 3090 /** 3091 * Audio stream usage type. 3092 * @syscap SystemCapability.Multimedia.Audio.Renderer 3093 * @since 7 3094 * @deprecated since 9 3095 */ 3096 streamUsage: StreamUsage; 3097 3098 /** 3099 * Type of the media interrupted. 3100 * @syscap SystemCapability.Multimedia.Audio.Renderer 3101 * @since 7 3102 * @deprecated since 9 3103 */ 3104 contentType: ContentType; 3105 3106 /** 3107 * Whether audio playback can be paused when it is interrupted. 3108 * The value true means that audio playback can be paused when it is interrupted, and false means the opposite. 3109 * @syscap SystemCapability.Multimedia.Audio.Renderer 3110 * @since 7 3111 * @deprecated since 9 3112 */ 3113 pauseWhenDucked: boolean; 3114 } 3115 3116 /** 3117 * Describes the microphone state change event received by the app when the microphone state is changed. 3118 * @typedef MicStateChangeEvent 3119 * @syscap SystemCapability.Multimedia.Audio.Device 3120 * @since 9 3121 */ 3122 interface MicStateChangeEvent { 3123 /** 3124 * Mic mute state. 3125 * @syscap SystemCapability.Multimedia.Audio.Device 3126 * @since 9 3127 */ 3128 mute: boolean; 3129 } 3130 /** 3131 * Describes the device change type and device information. 3132 * @typedef DeviceChangeAction 3133 * @syscap SystemCapability.Multimedia.Audio.Device 3134 * @since 7 3135 */ 3136 interface DeviceChangeAction { 3137 /** 3138 * Device change type. 3139 * @syscap SystemCapability.Multimedia.Audio.Device 3140 * @since 7 3141 */ 3142 type: DeviceChangeType; 3143 3144 /** 3145 * Device information. 3146 * @syscap SystemCapability.Multimedia.Audio.Device 3147 * @since 7 3148 */ 3149 deviceDescriptors: AudioDeviceDescriptors; 3150 } 3151 3152 /** 3153 * Provides audio playback APIs. 3154 * @typedef AudioRenderer 3155 * @syscap SystemCapability.Multimedia.Audio.Renderer 3156 * @since 8 3157 */ 3158 interface AudioRenderer { 3159 /** 3160 * Defines the current render state. 3161 * @syscap SystemCapability.Multimedia.Audio.Renderer 3162 * @since 8 3163 */ 3164 readonly state: AudioState; 3165 3166 /** 3167 * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous 3168 * callback to return the result. 3169 * @param { AsyncCallback<AudioRendererInfo> } callback - Callback used to return the renderer information. 3170 * @syscap SystemCapability.Multimedia.Audio.Renderer 3171 * @since 8 3172 */ 3173 getRendererInfo(callback: AsyncCallback<AudioRendererInfo>): void; 3174 /** 3175 * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to 3176 * return the result. 3177 * @returns { Promise<AudioRendererInfo> } Promise used to return the renderer information. 3178 * @syscap SystemCapability.Multimedia.Audio.Renderer 3179 * @since 8 3180 */ 3181 getRendererInfo(): Promise<AudioRendererInfo>; 3182 /** 3183 * Obtains the renderer information provided while creating a renderer instance. 3184 * @returns { AudioRendererInfo } The renderer information. 3185 * @syscap SystemCapability.Multimedia.Audio.Renderer 3186 * @since 10 3187 */ 3188 getRendererInfoSync(): AudioRendererInfo; 3189 3190 /** 3191 * Obtains the renderer stream information. This method uses an asynchronous callback to return the result. 3192 * @param { AsyncCallback<AudioStreamInfo> } callback - Callback used to return the stream information. 3193 * @syscap SystemCapability.Multimedia.Audio.Renderer 3194 * @since 8 3195 */ 3196 getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void; 3197 /** 3198 * Obtains the renderer stream information. This method uses a promise to return the result. 3199 * @returns { Promise<AudioStreamInfo> } Promise used to return the stream information. 3200 * @syscap SystemCapability.Multimedia.Audio.Renderer 3201 * @since 8 3202 */ 3203 getStreamInfo(): Promise<AudioStreamInfo>; 3204 /** 3205 * Obtains the renderer stream information. 3206 * @returns { AudioStreamInfo } The stream information. 3207 * @syscap SystemCapability.Multimedia.Audio.Renderer 3208 * @since 10 3209 */ 3210 getStreamInfoSync(): AudioStreamInfo; 3211 3212 /** 3213 * Obtains the renderer stream id. This method uses an asynchronous callback to return the result. 3214 * @param { AsyncCallback<number> } callback - Callback used to return the stream id. 3215 * @syscap SystemCapability.Multimedia.Audio.Renderer 3216 * @since 9 3217 */ 3218 getAudioStreamId(callback: AsyncCallback<number>): void; 3219 /** 3220 * Obtains the renderer stream id. This method uses a promise to return the result. 3221 * @returns { Promise<number> } Promise used to return the stream id. 3222 * @syscap SystemCapability.Multimedia.Audio.Renderer 3223 * @since 9 3224 */ 3225 getAudioStreamId(): Promise<number>; 3226 /** 3227 * Obtains the renderer stream id. 3228 * @returns { number } The stream id. 3229 * @syscap SystemCapability.Multimedia.Audio.Renderer 3230 * @since 10 3231 */ 3232 getAudioStreamIdSync(): number; 3233 3234 /** 3235 * Obtains the current audio effect mode. This method uses an asynchronous callback to return the query result. 3236 * @param { AsyncCallback<AudioEffectMode> } callback - Callback used to return the current audio effect mode. 3237 * @syscap SystemCapability.Multimedia.Audio.Renderer 3238 * @since 10 3239 */ 3240 getAudioEffectMode(callback: AsyncCallback<AudioEffectMode>): void; 3241 /** 3242 * Obtains the current audio effect mode. This method uses a promise to return the query result. 3243 * @returns { Promise<AudioEffectMode> } Promise used to return the current audio effect mode. 3244 * @syscap SystemCapability.Multimedia.Audio.Renderer 3245 * @since 10 3246 */ 3247 getAudioEffectMode(): Promise<AudioEffectMode>; 3248 3249 /** 3250 * Sets the current audio effect mode. This method uses an asynchronous callback to return the result. 3251 * @param { AudioEffectMode } mode - Audio effect mode. 3252 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3253 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 3254 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by callback. 3255 * @syscap SystemCapability.Multimedia.Audio.Renderer 3256 * @since 10 3257 */ 3258 setAudioEffectMode(mode: AudioEffectMode, callback: AsyncCallback<void>): void; 3259 /** 3260 * Sets the current audio effect mode. This method uses a promise to return the result. 3261 * @param { AudioEffectMode } mode - Audio effect mode. 3262 * @returns { Promise<void> } Promise used to return the result. 3263 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 3264 * @throws { BusinessError } 6800101 - Invalid parameter error. Return by promise. 3265 * @syscap SystemCapability.Multimedia.Audio.Renderer 3266 * @since 10 3267 */ 3268 setAudioEffectMode(mode: AudioEffectMode): Promise<void>; 3269 3270 /** 3271 * Starts the renderer. This method uses an asynchronous callback to return the result. 3272 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3273 * @syscap SystemCapability.Multimedia.Audio.Renderer 3274 * @since 8 3275 */ 3276 start(callback: AsyncCallback<void>): void; 3277 /** 3278 * Starts the renderer. This method uses a promise to return the result. 3279 * @returns { Promise<void> } Promise used to return the result. 3280 * @syscap SystemCapability.Multimedia.Audio.Renderer 3281 * @since 8 3282 */ 3283 start(): Promise<void>; 3284 3285 /** 3286 * Writes the buffer. This method uses an asynchronous callback to return the result. 3287 * @param { ArrayBuffer } buffer - Buffer to be written. 3288 * @param { AsyncCallback<number> } callback - Returns the number of bytes written if the operation is successful. 3289 * Returns an error code otherwise. 3290 * @syscap SystemCapability.Multimedia.Audio.Renderer 3291 * @since 8 3292 */ 3293 write(buffer: ArrayBuffer, callback: AsyncCallback<number>): void; 3294 /** 3295 * Writes the buffer. This method uses a promise to return the result. 3296 * @param { ArrayBuffer } buffer - Buffer to be written. 3297 * @returns { Promise<number> } Returns the number of bytes written if the operation is successful. 3298 * Returns an error code otherwise. 3299 * @syscap SystemCapability.Multimedia.Audio.Renderer 3300 * @since 8 3301 */ 3302 write(buffer: ArrayBuffer): Promise<number>; 3303 3304 /** 3305 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an 3306 * asynchronous callback to return the result. 3307 * @param { AsyncCallback<number> } callback - Callback used to return the timestamp. 3308 * @syscap SystemCapability.Multimedia.Audio.Renderer 3309 * @since 8 3310 */ 3311 getAudioTime(callback: AsyncCallback<number>): void; 3312 /** 3313 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a 3314 * promise to return the result. 3315 * @returns { Promise<number> } Promise used to return the timestamp. 3316 * @syscap SystemCapability.Multimedia.Audio.Renderer 3317 * @since 8 3318 */ 3319 getAudioTime(): Promise<number>; 3320 /** 3321 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. 3322 * @returns { number } The audio timestamp. 3323 * @syscap SystemCapability.Multimedia.Audio.Renderer 3324 * @since 10 3325 */ 3326 getAudioTimeSync(): number; 3327 3328 /** 3329 * Drains the playback buffer. This method uses an asynchronous callback to return the result. 3330 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3331 * @syscap SystemCapability.Multimedia.Audio.Renderer 3332 * @since 8 3333 */ 3334 drain(callback: AsyncCallback<void>): void; 3335 /** 3336 * Drains the playback buffer. This method uses a promise to return the result. 3337 * @returns { Promise<void> } Promise used to return the result. 3338 * @syscap SystemCapability.Multimedia.Audio.Renderer 3339 * @since 8 3340 */ 3341 drain(): Promise<void>; 3342 3343 /** 3344 * Pauses rendering. This method uses an asynchronous callback to return the result. 3345 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3346 * @syscap SystemCapability.Multimedia.Audio.Renderer 3347 * @since 8 3348 */ 3349 pause(callback: AsyncCallback<void>): void; 3350 /** 3351 * Pauses rendering. This method uses a promise to return the result. 3352 * @returns { Promise<void> } Promise used to return the result. 3353 * @syscap SystemCapability.Multimedia.Audio.Renderer 3354 * @since 8 3355 */ 3356 pause(): Promise<void>; 3357 3358 /** 3359 * Stops rendering. This method uses an asynchronous callback to return the result. 3360 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3361 * @syscap SystemCapability.Multimedia.Audio.Renderer 3362 * @since 8 3363 */ 3364 stop(callback: AsyncCallback<void>): void; 3365 /** 3366 * Stops rendering. This method uses a promise to return the result. 3367 * @returns { Promise<void> } Promise used to return the result. 3368 * @syscap SystemCapability.Multimedia.Audio.Renderer 3369 * @since 8 3370 */ 3371 stop(): Promise<void>; 3372 3373 /** 3374 * Releases the renderer. This method uses an asynchronous callback to return the result. 3375 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3376 * @syscap SystemCapability.Multimedia.Audio.Renderer 3377 * @since 8 3378 */ 3379 release(callback: AsyncCallback<void>): void; 3380 /** 3381 * Releases the renderer. This method uses a promise to return the result. 3382 * @returns { Promise<void> } Promise used to return the result. 3383 * @syscap SystemCapability.Multimedia.Audio.Renderer 3384 * @since 8 3385 */ 3386 release(): Promise<void>; 3387 3388 /** 3389 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to 3390 * return the result. 3391 * @param { AsyncCallback<number> } callback - Callback used to return the buffer size. 3392 * @syscap SystemCapability.Multimedia.Audio.Renderer 3393 * @since 8 3394 */ 3395 getBufferSize(callback: AsyncCallback<number>): void; 3396 /** 3397 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result. 3398 * @returns { Promise<number> } Promise used to return the buffer size. 3399 * @syscap SystemCapability.Multimedia.Audio.Renderer 3400 * @since 8 3401 */ 3402 getBufferSize(): Promise<number>; 3403 /** 3404 * Obtains a reasonable minimum buffer size in bytes for rendering. 3405 * @returns { number } The audio buffer size. 3406 * @syscap SystemCapability.Multimedia.Audio.Renderer 3407 * @since 10 3408 */ 3409 getBufferSizeSync(): number; 3410 3411 /** 3412 * Sets the render rate. This method uses an asynchronous callback to return the result. 3413 * @param { AudioRendererRate } rate - Audio render rate. 3414 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3415 * @syscap SystemCapability.Multimedia.Audio.Renderer 3416 * @since 8 3417 */ 3418 setRenderRate(rate: AudioRendererRate, callback: AsyncCallback<void>): void; 3419 /** 3420 * Sets the render rate. This method uses a promise to return the result. 3421 * @param { AudioRendererRate } rate - Audio render rate. 3422 * @returns { Promise<void> } Promise used to return the result. 3423 * @syscap SystemCapability.Multimedia.Audio.Renderer 3424 * @since 8 3425 */ 3426 setRenderRate(rate: AudioRendererRate): Promise<void>; 3427 3428 /** 3429 * Obtains the current render rate. This method uses an asynchronous callback to return the result. 3430 * @param { AsyncCallback<AudioRendererRate> } callback - Callback used to return the audio render rate. 3431 * @syscap SystemCapability.Multimedia.Audio.Renderer 3432 * @since 8 3433 */ 3434 getRenderRate(callback: AsyncCallback<AudioRendererRate>): void; 3435 /** 3436 * Obtains the current render rate. This method uses a promise to return the result. 3437 * @returns { Promise<AudioRendererRate> } Promise used to return the audio render rate. 3438 * @syscap SystemCapability.Multimedia.Audio.Renderer 3439 * @since 8 3440 */ 3441 getRenderRate(): Promise<AudioRendererRate>; 3442 /** 3443 * Obtains the current render rate. 3444 * @returns { AudioRendererRate } The audio render rate. 3445 * @syscap SystemCapability.Multimedia.Audio.Renderer 3446 * @since 10 3447 */ 3448 getRenderRateSync(): AudioRendererRate; 3449 3450 /** 3451 * Set interrupt mode. 3452 * @param { InterruptMode } mode - The interrupt mode. 3453 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3454 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3455 * @since 9 3456 */ 3457 setInterruptMode(mode: InterruptMode, callback: AsyncCallback<void>): void; 3458 /** 3459 * Set interrupt mode. 3460 * @param { InterruptMode } mode - The interrupt mode. 3461 * @returns { Promise<void> } Promise used to return the result. 3462 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3463 * @since 9 3464 */ 3465 setInterruptMode(mode: InterruptMode): Promise<void>; 3466 /** 3467 * Set interrupt mode. 3468 * @param { InterruptMode } mode - The interrupt mode. 3469 * @throws { BusinessError } 401 - Input parameter type or number mismatch. 3470 * @throws { BusinessError } 6800101 - Invalid parameter error. 3471 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3472 * @since 10 3473 */ 3474 setInterruptModeSync(mode: InterruptMode): void; 3475 3476 /** 3477 * Sets the volume for this stream. This method uses an asynchronous callback to return the result. 3478 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 3479 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3480 * @syscap SystemCapability.Multimedia.Audio.Renderer 3481 * @since 9 3482 */ 3483 setVolume(volume: number, callback: AsyncCallback<void>): void; 3484 /** 3485 * Sets the volume for a stream. This method uses a promise to return the result. 3486 * @param { number } volume - Volume to set. The value type is float, form 0.0 to 1.0. 3487 * @returns { Promise<void> } Promise used to return the result. 3488 * @syscap SystemCapability.Multimedia.Audio.Renderer 3489 * @since 9 3490 */ 3491 setVolume(volume: number): Promise<void>; 3492 3493 /** 3494 * Gets the min volume this stream can set. This method uses an asynchronous callback to return the result. 3495 * @param { AsyncCallback<number> } callback - Callback used to return the result. 3496 * @syscap SystemCapability.Multimedia.Audio.Renderer 3497 * @since 10 3498 */ 3499 getMinStreamVolume(callback: AsyncCallback<number>): void; 3500 /** 3501 * Gets the min volume this stream can set. This method uses a promise to return the result. 3502 * @returns { Promise<number> } Promise used to return the result. 3503 * @syscap SystemCapability.Multimedia.Audio.Renderer 3504 * @since 10 3505 */ 3506 getMinStreamVolume(): Promise<number>; 3507 /** 3508 * Gets the min volume this stream can set. 3509 * @returns { number } Min stream volume. 3510 * @syscap SystemCapability.Multimedia.Audio.Renderer 3511 * @since 10 3512 */ 3513 getMinStreamVolumeSync(): number; 3514 3515 /** 3516 * Gets the max volume this stream can set. This method uses an asynchronous callback to return the result. 3517 * @param { AsyncCallback<number> } callback - Callback used to return the result. 3518 * @syscap SystemCapability.Multimedia.Audio.Renderer 3519 * @since 10 3520 */ 3521 getMaxStreamVolume(callback: AsyncCallback<number>): void; 3522 /** 3523 * Gets the max volume this stream can set. This method uses a promise to return the result. 3524 * @returns { Promise<number> } Promise used to return the result. 3525 * @syscap SystemCapability.Multimedia.Audio.Renderer 3526 * @since 10 3527 */ 3528 getMaxStreamVolume(): Promise<number>; 3529 /** 3530 * Gets the max volume this stream can set. 3531 * @returns { number } Max stream volume. 3532 * @syscap SystemCapability.Multimedia.Audio.Renderer 3533 * @since 10 3534 */ 3535 getMaxStreamVolumeSync(): number; 3536 3537 /** 3538 * Gets buffer underflow count. This method uses an asynchronous callback to return the result. 3539 * @param { AsyncCallback<number> } callback - Callback used to return the result. 3540 * @syscap SystemCapability.Multimedia.Audio.Renderer 3541 * @since 10 3542 */ 3543 getUnderflowCount(callback: AsyncCallback<number>): void; 3544 /** 3545 * Gets buffer underflow count. This method uses a promise to return the result. 3546 * @returns { Promise<number> } Promise used to return the result. 3547 * @syscap SystemCapability.Multimedia.Audio.Renderer 3548 * @since 10 3549 */ 3550 getUnderflowCount(): Promise<number>; 3551 /** 3552 * Gets buffer underflow count. 3553 * @returns { number } Underflow count number. 3554 * @syscap SystemCapability.Multimedia.Audio.Renderer 3555 * @since 10 3556 */ 3557 getUnderflowCountSync(): number; 3558 3559 /** 3560 * Gets the output device or devices for this stream. 3561 * This method uses an asynchronous callback to return the result. 3562 * @param { AsyncCallback<AudioDeviceDescriptors> } callback - Callback used to return the result. 3563 * @syscap SystemCapability.Multimedia.Audio.Device 3564 * @since 10 3565 */ 3566 getCurrentOutputDevices(callback: AsyncCallback<AudioDeviceDescriptors>): void; 3567 /** 3568 * Gets the output device or devices for this stream. 3569 * This method uses a promise to return the result. 3570 * @returns { Promise<AudioDeviceDescriptors> } Promise used to return the result. 3571 * @syscap SystemCapability.Multimedia.Audio.Device 3572 * @since 10 3573 */ 3574 getCurrentOutputDevices(): Promise<AudioDeviceDescriptors>; 3575 /** 3576 * Gets the output device or devices for this stream. 3577 * @returns { AudioDeviceDescriptors } Output device or devices. 3578 * @syscap SystemCapability.Multimedia.Audio.Device 3579 * @since 10 3580 */ 3581 getCurrentOutputDevicesSync(): AudioDeviceDescriptors; 3582 3583 /** 3584 * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is 3585 * triggered when audio playback is interrupted. 3586 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 3587 * @param { Callback<InterruptEvent> } callback - Callback used to listen for interrupt callback. 3588 * @throws { BusinessError } 401 - if input parameter type or number mismatch 3589 * @throws { BusinessError } 6800101 - if input parameter value error 3590 * @syscap SystemCapability.Multimedia.Audio.Interrupt 3591 * @since 9 3592 */ 3593 on(type: 'audioInterrupt', callback: Callback<InterruptEvent>): void; 3594 3595 /** 3596 * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, 3597 * the callback is invoked. 3598 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 3599 * @param { number } frame - Number of frames to trigger the event. The value must be greater than 0. 3600 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 3601 * @syscap SystemCapability.Multimedia.Audio.Renderer 3602 * @since 8 3603 */ 3604 on(type: 'markReach', frame: number, callback: Callback<number>): void; 3605 /** 3606 * Unsubscribes from mark reached events. 3607 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 3608 * @syscap SystemCapability.Multimedia.Audio.Renderer 3609 * @since 8 3610 */ 3611 off(type: 'markReach'): void; 3612 3613 /** 3614 * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, 3615 * the callback is invoked. 3616 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 3617 * @param { number } frame - Period during which frame rendering is listened. The value must be greater than 0. 3618 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 3619 * @syscap SystemCapability.Multimedia.Audio.Renderer 3620 * @since 8 3621 */ 3622 on(type: 'periodReach', frame: number, callback: Callback<number>): void; 3623 /** 3624 * Unsubscribes from period reached events. 3625 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 3626 * @syscap SystemCapability.Multimedia.Audio.Renderer 3627 * @since 8 3628 */ 3629 off(type: 'periodReach'): void; 3630 3631 /** 3632 * Subscribes audio state change event callback. 3633 * @param { 'stateChange' } type - Type of the event to listen for. Only the stateChange event is supported. 3634 * @param { Callback<AudioState> } callback - Callback invoked when state change. 3635 * @syscap SystemCapability.Multimedia.Audio.Renderer 3636 * @since 8 3637 */ 3638 on(type: 'stateChange', callback: Callback<AudioState>): void; 3639 3640 /** 3641 * Subscribes output device change event callback. 3642 * The event is triggered when output device change for this stream. 3643 * @param { 'outputDeviceChange' } type - Type of the event to listen for. 3644 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used to listen device change event. 3645 * @throws { BusinessError } 401 - if input parameter type or number mismatch. 3646 * @throws { BusinessError } 6800101 - if input parameter value error. 3647 * @syscap SystemCapability.Multimedia.Audio.Device 3648 * @since 10 3649 */ 3650 on(type: 'outputDeviceChange', callback: Callback<AudioDeviceDescriptors>): void; 3651 /** 3652 * Unsubscribes output device change event callback. 3653 * @param { 'outputDeviceChange' } type - Type of the event to listen for. 3654 * @param { Callback<AudioDeviceDescriptors> } callback - Callback used in subscribe. 3655 * @throws { BusinessError } 401 - if input parameter type or number mismatch. 3656 * @throws { BusinessError } 6800101 - if input parameter value error. 3657 * @syscap SystemCapability.Multimedia.Audio.Device 3658 * @since 10 3659 */ 3660 off(type: 'outputDeviceChange', callback?: Callback<AudioDeviceDescriptors>): void; 3661 } 3662 3663 /** 3664 * Enumerates source types. 3665 * @enum { number } 3666 * @syscap SystemCapability.Multimedia.Audio.Core 3667 * @since 8 3668 */ 3669 enum SourceType { 3670 /** 3671 * Invalid source type. 3672 * @syscap SystemCapability.Multimedia.Audio.Core 3673 * @since 8 3674 */ 3675 SOURCE_TYPE_INVALID = -1, 3676 /** 3677 * Mic source type. 3678 * @syscap SystemCapability.Multimedia.Audio.Core 3679 * @since 8 3680 */ 3681 SOURCE_TYPE_MIC = 0, 3682 /** 3683 * Voice recognition source type. 3684 * @syscap SystemCapability.Multimedia.Audio.Core 3685 * @since 9 3686 */ 3687 SOURCE_TYPE_VOICE_RECOGNITION = 1, 3688 /** 3689 * Playback capture source type. 3690 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 3691 * @since 10 3692 */ 3693 SOURCE_TYPE_PLAYBACK_CAPTURE = 2, 3694 /** 3695 * Wakeup source type. 3696 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 3697 * @syscap SystemCapability.Multimedia.Audio.Core 3698 * @systemapi 3699 * @since 10 3700 */ 3701 SOURCE_TYPE_WAKEUP = 3, 3702 /** 3703 * Voice communication source type. 3704 * @syscap SystemCapability.Multimedia.Audio.Core 3705 * @since 8 3706 */ 3707 SOURCE_TYPE_VOICE_COMMUNICATION = 7 3708 } 3709 3710 /** 3711 * Describes audio capturer information. 3712 * @typedef AudioCapturerInfo 3713 * @syscap SystemCapability.Multimedia.Audio.Core 3714 * @since 8 3715 */ 3716 interface AudioCapturerInfo { 3717 /** 3718 * Audio source type. 3719 * @syscap SystemCapability.Multimedia.Audio.Core 3720 * @since 8 3721 */ 3722 source: SourceType; 3723 /** 3724 * Audio capturer flags. 3725 * @syscap SystemCapability.Multimedia.Audio.Core 3726 * @since 8 3727 */ 3728 capturerFlags: number; 3729 } 3730 3731 /** 3732 * Describes audio capturer configuration options. 3733 * @typedef AudioCapturerOptions 3734 * @syscap SystemCapability.Multimedia.Audio.Capturer 3735 * @since 8 3736 */ 3737 interface AudioCapturerOptions { 3738 /** 3739 * Stream information. 3740 * @syscap SystemCapability.Multimedia.Audio.Capturer 3741 * @since 8 3742 */ 3743 streamInfo: AudioStreamInfo; 3744 /** 3745 * Capturer information. 3746 * @syscap SystemCapability.Multimedia.Audio.Capturer 3747 * @since 8 3748 */ 3749 capturerInfo: AudioCapturerInfo; 3750 /** 3751 * Playback capture config. 3752 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 3753 * @since 10 3754 */ 3755 playbackCaptureConfig?: AudioPlaybackCaptureConfig; 3756 } 3757 3758 /** 3759 * Describe playback capture filtering options 3760 * @typedef CaptureFilterOptions 3761 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 3762 * @since 10 3763 */ 3764 interface CaptureFilterOptions { 3765 /** 3766 * Filter by stream usages. If you want to capture voice streams, additional permission is needed. 3767 * @permission ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO 3768 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 3769 * @since 10 3770 */ 3771 usages: Array<StreamUsage>; 3772 } 3773 3774 /** 3775 * Describe playback capture config object. 3776 * @typedef AudioPlaybackCaptureConfig 3777 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 3778 * @since 10 3779 */ 3780 interface AudioPlaybackCaptureConfig { 3781 /** 3782 * Add filter options to decide which streams to be captured. 3783 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture 3784 * @since 10 3785 */ 3786 filterOptions: CaptureFilterOptions; 3787 } 3788 3789 /** 3790 * Provides APIs for audio recording. 3791 * @typedef AudioCapturer 3792 * @syscap SystemCapability.Multimedia.Audio.Capturer 3793 * @since 8 3794 */ 3795 interface AudioCapturer { 3796 /** 3797 * Defines the current capture state. 3798 * @syscap SystemCapability.Multimedia.Audio.Capturer 3799 * @since 8 3800 */ 3801 readonly state: AudioState; 3802 3803 /** 3804 * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous 3805 * callback to return the result. 3806 * @param { AsyncCallback<AudioCapturerInfo> } callback - Callback used to return the capturer information. 3807 * @syscap SystemCapability.Multimedia.Audio.Capturer 3808 * @since 8 3809 */ 3810 getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo>): void; 3811 /** 3812 * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to 3813 * return the result. 3814 * @returns { Promise<AudioCapturerInfo> } Promise used to return the capturer information. 3815 * @syscap SystemCapability.Multimedia.Audio.Capturer 3816 * @since 8 3817 */ 3818 getCapturerInfo(): Promise<AudioCapturerInfo>; 3819 /** 3820 * Obtains the capturer information provided while creating a capturer instance. 3821 * @returns { AudioCapturerInfo } The capturer information. 3822 * @syscap SystemCapability.Multimedia.Audio.Capturer 3823 * @since 10 3824 */ 3825 getCapturerInfoSync(): AudioCapturerInfo; 3826 3827 /** 3828 * Obtains the capturer stream information. This method uses an asynchronous callback to return the result. 3829 * @param { AsyncCallback<AudioStreamInfo> } callback - Callback used to return the stream information. 3830 * @syscap SystemCapability.Multimedia.Audio.Capturer 3831 * @since 8 3832 */ 3833 getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void; 3834 /** 3835 * Obtains the capturer stream information. This method uses a promise to return the result. 3836 * @returns { Promise<AudioStreamInfo> } Promise used to return the stream information. 3837 * @syscap SystemCapability.Multimedia.Audio.Capturer 3838 * @since 8 3839 */ 3840 getStreamInfo(): Promise<AudioStreamInfo>; 3841 /** 3842 * Obtains the capturer stream information. 3843 * @returns { AudioStreamInfo } The stream information. 3844 * @syscap SystemCapability.Multimedia.Audio.Capturer 3845 * @since 10 3846 */ 3847 getStreamInfoSync(): AudioStreamInfo; 3848 3849 /** 3850 * Obtains the capturer stream id. This method uses an asynchronous callback to return the result. 3851 * @param { AsyncCallback<number> } callback - Callback used to return the stream id. 3852 * @syscap SystemCapability.Multimedia.Audio.Capturer 3853 * @since 9 3854 */ 3855 getAudioStreamId(callback: AsyncCallback<number>): void; 3856 /** 3857 * Obtains the capturer stream id. This method uses a promise to return the result. 3858 * @returns { Promise<number> } Promise used to return the stream id. 3859 * @syscap SystemCapability.Multimedia.Audio.Capturer 3860 * @since 9 3861 */ 3862 getAudioStreamId(): Promise<number>; 3863 /** 3864 * Obtains the capturer stream id. 3865 * @returns { number } The stream id. 3866 * @syscap SystemCapability.Multimedia.Audio.Capturer 3867 * @since 10 3868 */ 3869 getAudioStreamIdSync(): number; 3870 3871 /** 3872 * Starts capturing. This method uses an asynchronous callback to return the result. 3873 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3874 * @syscap SystemCapability.Multimedia.Audio.Capturer 3875 * @since 8 3876 */ 3877 start(callback: AsyncCallback<void>): void; 3878 /** 3879 * Starts capturing. This method uses a promise to return the result. 3880 * @returns { Promise<void> } Promise used to return the result. 3881 * @syscap SystemCapability.Multimedia.Audio.Capturer 3882 * @since 8 3883 */ 3884 start(): Promise<void>; 3885 3886 /** 3887 * Reads the buffer from the audio capturer. This method uses an asynchronous callback to return the result. 3888 * @param { number } size - Number of bytes to read. 3889 * @param { boolean } isBlockingRead - Whether the read operation should be blocked. 3890 * @param { AsyncCallback<ArrayBuffer> } callback - Callback used to return the buffer. 3891 * @syscap SystemCapability.Multimedia.Audio.Capturer 3892 * @since 8 3893 */ 3894 read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer>): void; 3895 /** 3896 * Reads the buffer from the audio capturer. This method uses a promise to return the result. 3897 * @param { number } size - Number of bytes to read. 3898 * @param { boolean } isBlockingRead - Whether the read operation should be blocked. 3899 * @returns { Promise<ArrayBuffer> } Returns the buffer data read if the operation is successful. 3900 * Returns an error code otherwise. 3901 * @syscap SystemCapability.Multimedia.Audio.Capturer 3902 * @since 8 3903 */ 3904 read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer>; 3905 3906 /** 3907 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an 3908 * asynchronous callback to return the result. 3909 * @param { AsyncCallback<number> } callback - Callback used to return the timestamp. 3910 * @syscap SystemCapability.Multimedia.Audio.Capturer 3911 * @since 8 3912 */ 3913 getAudioTime(callback: AsyncCallback<number>): void; 3914 /** 3915 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a 3916 * promise to return the result. 3917 * @returns { Promise<number> } Promise used to return the timestamp. 3918 * @syscap SystemCapability.Multimedia.Audio.Capturer 3919 * @since 8 3920 */ 3921 getAudioTime(): Promise<number>; 3922 /** 3923 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. 3924 * @returns { number } The audio timestamp. 3925 * @syscap SystemCapability.Multimedia.Audio.Capturer 3926 * @since 10 3927 */ 3928 getAudioTimeSync(): number; 3929 3930 /** 3931 * Stops capturing. This method uses an asynchronous callback to return the result. 3932 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3933 * @syscap SystemCapability.Multimedia.Audio.Capturer 3934 * @since 8 3935 */ 3936 stop(callback: AsyncCallback<void>): void; 3937 /** 3938 * Stops capturing. This method uses a promise to return the result. 3939 * @returns { Promise<void> } Promise used to return the result. 3940 * @syscap SystemCapability.Multimedia.Audio.Capturer 3941 * @since 8 3942 */ 3943 stop(): Promise<void>; 3944 3945 /** 3946 * Releases the capturer. This method uses an asynchronous callback to return the result. 3947 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3948 * @syscap SystemCapability.Multimedia.Audio.Capturer 3949 * @since 8 3950 */ 3951 release(callback: AsyncCallback<void>): void; 3952 /** 3953 * Releases the capturer. This method uses a promise to return the result. 3954 * @returns { Promise<void> } - Promise used to return the result. 3955 * @syscap SystemCapability.Multimedia.Audio.Capturer 3956 * @since 8 3957 */ 3958 release(): Promise<void>; 3959 3960 /** 3961 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to 3962 * return the result. 3963 * @param { AsyncCallback<number> } callback - Callback used to return the buffer size. 3964 * @syscap SystemCapability.Multimedia.Audio.Capturer 3965 * @since 8 3966 */ 3967 getBufferSize(callback: AsyncCallback<number>): void; 3968 /** 3969 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result. 3970 * @returns { Promise<number> } Promise used to return the buffer size. 3971 * @syscap SystemCapability.Multimedia.Audio.Capturer 3972 * @since 8 3973 */ 3974 getBufferSize(): Promise<number>; 3975 /** 3976 * Obtains a reasonable minimum buffer size in bytes for capturing. 3977 * @returns { number } Promise used to return the buffer size. 3978 * @syscap SystemCapability.Multimedia.Audio.Capturer 3979 * @since 10 3980 */ 3981 getBufferSizeSync(): number; 3982 3983 /** 3984 * Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter, 3985 * the callback is invoked. 3986 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 3987 * @param { number } frame - Number of frames to trigger the event. The value must be greater than 0. 3988 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 3989 * @syscap SystemCapability.Multimedia.Audio.Capturer 3990 * @since 8 3991 */ 3992 on(type: 'markReach', frame: number, callback: Callback<number>): void; 3993 /** 3994 * Unsubscribes from the mark reached events. 3995 * @param { 'markReach' } type - Type of the event to listen for. Only the markReach event is supported. 3996 * @syscap SystemCapability.Multimedia.Audio.Capturer 3997 * @since 8 3998 */ 3999 off(type: 'markReach'): void; 4000 4001 /** 4002 * Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter, 4003 * the callback is invoked. 4004 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 4005 * @param { number } frame - Period during which frame capturing is listened. The value must be greater than 0. 4006 * @param { Callback<number> } callback - Callback invoked when the event is triggered. 4007 * @syscap SystemCapability.Multimedia.Audio.Capturer 4008 * @since 8 4009 */ 4010 on(type: 'periodReach', frame: number, callback: Callback<number>): void; 4011 /** 4012 * Unsubscribes from period reached events. 4013 * @param { 'periodReach' } type - Type of the event to listen for. Only the periodReach event is supported. 4014 * @syscap SystemCapability.Multimedia.Audio.Capturer 4015 * @since 8 4016 */ 4017 off(type: 'periodReach'): void; 4018 4019 /** 4020 * Subscribes audio state change event callback. 4021 * @param { 'stateChange' } type - Type of the event to listen for. Only the stateChange event is supported. 4022 * @param { Callback<AudioState> } callback - Callback used to listen for the audio state change event. 4023 * @syscap SystemCapability.Multimedia.Audio.Capturer 4024 * @since 8 4025 */ 4026 on(type: 'stateChange', callback: Callback<AudioState>): void; 4027 4028 /** 4029 * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is 4030 * triggered when audio recording is interrupted. 4031 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 4032 * @param { Callback<InterruptEvent> } callback - Callback used to listen for interrupt callback. 4033 * @throws { BusinessError } 401 - if input parameter type or number mismatch 4034 * @throws { BusinessError } 6800101 - if input parameter value error 4035 * @syscap SystemCapability.Multimedia.Audio.Interrupt 4036 * @since 10 4037 */ 4038 on(type: 'audioInterrupt', callback: Callback<InterruptEvent>): void; 4039 4040 /** 4041 * UnSubscribes to audio interrupt events. 4042 * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported. 4043 * @throws { BusinessError } 401 - if input parameter type or number mismatch 4044 * @throws { BusinessError } 6800101 - if input parameter value error 4045 * @syscap SystemCapability.Multimedia.Audio.Interrupt 4046 * @since 10 4047 */ 4048 off(type: 'audioInterrupt'): void; 4049 } 4050 4051 /** 4052 * Enumerates tone types for player. 4053 * @enum { number } 4054 * @syscap SystemCapability.Multimedia.Audio.Tone 4055 * @systemapi 4056 * @since 9 4057 */ 4058 enum ToneType { 4059 /** 4060 * Dial tone for key 0. 4061 * @syscap SystemCapability.Multimedia.Audio.Tone 4062 * @systemapi 4063 * @since 9 4064 */ 4065 TONE_TYPE_DIAL_0 = 0, 4066 /** 4067 * Dial tone for key 1. 4068 * @syscap SystemCapability.Multimedia.Audio.Tone 4069 * @systemapi 4070 * @since 9 4071 */ 4072 TONE_TYPE_DIAL_1 = 1, 4073 /** 4074 * Dial tone for key 2. 4075 * @syscap SystemCapability.Multimedia.Audio.Tone 4076 * @systemapi 4077 * @since 9 4078 */ 4079 TONE_TYPE_DIAL_2 = 2, 4080 /** 4081 * Dial tone for key 3. 4082 * @syscap SystemCapability.Multimedia.Audio.Tone 4083 * @systemapi 4084 * @since 9 4085 */ 4086 TONE_TYPE_DIAL_3 = 3, 4087 /** 4088 * Dial tone for key 4. 4089 * @syscap SystemCapability.Multimedia.Audio.Tone 4090 * @systemapi 4091 * @since 9 4092 */ 4093 TONE_TYPE_DIAL_4 = 4, 4094 /** 4095 * Dial tone for key 5. 4096 * @syscap SystemCapability.Multimedia.Audio.Tone 4097 * @systemapi 4098 * @since 9 4099 */ 4100 TONE_TYPE_DIAL_5 = 5, 4101 /** 4102 * Dial tone for key 6. 4103 * @syscap SystemCapability.Multimedia.Audio.Tone 4104 * @systemapi 4105 * @since 9 4106 */ 4107 TONE_TYPE_DIAL_6 = 6, 4108 /** 4109 * Dial tone for key 7. 4110 * @syscap SystemCapability.Multimedia.Audio.Tone 4111 * @systemapi 4112 * @since 9 4113 */ 4114 TONE_TYPE_DIAL_7 = 7, 4115 /** 4116 * Dial tone for key 8. 4117 * @syscap SystemCapability.Multimedia.Audio.Tone 4118 * @systemapi 4119 * @since 9 4120 */ 4121 TONE_TYPE_DIAL_8 = 8, 4122 /** 4123 * Dial tone for key 9. 4124 * @syscap SystemCapability.Multimedia.Audio.Tone 4125 * @systemapi 4126 * @since 9 4127 */ 4128 TONE_TYPE_DIAL_9 = 9, 4129 /** 4130 * Dial tone for key *. 4131 * @syscap SystemCapability.Multimedia.Audio.Tone 4132 * @systemapi 4133 * @since 9 4134 */ 4135 TONE_TYPE_DIAL_S = 10, 4136 /** 4137 * Dial tone for key #. 4138 * @syscap SystemCapability.Multimedia.Audio.Tone 4139 * @systemapi 4140 * @since 9 4141 */ 4142 TONE_TYPE_DIAL_P = 11, 4143 /** 4144 * Dial tone for key A. 4145 * @syscap SystemCapability.Multimedia.Audio.Tone 4146 * @systemapi 4147 * @since 9 4148 */ 4149 TONE_TYPE_DIAL_A = 12, 4150 /** 4151 * Dial tone for key B. 4152 * @syscap SystemCapability.Multimedia.Audio.Tone 4153 * @systemapi 4154 * @since 9 4155 */ 4156 TONE_TYPE_DIAL_B = 13, 4157 /** 4158 * Dial tone for key C. 4159 * @syscap SystemCapability.Multimedia.Audio.Tone 4160 * @systemapi 4161 * @since 9 4162 */ 4163 TONE_TYPE_DIAL_C = 14, 4164 /** 4165 * Dial tone for key D. 4166 * @syscap SystemCapability.Multimedia.Audio.Tone 4167 * @systemapi 4168 * @since 9 4169 */ 4170 TONE_TYPE_DIAL_D = 15, 4171 /** 4172 * Supervisory tone for dial. 4173 * @syscap SystemCapability.Multimedia.Audio.Tone 4174 * @systemapi 4175 * @since 9 4176 */ 4177 TONE_TYPE_COMMON_SUPERVISORY_DIAL = 100, 4178 /** 4179 * Supervisory tone for busy. 4180 * @syscap SystemCapability.Multimedia.Audio.Tone 4181 * @systemapi 4182 * @since 9 4183 */ 4184 TONE_TYPE_COMMON_SUPERVISORY_BUSY = 101, 4185 /** 4186 * Supervisory tone for dial. 4187 * @syscap SystemCapability.Multimedia.Audio.Tone 4188 * @systemapi 4189 * @since 9 4190 */ 4191 TONE_TYPE_COMMON_SUPERVISORY_CONGESTION = 102, 4192 /** 4193 * Supervisory tone for radio path acknowledgment. 4194 * @syscap SystemCapability.Multimedia.Audio.Tone 4195 * @systemapi 4196 * @since 9 4197 */ 4198 TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK = 103, 4199 /** 4200 * Supervisory tone for radio path not available. 4201 * @syscap SystemCapability.Multimedia.Audio.Tone 4202 * @systemapi 4203 * @since 9 4204 */ 4205 TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE = 104, 4206 /** 4207 * Supervisory tone for call waiting. 4208 * @syscap SystemCapability.Multimedia.Audio.Tone 4209 * @systemapi 4210 * @since 9 4211 */ 4212 TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING = 106, 4213 /** 4214 * Supervisory tone for ringtone. 4215 * @syscap SystemCapability.Multimedia.Audio.Tone 4216 * @systemapi 4217 * @since 9 4218 */ 4219 TONE_TYPE_COMMON_SUPERVISORY_RINGTONE = 107, 4220 /** 4221 * Proprietary tone for beep. 4222 * @syscap SystemCapability.Multimedia.Audio.Tone 4223 * @systemapi 4224 * @since 9 4225 */ 4226 TONE_TYPE_COMMON_PROPRIETARY_BEEP = 200, 4227 /** 4228 * Proprietary tone for positive acknowledgment. 4229 * @syscap SystemCapability.Multimedia.Audio.Tone 4230 * @systemapi 4231 * @since 9 4232 */ 4233 TONE_TYPE_COMMON_PROPRIETARY_ACK = 201, 4234 /** 4235 * Proprietary tone for prompt. 4236 * @syscap SystemCapability.Multimedia.Audio.Tone 4237 * @systemapi 4238 * @since 9 4239 */ 4240 TONE_TYPE_COMMON_PROPRIETARY_PROMPT = 203, 4241 /** 4242 * Proprietary tone for double beep. 4243 * @syscap SystemCapability.Multimedia.Audio.Tone 4244 * @systemapi 4245 * @since 9 4246 */ 4247 TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP = 204, 4248 } 4249 4250 /** 4251 * Provides APIs for tone playing. 4252 * @typedef TonePlayer 4253 * @syscap SystemCapability.Multimedia.Audio.Tone 4254 * @systemapi 4255 * @since 9 4256 */ 4257 interface TonePlayer { 4258 /** 4259 * Loads tone. This method uses an asynchronous callback to return the result. 4260 * @param { ToneType } type - Tone type to play. 4261 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4262 * @syscap SystemCapability.Multimedia.Audio.Tone 4263 * @systemapi 4264 * @since 9 4265 */ 4266 load(type: ToneType, callback: AsyncCallback<void>): void; 4267 /** 4268 * Loads tone. This method uses a promise to return the result. 4269 * @param { ToneType } type - Tone type to play. 4270 * @returns { Promise<void> } Promise used to return the result. 4271 * @syscap SystemCapability.Multimedia.Audio.Tone 4272 * @systemapi 4273 * @since 9 4274 */ 4275 load(type: ToneType): Promise<void>; 4276 4277 /** 4278 * Starts player. This method uses an asynchronous callback to return the result. 4279 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4280 * @syscap SystemCapability.Multimedia.Audio.Tone 4281 * @systemapi 4282 * @since 9 4283 */ 4284 start(callback: AsyncCallback<void>): void; 4285 /** 4286 * Starts player. This method uses a promise to return the result. 4287 * @returns { Promise<void> }Promise used to return the result. 4288 * @syscap SystemCapability.Multimedia.Audio.Tone 4289 * @systemapi 4290 * @since 9 4291 */ 4292 start(): Promise<void>; 4293 4294 /** 4295 * Stops player. This method uses an asynchronous callback to return the result. 4296 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4297 * @syscap SystemCapability.Multimedia.Audio.Tone 4298 * @systemapi 4299 * @since 9 4300 */ 4301 stop(callback: AsyncCallback<void>): void; 4302 /** 4303 * Stops player. This method uses a promise to return the result. 4304 * @returns { Promise<void> } Promise used to return the result. 4305 * @syscap SystemCapability.Multimedia.Audio.Tone 4306 * @systemapi 4307 * @since 9 4308 */ 4309 stop(): Promise<void>; 4310 4311 /** 4312 * Releases the player. This method uses an asynchronous callback to return the result. 4313 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4314 * @syscap SystemCapability.Multimedia.Audio.Tone 4315 * @systemapi 4316 * @since 9 4317 */ 4318 release(callback: AsyncCallback<void>): void; 4319 /** 4320 * Releases the player. This method uses a promise to return the result. 4321 * @returns { Promise<void> } Promise used to return the result. 4322 * @syscap SystemCapability.Multimedia.Audio.Tone 4323 * @systemapi 4324 * @since 9 4325 */ 4326 release(): Promise<void>; 4327 } 4328 4329 /** 4330 * Array of AudioEffectMode, which is read-only. 4331 * @syscap SystemCapability.Multimedia.Audio.Renderer 4332 * @since 10 4333 */ 4334 type AudioEffectInfoArray = Array<Readonly<AudioEffectMode>>; 4335 4336 /** 4337 * Describes an audio effect mode group. 4338 * @enum { number } 4339 * @syscap SystemCapability.Multimedia.Audio.Renderer 4340 * @since 10 4341 */ 4342 enum AudioEffectMode { 4343 /** 4344 * Audio Effect Mode effect none. 4345 * @syscap SystemCapability.Multimedia.Audio.Renderer 4346 * @since 10 4347 */ 4348 EFFECT_NONE = 0, 4349 /** 4350 * Audio Effect Mode effect default. 4351 * @syscap SystemCapability.Multimedia.Audio.Renderer 4352 * @since 10 4353 */ 4354 EFFECT_DEFAULT = 1, 4355 } 4356} 4357 4358export default audio;