1/* 2* Copyright (C) 2021 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 './basic'; 17 18/** 19 * @namespace audio 20 * @since 7 21 */ 22declare namespace audio { 23 /** 24 * Enumerates audio errors. 25 * @since 9 26 * @syscap SystemCapability.Multimedia.Audio.Core 27 */ 28 enum AudioErrors { 29 /** 30 * Invalid parameter. 31 * @since 9 32 * @syscap SystemCapability.Multimedia.Audio.Core 33 */ 34 ERROR_INVALID_PARAM = 6800101, 35 /** 36 * Allocate memory failed. 37 * @since 9 38 * @syscap SystemCapability.Multimedia.Audio.Core 39 */ 40 ERROR_NO_MEMORY = 6800102, 41 /** 42 * Operation not permit at current state. 43 * @since 9 44 * @syscap SystemCapability.Multimedia.Audio.Core 45 */ 46 ERROR_ILLEGAL_STATE = 6800103, 47 /** 48 * Unsupported option. 49 * @since 9 50 * @syscap SystemCapability.Multimedia.Audio.Core 51 */ 52 ERROR_UNSUPPORTED = 6800104, 53 /** 54 * Time out. 55 * @since 9 56 * @syscap SystemCapability.Multimedia.Audio.Core 57 */ 58 ERROR_TIMEOUT = 6800105, 59 /** 60 * Audio specific errors. 61 * @since 9 62 * @syscap SystemCapability.Multimedia.Audio.Core 63 */ 64 ERROR_STREAM_LIMIT = 6800201, 65 /** 66 * Default error. 67 * @since 9 68 * @syscap SystemCapability.Multimedia.Audio.Core 69 */ 70 ERROR_SYSTEM = 6800301 71 } 72 73 /** 74 * Define local device network id for audio 75 * @since 9 76 * @syscap SystemCapability.Multimedia.Audio.Device 77 * @systemapi 78 */ 79 const LOCAL_NETWORK_ID: string; 80 81 /** 82 * Define default volume group id for audio 83 * @since 9 84 * @syscap SystemCapability.Multimedia.Audio.Volume 85 */ 86 const DEFAULT_VOLUME_GROUP_ID: number; 87 88 /** 89 * Define default interrupt group id for audio 90 * @since 9 91 * @syscap SystemCapability.Multimedia.Audio.Interrupt 92 */ 93 const DEFAULT_INTERRUPT_GROUP_ID: number; 94 95 /** 96 * Obtains an {@link AudioManager} instance. 97 * @returns AudioManager object. 98 * @since 7 99 * @syscap SystemCapability.Multimedia.Audio.Core 100 */ 101 function getAudioManager(): AudioManager; 102 103 /** 104 * Obtains an {@link AudioCapturer} instance. This method uses an asynchronous callback to return the capturer instance. 105 * @param options Capturer configurations. 106 * @param callback Callback used to return the audio capturer instance. 107 * @since 8 108 * @syscap SystemCapability.Multimedia.Audio.Capturer 109 */ 110 function createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<AudioCapturer>): void; 111 112 /** 113 * Obtains an {@link AudioCapturer} instance. This method uses a promise to return the capturer instance. 114 * @param options Capturer configurations. 115 * @returns Promise used to return the audio capturer instance. 116 * @since 8 117 * @syscap SystemCapability.Multimedia.Audio.Capturer 118 */ 119 function createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer>; 120 121 /** 122 * Obtains an {@link AudioRenderer} instance. This method uses an asynchronous callback to return the renderer instance. 123 * @param options Renderer configurations. 124 * @param callback Callback used to return the audio renderer instance. 125 * @since 8 126 * @syscap SystemCapability.Multimedia.Audio.Renderer 127 */ 128 function createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback<AudioRenderer>): void; 129 130 /** 131 * Obtains an {@link AudioRenderer} instance. This method uses a promise to return the renderer instance. 132 * @param options Renderer configurations. 133 * @returns Promise used to return the audio renderer instance. 134 * @since 8 135 * @syscap SystemCapability.Multimedia.Audio.Renderer 136 */ 137 function createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer>; 138 139 /** 140 * Obtains a {@link TonePlayer} instance. This method uses an asynchronous callback to return the renderer instance. 141 * @param options Tone playing attribute. 142 * @returns Promise used to return the tone player instance. 143 * @since 9 144 * @syscap SystemCapability.Multimedia.Audio.Tone 145 * @systemapi 146 */ 147 function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback<TonePlayer>): void; 148 149 /** 150 * Obtains a {@link TonePlayer} instance. This method uses a promise to return the renderer instance. 151 * @param options Tone playing attribute. 152 * @returns Promise used to return the tone player instance. 153 * @since 9 154 * @syscap SystemCapability.Multimedia.Audio.Tone 155 * @systemapi 156 */ 157 function createTonePlayer(options: AudioRendererInfo): Promise<TonePlayer>; 158 159 /** 160 * Enumerates the audio states. 161 * @since 8 162 * @syscap SystemCapability.Multimedia.Audio.Core 163 */ 164 enum AudioState { 165 /** 166 * Invalid state. 167 * @since 8 168 * @syscap SystemCapability.Multimedia.Audio.Core 169 */ 170 STATE_INVALID = -1, 171 /** 172 * Create new instance state. 173 * @since 8 174 * @syscap SystemCapability.Multimedia.Audio.Core 175 */ 176 STATE_NEW = 0, 177 /** 178 * Prepared state. 179 * @since 8 180 * @syscap SystemCapability.Multimedia.Audio.Core 181 */ 182 STATE_PREPARED = 1, 183 /** 184 * Running state. 185 * @since 8 186 * @syscap SystemCapability.Multimedia.Audio.Core 187 */ 188 STATE_RUNNING = 2, 189 /** 190 * Stopped state. 191 * @since 8 192 * @syscap SystemCapability.Multimedia.Audio.Core 193 */ 194 STATE_STOPPED = 3, 195 /** 196 * Released state. 197 * @since 8 198 * @syscap SystemCapability.Multimedia.Audio.Core 199 */ 200 STATE_RELEASED = 4, 201 /** 202 * Paused state. 203 * @since 8 204 * @syscap SystemCapability.Multimedia.Audio.Core 205 */ 206 STATE_PAUSED = 5 207 } 208 209 /** 210 * Enumerates audio stream types. 211 * @since 7 212 * @syscap SystemCapability.Multimedia.Audio.Volume 213 */ 214 enum AudioVolumeType { 215 /** 216 * Audio streams for voice calls. 217 * @since 8 218 * @syscap SystemCapability.Multimedia.Audio.Volume 219 */ 220 VOICE_CALL = 0, 221 /** 222 * Audio streams for ringtones. 223 * @since 7 224 * @syscap SystemCapability.Multimedia.Audio.Volume 225 */ 226 RINGTONE = 2, 227 /** 228 * Audio streams for media purpose. 229 * @since 7 230 * @syscap SystemCapability.Multimedia.Audio.Volume 231 */ 232 MEDIA = 3, 233 /** 234 * Audio stream for voice assistant. 235 * @since 8 236 * @syscap SystemCapability.Multimedia.Audio.Volume 237 */ 238 VOICE_ASSISTANT = 9, 239 /** 240 * Audio stream for all common. 241 * @since 9 242 * @syscap SystemCapability.Multimedia.Audio.Volume 243 * @systemapi 244 */ 245 ALL = 100, 246 } 247 248 /** 249 * Enumerates audio device flags. 250 * @since 7 251 * @syscap SystemCapability.Multimedia.Audio.Device 252 */ 253 enum DeviceFlag { 254 /** 255 * None devices. 256 * @since 9 257 * @syscap SystemCapability.Multimedia.Audio.Device 258 * @systemapi 259 */ 260 NONE_DEVICES_FLAG = 0, 261 /** 262 * Output devices. 263 * @since 7 264 * @syscap SystemCapability.Multimedia.Audio.Device 265 */ 266 OUTPUT_DEVICES_FLAG = 1, 267 /** 268 * Input devices. 269 * @since 7 270 * @syscap SystemCapability.Multimedia.Audio.Device 271 */ 272 INPUT_DEVICES_FLAG = 2, 273 /** 274 * All devices. 275 * @since 7 276 * @syscap SystemCapability.Multimedia.Audio.Device 277 */ 278 ALL_DEVICES_FLAG = 3, 279 /** 280 * Distributed output devices. 281 * @since 9 282 * @syscap SystemCapability.Multimedia.Audio.Device 283 * @systemapi 284 */ 285 DISTRIBUTED_OUTPUT_DEVICES_FLAG = 4, 286 /** 287 * Distributed input devices. 288 * @since 9 289 * @syscap SystemCapability.Multimedia.Audio.Device 290 * @systemapi 291 */ 292 DISTRIBUTED_INPUT_DEVICES_FLAG = 8, 293 /** 294 * All Distributed devices. 295 * @since 9 296 * @syscap SystemCapability.Multimedia.Audio.Device 297 * @systemapi 298 */ 299 ALL_DISTRIBUTED_DEVICES_FLAG = 12, 300 } 301 302 /** 303 * Enumerates device roles. 304 * @since 7 305 * @syscap SystemCapability.Multimedia.Audio.Device 306 */ 307 enum DeviceRole { 308 /** 309 * Input role. 310 * @since 7 311 * @syscap SystemCapability.Multimedia.Audio.Device 312 */ 313 INPUT_DEVICE = 1, 314 /** 315 * Output role. 316 * @since 7 317 * @syscap SystemCapability.Multimedia.Audio.Device 318 */ 319 OUTPUT_DEVICE = 2, 320 } 321 322 /** 323 * Enumerates device types. 324 * @since 7 325 * @syscap SystemCapability.Multimedia.Audio.Device 326 */ 327 enum DeviceType { 328 /** 329 * Invalid device. 330 * @since 7 331 * @syscap SystemCapability.Multimedia.Audio.Device 332 */ 333 INVALID = 0, 334 /** 335 * Built-in earpiece. 336 * @since 7 337 * @syscap SystemCapability.Multimedia.Audio.Device 338 */ 339 EARPIECE = 1, 340 /** 341 * Built-in speaker. 342 * @since 7 343 * @syscap SystemCapability.Multimedia.Audio.Device 344 */ 345 SPEAKER = 2, 346 /** 347 * Wired headset, which is a combination of a pair of earpieces and a microphone. 348 * @since 7 349 * @syscap SystemCapability.Multimedia.Audio.Device 350 */ 351 WIRED_HEADSET = 3, 352 /** 353 * A pair of wired headphones. 354 * @since 7 355 * @syscap SystemCapability.Multimedia.Audio.Device 356 */ 357 WIRED_HEADPHONES = 4, 358 /** 359 * Bluetooth device using the synchronous connection oriented link (SCO). 360 * @since 7 361 * @syscap SystemCapability.Multimedia.Audio.Device 362 */ 363 BLUETOOTH_SCO = 7, 364 /** 365 * Bluetooth device using advanced audio distribution profile (A2DP). 366 * @since 7 367 * @syscap SystemCapability.Multimedia.Audio.Device 368 */ 369 BLUETOOTH_A2DP = 8, 370 /** 371 * Built-in microphone. 372 * @since 7 373 * @syscap SystemCapability.Multimedia.Audio.Device 374 */ 375 MIC = 15, 376 /** 377 * USB audio headset. 378 * @since 7 379 * @syscap SystemCapability.Multimedia.Audio.Device 380 */ 381 USB_HEADSET = 22, 382 /** 383 * Default device type. 384 * @since 9 385 * @syscap SystemCapability.Multimedia.Audio.Device 386 */ 387 DEFAULT = 1000, 388 } 389 390 /** 391 * Enumerates the active device types. 392 * @since 7 393 * @syscap SystemCapability.Multimedia.Audio.Device 394 * @deprecated since 9 395 * @useinstead ohos.multimedia.audio.CommunicationDeviceType 396 */ 397 enum ActiveDeviceType { 398 /** 399 * Speaker. 400 * @since 7 401 * @syscap SystemCapability.Multimedia.Audio.Device 402 * @deprecated since 9 403 * @useinstead ohos.multimedia.audio.CommunicationDeviceType.SPEAKER 404 */ 405 SPEAKER = 2, 406 /** 407 * Bluetooth device using the SCO link. 408 * @since 7 409 * @syscap SystemCapability.Multimedia.Audio.Device 410 * @deprecated since 9 411 */ 412 BLUETOOTH_SCO = 7, 413 } 414 415 /** 416 * Enumerates the available device types for communication. 417 * @since 9 418 * @syscap SystemCapability.Multimedia.Audio.Communication 419 */ 420 enum CommunicationDeviceType { 421 /** 422 * Speaker. 423 * @since 9 424 * @syscap SystemCapability.Multimedia.Audio.Communication 425 */ 426 SPEAKER = 2 427 } 428 429 /** 430 * Enumerates ringer modes. 431 * @since 7 432 * @syscap SystemCapability.Multimedia.Audio.Communication 433 */ 434 enum AudioRingMode { 435 /** 436 * Silent mode. 437 * @since 7 438 * @syscap SystemCapability.Multimedia.Audio.Communication 439 */ 440 RINGER_MODE_SILENT = 0, 441 /** 442 * Vibration mode. 443 * @since 7 444 * @syscap SystemCapability.Multimedia.Audio.Communication 445 */ 446 RINGER_MODE_VIBRATE = 1, 447 /** 448 * Normal mode. 449 * @since 7 450 * @syscap SystemCapability.Multimedia.Audio.Communication 451 */ 452 RINGER_MODE_NORMAL = 2, 453 } 454 455 /** 456 * Enumerates the audio sample formats. 457 * @since 8 458 * @syscap SystemCapability.Multimedia.Audio.Core 459 */ 460 enum AudioSampleFormat { 461 /** 462 * Invalid format. 463 * @since 8 464 * @syscap SystemCapability.Multimedia.Audio.Core 465 */ 466 SAMPLE_FORMAT_INVALID = -1, 467 /** 468 * Unsigned 8 format. 469 * @since 8 470 * @syscap SystemCapability.Multimedia.Audio.Core 471 */ 472 SAMPLE_FORMAT_U8 = 0, 473 /** 474 * Signed 16 bit integer, little endian. 475 * @since 8 476 * @syscap SystemCapability.Multimedia.Audio.Core 477 */ 478 SAMPLE_FORMAT_S16LE = 1, 479 /** 480 * Signed 24 bit integer, little endian. 481 * @since 8 482 * @syscap SystemCapability.Multimedia.Audio.Core 483 */ 484 SAMPLE_FORMAT_S24LE = 2, 485 /** 486 * Signed 32 bit integer, little endian. 487 * @since 8 488 * @syscap SystemCapability.Multimedia.Audio.Core 489 */ 490 SAMPLE_FORMAT_S32LE = 3, 491 /** 492 * Signed 32 bit float, little endian. 493 * @since 9 494 * @syscap SystemCapability.Multimedia.Audio.Core 495 */ 496 SAMPLE_FORMAT_F32LE = 4, 497 } 498 499 /** 500 * Enumerates the audio channel. 501 * @since 8 502 * @syscap SystemCapability.Multimedia.Audio.Core 503 */ 504 enum AudioChannel { 505 /** 506 * Channel 1. 507 * @since 8 508 * @syscap SystemCapability.Multimedia.Audio.Core 509 */ 510 CHANNEL_1 = 0x1 << 0, 511 /** 512 * Channel 2. 513 * @since 8 514 * @syscap SystemCapability.Multimedia.Audio.Core 515 */ 516 CHANNEL_2 = 0x1 << 1 517 } 518 519 /** 520 * Enumerates the audio sampling rate. 521 * @since 8 522 * @syscap SystemCapability.Multimedia.Audio.Core 523 */ 524 enum AudioSamplingRate { 525 /** 526 * 8kHz sample rate. 527 * @since 8 528 * @syscap SystemCapability.Multimedia.Audio.Core 529 */ 530 SAMPLE_RATE_8000 = 8000, 531 /** 532 * 11.025kHz sample rate. 533 * @since 8 534 * @syscap SystemCapability.Multimedia.Audio.Core 535 */ 536 SAMPLE_RATE_11025 = 11025, 537 /** 538 * 12kHz sample rate. 539 * @since 8 540 * @syscap SystemCapability.Multimedia.Audio.Core 541 */ 542 SAMPLE_RATE_12000 = 12000, 543 /** 544 * 16kHz sample rate. 545 * @since 8 546 * @syscap SystemCapability.Multimedia.Audio.Core 547 */ 548 SAMPLE_RATE_16000 = 16000, 549 /** 550 * 22.05kHz sample rate. 551 * @since 8 552 * @syscap SystemCapability.Multimedia.Audio.Core 553 */ 554 SAMPLE_RATE_22050 = 22050, 555 /** 556 * 24kHz sample rate. 557 * @since 8 558 * @syscap SystemCapability.Multimedia.Audio.Core 559 */ 560 SAMPLE_RATE_24000 = 24000, 561 /** 562 * 32kHz sample rate. 563 * @since 8 564 * @syscap SystemCapability.Multimedia.Audio.Core 565 */ 566 SAMPLE_RATE_32000 = 32000, 567 /** 568 * 44.1kHz sample rate. 569 * @since 8 570 * @syscap SystemCapability.Multimedia.Audio.Core 571 */ 572 SAMPLE_RATE_44100 = 44100, 573 /** 574 * 48kHz sample rate. 575 * @since 8 576 * @syscap SystemCapability.Multimedia.Audio.Core 577 */ 578 SAMPLE_RATE_48000 = 48000, 579 /** 580 * 64kHz sample rate. 581 * @since 8 582 * @syscap SystemCapability.Multimedia.Audio.Core 583 */ 584 SAMPLE_RATE_64000 = 64000, 585 /** 586 * 96kHz sample rate. 587 * @since 8 588 * @syscap SystemCapability.Multimedia.Audio.Core 589 */ 590 SAMPLE_RATE_96000 = 96000 591 } 592 593 /** 594 * Enumerates the audio encoding type. 595 * @since 8 596 * @syscap SystemCapability.Multimedia.Audio.Core 597 */ 598 enum AudioEncodingType { 599 /** 600 * Invalid type. 601 * @since 8 602 * @syscap SystemCapability.Multimedia.Audio.Core 603 */ 604 ENCODING_TYPE_INVALID = -1, 605 /** 606 * PCM encoding. 607 * @since 8 608 * @syscap SystemCapability.Multimedia.Audio.Core 609 */ 610 ENCODING_TYPE_RAW = 0 611 } 612 613 /** 614 * Enumerates the audio content type. 615 * @since 7 616 * @syscap SystemCapability.Multimedia.Audio.Core 617 */ 618 enum ContentType { 619 /** 620 * Unknown content. 621 * @since 7 622 * @syscap SystemCapability.Multimedia.Audio.Core 623 */ 624 CONTENT_TYPE_UNKNOWN = 0, 625 /** 626 * Speech content. 627 * @since 7 628 * @syscap SystemCapability.Multimedia.Audio.Core 629 */ 630 CONTENT_TYPE_SPEECH = 1, 631 /** 632 * Music content. 633 * @since 7 634 * @syscap SystemCapability.Multimedia.Audio.Core 635 */ 636 CONTENT_TYPE_MUSIC = 2, 637 /** 638 * Movie content. 639 * @since 7 640 * @syscap SystemCapability.Multimedia.Audio.Core 641 */ 642 CONTENT_TYPE_MOVIE = 3, 643 /** 644 * Notification content. 645 * @since 7 646 * @syscap SystemCapability.Multimedia.Audio.Core 647 */ 648 CONTENT_TYPE_SONIFICATION = 4, 649 /** 650 * Ringtone content. 651 * @since 8 652 * @syscap SystemCapability.Multimedia.Audio.Core 653 */ 654 CONTENT_TYPE_RINGTONE = 5, 655 } 656 657 /** 658 * Enumerates the stream usage. 659 * @since 7 660 * @syscap SystemCapability.Multimedia.Audio.Core 661 */ 662 enum StreamUsage { 663 /** 664 * Unknown usage. 665 * @since 7 666 * @syscap SystemCapability.Multimedia.Audio.Core 667 */ 668 STREAM_USAGE_UNKNOWN = 0, 669 /** 670 * Media usage. 671 * @since 7 672 * @syscap SystemCapability.Multimedia.Audio.Core 673 */ 674 STREAM_USAGE_MEDIA = 1, 675 /** 676 * Voice communication usage. 677 * @since 7 678 * @syscap SystemCapability.Multimedia.Audio.Core 679 */ 680 STREAM_USAGE_VOICE_COMMUNICATION = 2, 681 /** 682 * Voice assistant broadcast usage. 683 * @since 9 684 * @syscap SystemCapability.Multimedia.Audio.Core 685 */ 686 STREAM_USAGE_VOICE_ASSISTANT = 3, 687 /** 688 * Notification or ringtone usage. 689 * @since 7 690 * @syscap SystemCapability.Multimedia.Audio.Core 691 */ 692 STREAM_USAGE_NOTIFICATION_RINGTONE = 6 693 } 694 695 /** 696 * Enumerates the audio interrupt request type. 697 * @since 9 698 * @syscap SystemCapability.Multimedia.Audio.Interrupt 699 * @systemapi 700 */ 701 enum InterruptRequestType { 702 /** 703 * Default type to request audio interrupt. 704 * @since 9 705 * @syscap SystemCapability.Multimedia.Audio.Interrupt 706 * @systemapi 707 */ 708 INTERRUPT_REQUEST_TYPE_DEFAULT = 0, 709 } 710 711 /** 712 * Describes audio stream information. 713 * @since 8 714 * @syscap SystemCapability.Multimedia.Audio.Core 715 */ 716 interface AudioStreamInfo { 717 /** 718 * Sampling rate. 719 * @since 8 720 * @syscap SystemCapability.Multimedia.Audio.Core 721 */ 722 samplingRate: AudioSamplingRate; 723 /** 724 * Audio channels. 725 * @since 8 726 * @syscap SystemCapability.Multimedia.Audio.Core 727 */ 728 channels: AudioChannel; 729 /** 730 * Audio sample format. 731 * @since 8 732 * @syscap SystemCapability.Multimedia.Audio.Core 733 */ 734 sampleFormat: AudioSampleFormat; 735 /** 736 * Audio encoding type. 737 * @since 8 738 * @syscap SystemCapability.Multimedia.Audio.Core 739 */ 740 encodingType: AudioEncodingType; 741 } 742 743 /** 744 * Describes audio renderer information. 745 * @since 8 746 * @syscap SystemCapability.Multimedia.Audio.Core 747 */ 748 interface AudioRendererInfo { 749 /** 750 * Content type. 751 * @since 8 752 * @syscap SystemCapability.Multimedia.Audio.Core 753 */ 754 content: ContentType; 755 /** 756 * Stream usage. 757 * @since 8 758 * @syscap SystemCapability.Multimedia.Audio.Core 759 */ 760 usage: StreamUsage; 761 /** 762 * Audio renderer flags. 763 * @since 8 764 * @syscap SystemCapability.Multimedia.Audio.Core 765 */ 766 rendererFlags: number; 767 } 768 769 /** 770 * Describes audio renderer filter. 771 * @since 9 772 * @syscap SystemCapability.Multimedia.Audio.Core 773 * @systemapi 774 */ 775 interface AudioRendererFilter { 776 /** 777 * Application uid. 778 * @since 9 779 * @syscap SystemCapability.Multimedia.Audio.Core 780 * @systemapi 781 */ 782 uid: number; 783 /** 784 * Renderer information. 785 * @since 9 786 * @syscap SystemCapability.Multimedia.Audio.Renderer 787 * @systemapi 788 */ 789 rendererInfo?: AudioRendererInfo; 790 /** 791 * AudioRenderer id. 792 * @since 9 793 * @syscap SystemCapability.Multimedia.Audio.Renderer 794 * @systemapi 795 */ 796 rendererId?: number; 797 } 798 799 /** 800 * Describes audio renderer configuration options. 801 * @since 8 802 * @syscap SystemCapability.Multimedia.Audio.Renderer 803 */ 804 interface AudioRendererOptions { 805 /** 806 * Stream information. 807 * @since 8 808 * @syscap SystemCapability.Multimedia.Audio.Renderer 809 */ 810 streamInfo: AudioStreamInfo; 811 /** 812 * Renderer information. 813 * @since 8 814 * @syscap SystemCapability.Multimedia.Audio.Renderer 815 */ 816 rendererInfo: AudioRendererInfo; 817 } 818 819 /** 820 * Enumerates the interrupt modes. 821 * @since 9 822 * @syscap SystemCapability.Multimedia.Audio.Interrupt 823 */ 824 enum InterruptMode { 825 /** 826 * Mode that different stream share one interrupt unit. 827 * @since 9 828 * @syscap SystemCapability.Multimedia.Audio.Interrupt 829 */ 830 SHARE_MODE = 0, 831 /** 832 * Mode that each stream has independent interrupt unit. 833 * @since 9 834 * @syscap SystemCapability.Multimedia.Audio.Interrupt 835 */ 836 INDEPENDENT_MODE = 1 837 } 838 839 /** 840 * Enumerates the audio renderer rates. 841 * @since 8 842 * @syscap SystemCapability.Multimedia.Audio.Renderer 843 */ 844 enum AudioRendererRate { 845 /** 846 * Normal rate. 847 * @since 8 848 * @syscap SystemCapability.Multimedia.Audio.Renderer 849 */ 850 RENDER_RATE_NORMAL = 0, 851 /** 852 * Double rate. 853 * @since 8 854 * @syscap SystemCapability.Multimedia.Audio.Renderer 855 */ 856 RENDER_RATE_DOUBLE = 1, 857 /** 858 * Half rate. 859 * @since 8 860 * @syscap SystemCapability.Multimedia.Audio.Renderer 861 */ 862 RENDER_RATE_HALF = 2 863 } 864 865 /** 866 * Enumerates the interrupt types. 867 * @since 7 868 * @syscap SystemCapability.Multimedia.Audio.Renderer 869 */ 870 enum InterruptType { 871 /** 872 * Audio playback interruption started. 873 * @since 7 874 * @syscap SystemCapability.Multimedia.Audio.Renderer 875 */ 876 INTERRUPT_TYPE_BEGIN = 1, 877 878 /** 879 * Audio playback interruption ended. 880 * @since 7 881 * @syscap SystemCapability.Multimedia.Audio.Renderer 882 */ 883 INTERRUPT_TYPE_END = 2 884 } 885 886 /** 887 * Enumerates the interrupt hints. 888 * @since 7 889 * @syscap SystemCapability.Multimedia.Audio.Renderer 890 */ 891 enum InterruptHint { 892 /** 893 * None. 894 * @since 8 895 * @syscap SystemCapability.Multimedia.Audio.Renderer 896 */ 897 INTERRUPT_HINT_NONE = 0, 898 /** 899 * Resume the playback. 900 * @since 7 901 * @syscap SystemCapability.Multimedia.Audio.Renderer 902 */ 903 INTERRUPT_HINT_RESUME = 1, 904 905 /** 906 * Paused/Pause the playback. 907 * @since 7 908 * @syscap SystemCapability.Multimedia.Audio.Renderer 909 */ 910 INTERRUPT_HINT_PAUSE = 2, 911 912 /** 913 * Stopped/Stop the playback. 914 * @since 7 915 * @syscap SystemCapability.Multimedia.Audio.Renderer 916 */ 917 INTERRUPT_HINT_STOP = 3, 918 919 /** 920 * Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.) 921 * @since 7 922 * @syscap SystemCapability.Multimedia.Audio.Renderer 923 */ 924 INTERRUPT_HINT_DUCK = 4, 925 926 /** 927 * Unducked the playback. 928 * @since 8 929 * @syscap SystemCapability.Multimedia.Audio.Renderer 930 */ 931 INTERRUPT_HINT_UNDUCK = 5, 932 } 933 934 /** 935 * Enumerates the interrupt force types. 936 * @since 9 937 * @syscap SystemCapability.Multimedia.Audio.Renderer 938 */ 939 enum InterruptForceType { 940 /** 941 * Forced action taken by system. 942 * @since 9 943 * @syscap SystemCapability.Multimedia.Audio.Renderer 944 */ 945 INTERRUPT_FORCE = 0, 946 /** 947 * Share type, application can choose to take action or ignore. 948 * @since 9 949 * @syscap SystemCapability.Multimedia.Audio.Renderer 950 */ 951 INTERRUPT_SHARE = 1 952 } 953 954 /** 955 * Describes the interrupt event received by the app when playback is interrupted. 956 * @since 9 957 * @syscap SystemCapability.Multimedia.Audio.Renderer 958 */ 959 interface InterruptEvent { 960 /** 961 * Indicates whether the interruption has started or finished. 962 * @since 9 963 * @syscap SystemCapability.Multimedia.Audio.Renderer 964 */ 965 eventType: InterruptType; 966 967 /** 968 * Indicates whether the action is taken by system or to be taken by the app. 969 * @since 9 970 * @syscap SystemCapability.Multimedia.Audio.Renderer 971 */ 972 forceType: InterruptForceType; 973 974 /** 975 * Indicates the kind of action. 976 * @since 9 977 * @syscap SystemCapability.Multimedia.Audio.Renderer 978 */ 979 hintType: InterruptHint; 980 } 981 982 /** 983 * Enumerates interrupt action types. 984 * @since 7 985 * @syscap SystemCapability.Multimedia.Audio.Renderer 986 * @deprecated since 9 987 */ 988 enum InterruptActionType { 989 990 /** 991 * Focus gain event. 992 * @since 7 993 * @syscap SystemCapability.Multimedia.Audio.Renderer 994 * @deprecated since 9 995 */ 996 TYPE_ACTIVATED = 0, 997 998 /** 999 * Audio interruption event. 1000 * @since 7 1001 * @syscap SystemCapability.Multimedia.Audio.Renderer 1002 * @deprecated since 9 1003 */ 1004 TYPE_INTERRUPT = 1 1005 } 1006 1007 /** 1008 * Enumerates device change types. 1009 * @since 7 1010 * @syscap SystemCapability.Multimedia.Audio.Device 1011 */ 1012 enum DeviceChangeType { 1013 /** 1014 * Device connection. 1015 * @since 7 1016 * @syscap SystemCapability.Multimedia.Audio.Device 1017 */ 1018 CONNECT = 0, 1019 1020 /** 1021 * Device disconnection. 1022 * @since 7 1023 * @syscap SystemCapability.Multimedia.Audio.Device 1024 */ 1025 DISCONNECT = 1, 1026 } 1027 1028 /** 1029 * Enumerates audio scenes. 1030 * @since 8 1031 * @syscap SystemCapability.Multimedia.Audio.Communication 1032 */ 1033 enum AudioScene { 1034 /** 1035 * Default audio scene 1036 * @since 8 1037 * @syscap SystemCapability.Multimedia.Audio.Communication 1038 */ 1039 AUDIO_SCENE_DEFAULT = 0, 1040 /** 1041 * Ringing audio scene 1042 * @since 8 1043 * @syscap SystemCapability.Multimedia.Audio.Communication 1044 * @systemapi 1045 */ 1046 AUDIO_SCENE_RINGING = 1, 1047 /** 1048 * Phone call audio scene 1049 * @since 8 1050 * @syscap SystemCapability.Multimedia.Audio.Communication 1051 * @systemapi 1052 */ 1053 AUDIO_SCENE_PHONE_CALL = 2, 1054 /** 1055 * Voice chat audio scene 1056 * @since 8 1057 * @syscap SystemCapability.Multimedia.Audio.Communication 1058 */ 1059 AUDIO_SCENE_VOICE_CHAT = 3 1060 } 1061 1062 /** 1063 * Implements audio volume and audio device management. 1064 * @since 7 1065 * @syscap SystemCapability.Multimedia.Audio.Core 1066 */ 1067 interface AudioManager { 1068 /** 1069 * Sets the volume for a stream. This method uses an asynchronous callback to return the result. 1070 * @param volumeType Audio stream type. 1071 * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 1072 * @param callback Callback used to return the result. 1073 * @since 7 1074 * @syscap SystemCapability.Multimedia.Audio.Volume 1075 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1076 * @deprecated since 9 1077 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume 1078 */ 1079 setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void; 1080 /** 1081 * Sets the volume for a stream. This method uses a promise to return the result. 1082 * @param volumeType Audio stream type. 1083 * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 1084 * @returns Promise used to return the result. 1085 * @since 7 1086 * @syscap SystemCapability.Multimedia.Audio.Volume 1087 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1088 * @deprecated since 9 1089 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume 1090 */ 1091 setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>; 1092 /** 1093 * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. 1094 * @param volumeType Audio stream type. 1095 * @param callback Callback used to return the volume. 1096 * @since 7 1097 * @syscap SystemCapability.Multimedia.Audio.Volume 1098 * @deprecated since 9 1099 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume 1100 */ 1101 getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1102 /** 1103 * Obtains the volume of a stream. This method uses a promise to return the query result. 1104 * @param volumeType Audio stream type. 1105 * @returns Promise used to return the volume. 1106 * @since 7 1107 * @syscap SystemCapability.Multimedia.Audio.Volume 1108 * @deprecated since 9 1109 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume 1110 */ 1111 getVolume(volumeType: AudioVolumeType): Promise<number>; 1112 /** 1113 * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 1114 * @param volumeType Audio stream type. 1115 * @param callback Callback used to return the minimum volume. 1116 * @since 7 1117 * @syscap SystemCapability.Multimedia.Audio.Volume 1118 * @deprecated since 9 1119 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume 1120 */ 1121 getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1122 /** 1123 * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. 1124 * @param volumeType Audio stream type. 1125 * @returns Promise used to return the minimum volume. 1126 * @since 7 1127 * @syscap SystemCapability.Multimedia.Audio.Volume 1128 * @deprecated since 9 1129 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume 1130 */ 1131 getMinVolume(volumeType: AudioVolumeType): Promise<number>; 1132 /** 1133 * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 1134 * @param volumeType Audio stream type. 1135 * @param callback Callback used to return the maximum volume. 1136 * @since 7 1137 * @syscap SystemCapability.Multimedia.Audio.Volume 1138 * @deprecated since 9 1139 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume 1140 */ 1141 getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1142 /** 1143 * Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result. 1144 * @param volumeType Audio stream type. 1145 * @returns Promise used to return the maximum volume. 1146 * @since 7 1147 * @syscap SystemCapability.Multimedia.Audio.Volume 1148 * @deprecated since 9 1149 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume 1150 */ 1151 getMaxVolume(volumeType: AudioVolumeType): Promise<number>; 1152 /** 1153 * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. 1154 * @param deviceFlag Audio device flag. 1155 * @param callback Callback used to return the device list. 1156 * @since 7 1157 * @syscap SystemCapability.Multimedia.Audio.Device 1158 * @deprecated since 9 1159 * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices 1160 */ 1161 getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void; 1162 /** 1163 * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. 1164 * @param deviceFlag Audio device flag. 1165 * @returns Promise used to return the device list. 1166 * @since 7 1167 * @syscap SystemCapability.Multimedia.Audio.Device 1168 * @deprecated since 9 1169 * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices 1170 */ 1171 getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>; 1172 /** 1173 * Mutes a stream. This method uses an asynchronous callback to return the result. 1174 * @param volumeType Audio stream type. 1175 * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite. 1176 * @param callback Callback used to return the result. 1177 * @since 7 1178 * @syscap SystemCapability.Multimedia.Audio.Volume 1179 * @deprecated since 9 1180 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute 1181 */ 1182 mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void; 1183 /** 1184 * Mutes a stream. This method uses a promise to return the result. 1185 * @param volumeType Audio stream type. 1186 * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite. 1187 * @returns Promise used to return the result. 1188 * @since 7 1189 * @syscap SystemCapability.Multimedia.Audio.Volume 1190 * @deprecated since 9 1191 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute 1192 */ 1193 mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>; 1194 /** 1195 * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. 1196 * @param volumeType Audio stream type. 1197 * @param callback Callback used to return the mute status of the stream. The value true means that the stream is 1198 * muted, and false means the opposite. 1199 * @since 7 1200 * @syscap SystemCapability.Multimedia.Audio.Volume 1201 * @deprecated since 9 1202 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute 1203 */ 1204 isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 1205 /** 1206 * Checks whether a stream is muted. This method uses a promise to return the result. 1207 * @param volumeType Audio stream type. 1208 * @returns Promise used to return the mute status of the stream. The value true means that the stream is muted, 1209 * and false means the opposite. 1210 * @since 7 1211 * @syscap SystemCapability.Multimedia.Audio.Volume 1212 * @deprecated since 9 1213 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute 1214 */ 1215 isMute(volumeType: AudioVolumeType): Promise<boolean>; 1216 /** 1217 * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. 1218 * @param volumeType Audio stream type. 1219 * @param callback Callback used to return the active status of the stream. The value true means that the stream is 1220 * active, and false means the opposite. 1221 * @since 7 1222 * @syscap SystemCapability.Multimedia.Audio.Volume 1223 * @deprecated since 9 1224 * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive 1225 */ 1226 isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 1227 /** 1228 * Checks whether a stream is active. This method uses a promise to return the query result. 1229 * @param volumeType Audio stream type. 1230 * @returns Promise used to return the active status of the stream. The value true means that the stream is active, 1231 * and false means the opposite. 1232 * @since 7 1233 * @syscap SystemCapability.Multimedia.Audio.Volume 1234 * @deprecated since 9 1235 * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive 1236 */ 1237 isActive(volumeType: AudioVolumeType): Promise<boolean>; 1238 /** 1239 * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. 1240 * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. 1241 * @param callback Callback used to return the result. 1242 * @since 7 1243 * @syscap SystemCapability.Multimedia.Audio.Device 1244 * @permission ohos.permission.MICROPHONE 1245 * @deprecated since 9 1246 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute 1247 */ 1248 setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void; 1249 /** 1250 * Mutes or unmutes the microphone. This method uses a promise to return the result. 1251 * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. 1252 * @returns Promise used to return the result. 1253 * @since 7 1254 * @syscap SystemCapability.Multimedia.Audio.Device 1255 * @permission ohos.permission.MICROPHONE 1256 * @deprecated since 9 1257 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute 1258 */ 1259 setMicrophoneMute(mute: boolean): Promise<void>; 1260 /** 1261 * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. 1262 * @param Callback used to return the mute status of the microphone. The value true means that the microphone is 1263 * muted, and false means the opposite. 1264 * @since 7 1265 * @syscap SystemCapability.Multimedia.Audio.Device 1266 * @permission ohos.permission.MICROPHONE 1267 * @deprecated since 9 1268 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute 1269 */ 1270 isMicrophoneMute(callback: AsyncCallback<boolean>): void; 1271 /** 1272 * Checks whether the microphone is muted. This method uses a promise to return the query result. 1273 * @returns Promise used to return the mute status of the microphone. The value true means that the microphone is 1274 * muted, and false means the opposite. 1275 * @since 7 1276 * @syscap SystemCapability.Multimedia.Audio.Device 1277 * @permission ohos.permission.MICROPHONE 1278 * @deprecated since 9 1279 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute 1280 */ 1281 isMicrophoneMute(): Promise<boolean>; 1282 /** 1283 * Sets the ringer mode. This method uses an asynchronous callback to return the result. 1284 * @param mode Ringer mode. 1285 * @param callback Callback used to return the result. 1286 * @since 7 1287 * @syscap SystemCapability.Multimedia.Audio.Communication 1288 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1289 * @deprecated since 9 1290 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode 1291 */ 1292 setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void; 1293 /** 1294 * Sets the ringer mode. This method uses a promise to return the result. 1295 * @param mode Ringer mode. 1296 * @returns Promise used to return the result. 1297 * @since 7 1298 * @syscap SystemCapability.Multimedia.Audio.Communication 1299 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1300 * @deprecated since 9 1301 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode 1302 */ 1303 setRingerMode(mode: AudioRingMode): Promise<void>; 1304 /** 1305 * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. 1306 * @param callback Callback used to return the ringer mode. 1307 * @since 7 1308 * @syscap SystemCapability.Multimedia.Audio.Communication 1309 * @deprecated since 9 1310 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode 1311 */ 1312 getRingerMode(callback: AsyncCallback<AudioRingMode>): void; 1313 /** 1314 * Obtains the ringer mode. This method uses a promise to return the query result. 1315 * @returns Promise used to return the ringer mode. 1316 * @since 7 1317 * @syscap SystemCapability.Multimedia.Audio.Communication 1318 * @deprecated since 9 1319 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode 1320 */ 1321 getRingerMode(): Promise<AudioRingMode>; 1322 /** 1323 * Sets an audio parameter. This method uses an asynchronous callback to return the result. 1324 * @param key Key of the audio parameter to set. 1325 * @param value Value of the audio parameter to set. 1326 * @param callback Callback used to return the result. 1327 * @since 7 1328 * @syscap SystemCapability.Multimedia.Audio.Core 1329 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 1330 */ 1331 setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void; 1332 /** 1333 * Sets an audio parameter. This method uses a promise to return the result. 1334 * @param key Key of the audio parameter to set. 1335 * @param value Value of the audio parameter to set. 1336 * @returns Promise used to return the result. 1337 * @since 7 1338 * @syscap SystemCapability.Multimedia.Audio.Core 1339 * @permission ohos.permission.MODIFY_AUDIO_SETTINGS 1340 */ 1341 setAudioParameter(key: string, value: string): Promise<void>; 1342 /** 1343 * Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. 1344 * @param key Key of the audio parameter whose value is to be obtained. 1345 * @param callback Callback used to return the value of the audio parameter. 1346 * @since 7 1347 * @syscap SystemCapability.Multimedia.Audio.Core 1348 */ 1349 getAudioParameter(key: string, callback: AsyncCallback<string>): void; 1350 /** 1351 * Obtains the value of an audio parameter. This method uses a promise to return the query result. 1352 * @param key Key of the audio parameter whose value is to be obtained. 1353 * @returns Promise used to return the value of the audio parameter. 1354 * @since 7 1355 * @syscap SystemCapability.Multimedia.Audio.Core 1356 */ 1357 getAudioParameter(key: string): Promise<string>; 1358 /** 1359 * Sets a device to the active state. This method uses an asynchronous callback to return the result. 1360 * @param deviceType Audio device type. 1361 * @param active Active status to set. The value true means to set the device to the active status, and false 1362 * means the opposite. 1363 * @param callback Callback used to return the result. 1364 * @since 7 1365 * @syscap SystemCapability.Multimedia.Audio.Device 1366 * @deprecated since 9 1367 * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice 1368 */ 1369 setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback<void>): void; 1370 /** 1371 * Sets a device to the active state. This method uses a promise to return the result. 1372 * @param deviceType Audio device type. 1373 * @param active Active status to set. The value true means to set the device to the active status, and false 1374 * means the opposite. 1375 * @returns Promise used to return the result. 1376 * @since 7 1377 * @syscap SystemCapability.Multimedia.Audio.Device 1378 * @deprecated since 9 1379 * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice 1380 */ 1381 setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void>; 1382 /** 1383 * Checks whether a device is active. This method uses an asynchronous callback to return the query result. 1384 * @param deviceType Audio device type. 1385 * @param callback Callback used to return the active status of the device. 1386 * @since 7 1387 * @syscap SystemCapability.Multimedia.Audio.Device 1388 * @deprecated since 9 1389 * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive 1390 */ 1391 isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean>): void; 1392 /** 1393 * Checks whether a device is active. This method uses a promise to return the query result. 1394 * @param deviceType Audio device type. 1395 * @returns Promise used to return the active status of the device. 1396 * @since 7 1397 * @syscap SystemCapability.Multimedia.Audio.Device 1398 * @deprecated since 9 1399 * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive 1400 */ 1401 isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean>; 1402 /** 1403 * Listens for system volume change events. This method uses a callback to get volume change events. 1404 * @param callback Callback used to get the system volume change event. 1405 * @since 9 1406 * @syscap SystemCapability.Multimedia.Audio.Volume 1407 * @systemapi 1408 * @useinstead ohos.multimedia.audio.AudioVolumeManager#event:volumeChange 1409 */ 1410 on(type: 'volumeChange', callback: Callback<VolumeEvent>): void; 1411 /** 1412 * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. 1413 * @param callback Callback used to get the updated ringer mode. 1414 * @since 8 1415 * @syscap SystemCapability.Multimedia.Audio.Communication 1416 * @systemapi 1417 * @deprecated since 9 1418 * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#event:ringerModeChange 1419 */ 1420 on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void; 1421 /** 1422 * Sets the audio scene mode to change audio strategies. This method uses an asynchronous callback to return the 1423 * result. 1424 * @param scene Audio scene mode. 1425 * @param callback Callback used to return the result. 1426 * @since 8 1427 * @syscap SystemCapability.Multimedia.Audio.Communication 1428 * @systemapi 1429 */ 1430 setAudioScene(scene: AudioScene, callback: AsyncCallback<void> ): void; 1431 /** 1432 * Sets the audio scene mode to change audio strategies. This method uses a promise to return the result. 1433 * @param scene Audio scene mode. 1434 * @returns Promise used to return the result. 1435 * @since 8 1436 * @syscap SystemCapability.Multimedia.Audio.Communication 1437 * @systemapi 1438 */ 1439 setAudioScene(scene: AudioScene): Promise<void>; 1440 /** 1441 * Obtains the audio scene mode. This method uses an asynchronous callback to return the query result. 1442 * @param callback Callback used to return the audio scene mode. 1443 * @since 8 1444 * @syscap SystemCapability.Multimedia.Audio.Communication 1445 */ 1446 getAudioScene(callback: AsyncCallback<AudioScene>): void; 1447 /** 1448 * Obtains the audio scene mode. This method uses a promise to return the query result. 1449 * @returns Promise used to return the audio scene mode. 1450 * @since 8 1451 * @syscap SystemCapability.Multimedia.Audio.Communication 1452 */ 1453 getAudioScene(): Promise<AudioScene>; 1454 /** 1455 * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive 1456 * the callback. 1457 * @param callback Callback used to obtain the device update details. 1458 * @since 7 1459 * @syscap SystemCapability.Multimedia.Audio.Device 1460 * @deprecated since 9 1461 * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange 1462 */ 1463 on(type: 'deviceChange', callback: Callback<DeviceChangeAction>): void; 1464 1465 /** 1466 * UnSubscribes to device change events. 1467 * @param callback Callback used to obtain the device update details. 1468 * @since 7 1469 * @syscap SystemCapability.Multimedia.Audio.Device 1470 * @deprecated since 9 1471 * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange 1472 */ 1473 off(type: 'deviceChange', callback?: Callback<DeviceChangeAction>): void; 1474 1475 /** 1476 * Listens for audio interruption events. When the audio of an application is interrupted by another application, 1477 * the callback is invoked to notify the former application. 1478 * @param type Type of the event to listen for. Only the interrupt event is supported. 1479 * @param interrupt Parameters of the audio interruption event type. 1480 * @param callback Callback invoked for the audio interruption event. 1481 * @since 7 1482 * @syscap SystemCapability.Multimedia.Audio.Renderer 1483 */ 1484 on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback<InterruptAction>): void; 1485 1486 /** 1487 * Cancels the listening of audio interruption events. 1488 * @param type Type of the event to listen for. Only the interrupt event is supported. 1489 * @param interrupt Input parameters of the audio interruption event. 1490 * @param callback Callback invoked for the audio interruption event. 1491 * @since 7 1492 * @syscap SystemCapability.Multimedia.Audio.Renderer 1493 */ 1494 off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback<InterruptAction>): void; 1495 1496 /** 1497 * Obtains an {@link AudioVolumeManager} instance. 1498 * @returns AudioVolumeManager instance. 1499 * @since 9 1500 * @syscap SystemCapability.Multimedia.Audio.Volume 1501 */ 1502 getVolumeManager(): AudioVolumeManager; 1503 1504 /** 1505 * Obtains an {@link AudioStreamManager} instance. 1506 * @returns AudioStreamManager instance. 1507 * @since 9 1508 * @syscap SystemCapability.Multimedia.Audio.Core 1509 */ 1510 getStreamManager(): AudioStreamManager; 1511 1512 /** 1513 * Obtains an {@link AudioRoutingManager} instance. 1514 * @returns AudioRoutingManager instance. 1515 * @since 9 1516 * @syscap SystemCapability.Multimedia.Audio.Device 1517 */ 1518 getRoutingManager(): AudioRoutingManager; 1519 } 1520 1521 /** 1522 * Enumerates audio interrupt request result type. 1523 * @since 9 1524 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1525 * @systemapi 1526 */ 1527 enum InterruptRequestResultType { 1528 /** 1529 * Request audio interrupt success 1530 * @since 9 1531 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1532 * @systemapi 1533 */ 1534 INTERRUPT_REQUEST_GRANT = 0, 1535 /** 1536 * Request audio interrupt fail, may have higher priority type 1537 * @since 9 1538 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1539 * @systemapi 1540 */ 1541 INTERRUPT_REQUEST_REJECT = 1 1542 } 1543 1544 /** 1545 * Describes audio interrupt operation results. 1546 * @since 9 1547 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1548 * @systemapi 1549 */ 1550 interface InterruptResult { 1551 /** 1552 * Interrupt request or abandon result. 1553 * @since 9 1554 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1555 * @systemapi 1556 */ 1557 requestResult: InterruptRequestResultType; 1558 /** 1559 * Interrupt node as a unit to receive interrupt change event. 1560 * @since 9 1561 * @syscap SystemCapability.Multimedia.Audio.Interrupt 1562 * @systemapi 1563 */ 1564 interruptNode: number; 1565 } 1566 1567 /** 1568 * Implements audio router management. 1569 * @since 9 1570 * @syscap SystemCapability.Multimedia.Audio.Device 1571 */ 1572 interface AudioRoutingManager { 1573 /** 1574 * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. 1575 * @param deviceFlag Audio device flag. 1576 * @param callback Callback used to return the device list. 1577 * @since 9 1578 * @syscap SystemCapability.Multimedia.Audio.Device 1579 */ 1580 getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void; 1581 /** 1582 * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. 1583 * @param deviceFlag Audio device flag. 1584 * @returns Promise used to return the device list. 1585 * @since 9 1586 * @syscap SystemCapability.Multimedia.Audio.Device 1587 */ 1588 getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>; 1589 1590 /** 1591 * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive 1592 * the callback. 1593 * @param deviceFlag Audio device flag. 1594 * @param callback Callback used to obtain the device update details. 1595 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1596 * @throws { BusinessError } 6800101 - if input parameter value error 1597 * @since 9 1598 * @syscap SystemCapability.Multimedia.Audio.Device 1599 */ 1600 on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback<DeviceChangeAction>): void; 1601 1602 /** 1603 * UnSubscribes to device change events. 1604 * @param callback Callback used to obtain the device update details. 1605 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1606 * @throws { BusinessError } 6800101 - if input parameter value error 1607 * @since 9 1608 * @syscap SystemCapability.Multimedia.Audio.Device 1609 */ 1610 off(type: 'deviceChange', callback?: Callback<DeviceChangeAction>): void; 1611 1612 /** 1613 * Sets a device to the active state. This method uses an asynchronous callback to return the result. 1614 * @param deviceType Audio device type. 1615 * @param active Active status to set. The value true means to set the device to the active status, and false 1616 * means the opposite. 1617 * @param callback Callback used to return the result. 1618 * @since 9 1619 * @syscap SystemCapability.Multimedia.Audio.Communication 1620 */ 1621 setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean, callback: AsyncCallback<void>): void; 1622 /** 1623 * Sets a device to the active state. This method uses a promise to return the result. 1624 * @param deviceType Audio device type. 1625 * @param active Active status to set. The value true means to set the device to the active status, and false 1626 * means the opposite. 1627 * @returns Promise used to return the result. 1628 * @since 9 1629 * @syscap SystemCapability.Multimedia.Audio.Communication 1630 */ 1631 setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean): Promise<void>; 1632 1633 /** 1634 * Checks whether a device is active. This method uses an asynchronous callback to return the query result. 1635 * @param deviceType Audio device type. 1636 * @param callback Callback used to return the active status of the device. 1637 * @since 9 1638 * @syscap SystemCapability.Multimedia.Audio.Communication 1639 */ 1640 isCommunicationDeviceActive(deviceType: CommunicationDeviceType, callback: AsyncCallback<boolean>): void; 1641 /** 1642 * Checks whether a device is active. This method uses a promise to return the query result. 1643 * @param deviceType Audio device type. 1644 * @returns Promise used to return the active status of the device. 1645 * @since 9 1646 * @syscap SystemCapability.Multimedia.Audio.Communication 1647 */ 1648 isCommunicationDeviceActive(deviceType: CommunicationDeviceType): Promise<boolean>; 1649 1650 /** 1651 * Select the output device. This method uses an asynchronous callback to return the result. 1652 * @param outputAudioDevices Audio device description 1653 * @param callback Callback used to return the result. 1654 * @since 9 1655 * @syscap SystemCapability.Multimedia.Audio.Device 1656 * @systemapi 1657 */ 1658 selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 1659 /** 1660 * Select the output device. This method uses a promise to return the result. 1661 * @param outputAudioDevices Audio device description 1662 * @returns Promise used to return the result. 1663 * @since 9 1664 * @syscap SystemCapability.Multimedia.Audio.Device 1665 * @systemapi 1666 */ 1667 selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void>; 1668 1669 /** 1670 * Select the output device with desired AudioRenderer. This method uses an asynchronous callback to return the result. 1671 * @param filter Filter for AudioRenderer. 1672 * @param outputAudioDevices Audio device description 1673 * @param callback Callback used to return the result. 1674 * @since 9 1675 * @syscap SystemCapability.Multimedia.Audio.Device 1676 * @systemapi 1677 */ 1678 selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 1679 /** 1680 * Select the output device with desired AudioRenderer. This method uses a promise to return the result. 1681 * @param filter Filter for AudioRenderer. 1682 * @param outputAudioDevices Audio device description 1683 * @returns Promise used to return the result. 1684 * @since 9 1685 * @syscap SystemCapability.Multimedia.Audio.Device 1686 * @systemapi 1687 */ 1688 selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise<void>; 1689 1690 /** 1691 * Select the input device. This method uses an asynchronous callback to return the result. 1692 * @param inputAudioDevices Audio device description 1693 * @param callback Callback used to return the result. 1694 * @since 9 1695 * @syscap SystemCapability.Multimedia.Audio.Device 1696 * @systemapi 1697 */ 1698 selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void; 1699 /** 1700 * Select the input device. This method uses a promise to return the result. 1701 * @param inputAudioDevices Audio device description 1702 * @returns Promise used to return the result. 1703 * @since 9 1704 * @syscap SystemCapability.Multimedia.Audio.Device 1705 * @systemapi 1706 */ 1707 selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void>; 1708 } 1709 1710 /** 1711 * Implements audio stream management. 1712 * @since 9 1713 * @syscap SystemCapability.Multimedia.Audio.Core 1714 */ 1715 interface AudioStreamManager { 1716 /** 1717 * Get information of current existing audio renderers. 1718 * @param callback Callback used to return the information of current existing audio renderers. 1719 * @since 9 1720 * @syscap SystemCapability.Multimedia.Audio.Renderer 1721 */ 1722 getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeInfoArray>): void; 1723 /** 1724 * Get information of current existing audio renderers. 1725 * @returns Promise used to return the information of current existing audio renderers. 1726 * @since 9 1727 * @syscap SystemCapability.Multimedia.Audio.Renderer 1728 */ 1729 getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray>; 1730 1731 /** 1732 * Get information of current existing audio capturers. 1733 * @param callback Callback used to return the information of current existing audio capturers. 1734 * @since 9 1735 * @syscap SystemCapability.Multimedia.Audio.Renderer 1736 */ 1737 getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeInfoArray>): void; 1738 /** 1739 * Get information of current existing audio capturers. 1740 * @returns Promise used to return the information of current existing audio capturers. 1741 * @since 9 1742 * @syscap SystemCapability.Multimedia.Audio.Renderer 1743 */ 1744 getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray>; 1745 1746 /** 1747 * Listens for audio renderer change events. When there is any audio renderer change, 1748 * registered clients will receive the callback. 1749 * @param type Type of the event to listen for. Only the audioRendererChange event is supported. 1750 * @param callback Callback invoked for the audio renderer change event. 1751 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1752 * @throws { BusinessError } 6800101 - if input parameter value error 1753 * @since 9 1754 * @syscap SystemCapability.Multimedia.Audio.Renderer 1755 */ 1756 on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArray>): void; 1757 1758 /** 1759 * UnSubscribes to audio renderer change events. 1760 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1761 * @throws { BusinessError } 6800101 - if input parameter value error 1762 * @since 9 1763 * @syscap SystemCapability.Multimedia.Audio.Renderer 1764 */ 1765 off(type: "audioRendererChange"): void; 1766 1767 /** 1768 * Listens for audio capturer change events. When there is any audio capturer change, 1769 * registered clients will receive the callback. 1770 * @param type Type of the event to listen for. Only the audioCapturerChange event is supported. 1771 * @param callback Callback invoked for the audio capturer change event. 1772 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1773 * @throws { BusinessError } 6800101 - if input parameter value error 1774 * @since 9 1775 * @syscap SystemCapability.Multimedia.Audio.Capturer 1776 */ 1777 on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArray>): void; 1778 1779 /** 1780 * UnSubscribes to audio capturer change events. 1781 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1782 * @throws { BusinessError } 6800101 - if input parameter value error 1783 * @since 9 1784 * @syscap SystemCapability.Multimedia.Audio.Capturer 1785 */ 1786 off(type: "audioCapturerChange"): void; 1787 1788 /** 1789 * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. 1790 * @param volumeType Audio stream type. 1791 * @param callback Callback used to return the active status of the stream. The value true means that the stream is 1792 * active, and false means the opposite. 1793 * @since 9 1794 * @syscap SystemCapability.Multimedia.Audio.Renderer 1795 */ 1796 isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 1797 /** 1798 * Checks whether a stream is active. This method uses a promise to return the query result. 1799 * @param volumeType Audio stream type. 1800 * @returns Promise used to return the active status of the stream. The value true means that the stream is active, 1801 * and false means the opposite. 1802 * @since 9 1803 * @syscap SystemCapability.Multimedia.Audio.Renderer 1804 */ 1805 isActive(volumeType: AudioVolumeType): Promise<boolean>; 1806 } 1807 1808 /** 1809 * Implements audio volume management. 1810 * @since 9 1811 * @syscap SystemCapability.Multimedia.Audio.Volume 1812 */ 1813 interface AudioVolumeManager { 1814 /** 1815 * Get the volume group list for a networkId. This method uses an asynchronous callback to return the result. 1816 * @param networkId Distributed deice net work id 1817 * @param callback Callback used to return the result. 1818 * @since 9 1819 * @syscap SystemCapability.Multimedia.Audio.Volume 1820 * @systemapi 1821 */ 1822 getVolumeGroupInfos(networkId: string, callback: AsyncCallback<VolumeGroupInfos>): void; 1823 /** 1824 * Get the volume group list for a networkId. This method uses a promise to return the result. 1825 * @param networkId Distributed deice net work id 1826 * @returns Promise used to return the result. 1827 * @since 9 1828 * @syscap SystemCapability.Multimedia.Audio.Volume 1829 * @systemapi 1830 */ 1831 getVolumeGroupInfos(networkId: string): Promise<VolumeGroupInfos>; 1832 1833 /** 1834 * Obtains an AudioVolumeGroupManager instance. This method uses an asynchronous callback to return the result. 1835 * @param groupId volume group id, use LOCAL_VOLUME_GROUP_ID in default 1836 * @param callback Callback used to return the result. 1837 * @since 9 1838 * @syscap SystemCapability.Multimedia.Audio.Volume 1839 */ 1840 getVolumeGroupManager(groupId: number, callback: AsyncCallback<AudioVolumeGroupManager>): void; 1841 /** 1842 * Obtains an AudioVolumeGroupManager instance. This method uses a promise to return the result. 1843 * @param groupId volume group id, use LOCAL_VOLUME_GROUP_ID in default 1844 * @param callback Callback used to return the result. 1845 * @since 9 1846 * @syscap SystemCapability.Multimedia.Audio.Volume 1847 */ 1848 getVolumeGroupManager(groupId: number): Promise<AudioVolumeGroupManager>; 1849 1850 /** 1851 * Listens for system volume change events. This method uses a callback to get volume change events. 1852 * @param callback Callback used to get the system volume change event. 1853 * @throws { BusinessError } 401 - if input parameter type or number mismatch 1854 * @throws { BusinessError } 6800101 - if input parameter value error 1855 * @since 9 1856 * @syscap SystemCapability.Multimedia.Audio.Volume 1857 */ 1858 on(type: 'volumeChange', callback: Callback<VolumeEvent>): void; 1859 } 1860 1861 /** 1862 * Implements audio volume group management. 1863 * @since 9 1864 * @syscap SystemCapability.Multimedia.Audio.Volume 1865 */ 1866 interface AudioVolumeGroupManager { 1867 /** 1868 * Sets the volume for a stream. This method uses an asynchronous callback to return the result. 1869 * @param volumeType Audio stream type. 1870 * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 1871 * @param callback Callback used to return the result. 1872 * @since 9 1873 * @syscap SystemCapability.Multimedia.Audio.Volume 1874 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1875 * @systemapi 1876 */ 1877 setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void; 1878 /** 1879 * Sets the volume for a stream. This method uses a promise to return the result. 1880 * @param volumeType Audio stream type. 1881 * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. 1882 * @returns Promise used to return the result. 1883 * @since 9 1884 * @syscap SystemCapability.Multimedia.Audio.Volume 1885 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1886 * @systemapi 1887 */ 1888 setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>; 1889 1890 /** 1891 * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. 1892 * @param volumeType Audio stream type. 1893 * @param callback Callback used to return the volume. 1894 * @since 9 1895 * @syscap SystemCapability.Multimedia.Audio.Volume 1896 */ 1897 getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1898 /** 1899 * Obtains the volume of a stream. This method uses a promise to return the query result. 1900 * @param volumeType Audio stream type. 1901 * @returns Promise used to return the volume. 1902 * @since 9 1903 * @syscap SystemCapability.Multimedia.Audio.Volume 1904 */ 1905 getVolume(volumeType: AudioVolumeType): Promise<number>; 1906 1907 /** 1908 * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 1909 * @param volumeType Audio stream type. 1910 * @param callback Callback used to return the minimum volume. 1911 * @since 9 1912 * @syscap SystemCapability.Multimedia.Audio.Volume 1913 */ 1914 getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1915 /** 1916 * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. 1917 * @param volumeType Audio stream type. 1918 * @returns Promise used to return the minimum volume. 1919 * @since 9 1920 * @syscap SystemCapability.Multimedia.Audio.Volume 1921 */ 1922 getMinVolume(volumeType: AudioVolumeType): Promise<number>; 1923 1924 /** 1925 * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. 1926 * @param volumeType Audio stream type. 1927 * @param callback Callback used to return the maximum volume. 1928 * @since 9 1929 * @syscap SystemCapability.Multimedia.Audio.Volume 1930 */ 1931 getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void; 1932 /** 1933 * Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result. 1934 * @param volumeType Audio stream type. 1935 * @returns Promise used to return the maximum volume. 1936 * @since 9 1937 * @syscap SystemCapability.Multimedia.Audio.Volume 1938 */ 1939 getMaxVolume(volumeType: AudioVolumeType): Promise<number>; 1940 1941 /** 1942 * Mutes a stream. This method uses an asynchronous callback to return the result. 1943 * @param volumeType Audio stream type. 1944 * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite. 1945 * @param callback Callback used to return the result. 1946 * @since 9 1947 * @syscap SystemCapability.Multimedia.Audio.Volume 1948 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1949 * @systemapi 1950 */ 1951 mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void; 1952 /** 1953 * Mutes a stream. This method uses a promise to return the result. 1954 * @param volumeType Audio stream type. 1955 * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite. 1956 * @returns Promise used to return the result. 1957 * @since 9 1958 * @syscap SystemCapability.Multimedia.Audio.Volume 1959 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1960 * @systemapi 1961 */ 1962 mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>; 1963 1964 /** 1965 * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. 1966 * @param volumeType Audio stream type. 1967 * @param callback Callback used to return the mute status of the stream. The value true means that the stream is 1968 * muted, and false means the opposite. 1969 * @since 9 1970 * @syscap SystemCapability.Multimedia.Audio.Volume 1971 */ 1972 isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void; 1973 /** 1974 * Checks whether a stream is muted. This method uses a promise to return the result. 1975 * @param volumeType Audio stream type. 1976 * @returns Promise used to return the mute status of the stream. The value true means that the stream is muted, 1977 * and false means the opposite. 1978 * @since 9 1979 * @syscap SystemCapability.Multimedia.Audio.Volume 1980 */ 1981 isMute(volumeType: AudioVolumeType): Promise<boolean>; 1982 1983 /** 1984 * Sets the ringer mode. This method uses an asynchronous callback to return the result. 1985 * @param mode Ringer mode. 1986 * @param callback Callback used to return the result. 1987 * @since 9 1988 * @syscap SystemCapability.Multimedia.Audio.Volume 1989 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 1990 * @systemapi 1991 */ 1992 setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void; 1993 /** 1994 * Sets the ringer mode. This method uses a promise to return the result. 1995 * @param mode Ringer mode. 1996 * @returns Promise used to return the result. 1997 * @since 9 1998 * @syscap SystemCapability.Multimedia.Audio.Volume 1999 * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY 2000 * @systemapi 2001 */ 2002 setRingerMode(mode: AudioRingMode): Promise<void>; 2003 2004 /** 2005 * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. 2006 * @param callback Callback used to return the ringer mode. 2007 * @since 9 2008 * @syscap SystemCapability.Multimedia.Audio.Volume 2009 */ 2010 getRingerMode(callback: AsyncCallback<AudioRingMode>): void; 2011 /** 2012 * Obtains the ringer mode. This method uses a promise to return the query result. 2013 * @returns Promise used to return the ringer mode. 2014 * @since 9 2015 * @syscap SystemCapability.Multimedia.Audio.Volume 2016 */ 2017 getRingerMode(): Promise<AudioRingMode>; 2018 2019 /** 2020 * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. 2021 * @param callback Callback used to get the updated ringer mode. 2022 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2023 * @throws { BusinessError } 6800101 - if input parameter value error 2024 * @since 9 2025 * @syscap SystemCapability.Multimedia.Audio.Volume 2026 */ 2027 on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void; 2028 2029 /** 2030 * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. 2031 * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. 2032 * @param callback Callback used to return the result. 2033 * @since 9 2034 * @syscap SystemCapability.Multimedia.Audio.Volume 2035 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 2036 */ 2037 setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void; 2038 /** 2039 * Mutes or unmutes the microphone. This method uses a promise to return the result. 2040 * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. 2041 * @returns Promise used to return the result. 2042 * @since 9 2043 * @syscap SystemCapability.Multimedia.Audio.Volume 2044 * @permission ohos.permission.MANAGE_AUDIO_CONFIG 2045 */ 2046 setMicrophoneMute(mute: boolean): Promise<void>; 2047 2048 /** 2049 * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. 2050 * @param Callback used to return the mute status of the microphone. The value true means that the microphone is 2051 * muted, and false means the opposite. 2052 * @since 9 2053 * @syscap SystemCapability.Multimedia.Audio.Volume 2054 */ 2055 isMicrophoneMute(callback: AsyncCallback<boolean>): void; 2056 /** 2057 * Checks whether the microphone is muted. This method uses a promise to return the query result. 2058 * @returns Promise used to return the mute status of the microphone. The value true means that the microphone is 2059 * muted, and false means the opposite. 2060 * @since 9 2061 * @syscap SystemCapability.Multimedia.Audio.Volume 2062 */ 2063 isMicrophoneMute(): Promise<boolean>; 2064 2065 /** 2066 * Listens for system microphone state change events. This method uses a callback to get microphone change events. 2067 * @param callback Callback used to get the system microphone state change event. 2068 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2069 * @throws { BusinessError } 6800101 - if input parameter value error 2070 * @since 9 2071 * @syscap SystemCapability.Multimedia.Audio.Volume 2072 */ 2073 on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void; 2074 } 2075 2076 /** 2077 * Describes an audio volume group. 2078 * @since 9 2079 * @syscap SystemCapability.Multimedia.Audio.Volume 2080 * @systemapi 2081 */ 2082 enum ConnectType { 2083 /** 2084 * Connect type for local device. 2085 * @since 9 2086 * @syscap SystemCapability.Multimedia.Audio.Volume 2087 */ 2088 CONNECT_TYPE_LOCAL = 1, 2089 2090 /** 2091 * Connect type for distributed device. 2092 * @since 9 2093 * @syscap SystemCapability.Multimedia.Audio.Volume 2094 */ 2095 CONNECT_TYPE_DISTRIBUTED = 2 2096 } 2097 2098 /** 2099 * Describes an audio volume group. 2100 * @since 9 2101 * @syscap SystemCapability.Multimedia.Audio.Volume 2102 * @systemapi 2103 */ 2104 interface VolumeGroupInfo { 2105 /** 2106 * Device network id. 2107 * @since 9 2108 * @syscap SystemCapability.Multimedia.Audio.Volume 2109 * @systemapi 2110 */ 2111 readonly networkId: string; 2112 2113 /** 2114 * Volume group id. 2115 * @since 9 2116 * @syscap SystemCapability.Multimedia.Audio.Volume 2117 */ 2118 readonly groupId: number; 2119 2120 /** 2121 * Volume mapping group id. 2122 * @since 9 2123 * @syscap SystemCapability.Multimedia.Audio.Volume 2124 */ 2125 readonly mappingId: number; 2126 2127 /** 2128 * Volume group name. 2129 * @since 9 2130 * @syscap SystemCapability.Multimedia.Audio.Volume 2131 */ 2132 readonly groupName: string; 2133 2134 /** 2135 * Connect type of device for this group. 2136 * @since 9 2137 * @syscap SystemCapability.Multimedia.Audio.Volume 2138 */ 2139 readonly type: ConnectType; 2140 } 2141 2142 /** 2143 * Array of VolumeGroupInfos, which is read-only. 2144 * @since 9 2145 * @syscap SystemCapability.Multimedia.Audio.Volume 2146 * @systemapi 2147 */ 2148 type VolumeGroupInfos = Array<Readonly<VolumeGroupInfo>>; 2149 2150 /** 2151 * Array of AudioRendererChangeInfo, which is read-only. 2152 * @since 9 2153 * @syscap SystemCapability.Multimedia.Audio.Renderer 2154 */ 2155 type AudioRendererChangeInfoArray = Array<Readonly<AudioRendererChangeInfo>>; 2156 2157 /** 2158 * Describes audio renderer change information. 2159 * @since 9 2160 * @syscap SystemCapability.Multimedia.Audio.Renderer 2161 */ 2162 interface AudioRendererChangeInfo { 2163 /** 2164 * Audio stream unique id. 2165 * @since 9 2166 * @syscap SystemCapability.Multimedia.Audio.Renderer 2167 */ 2168 readonly streamId: number; 2169 2170 /** 2171 * Uid for audio renderer client application. 2172 * @since 9 2173 * @syscap SystemCapability.Multimedia.Audio.Renderer 2174 * @systemapi 2175 */ 2176 readonly clientUid: number; 2177 2178 /** 2179 * Audio renderer information. 2180 * @since 9 2181 * @syscap SystemCapability.Multimedia.Audio.Renderer 2182 */ 2183 readonly rendererInfo: AudioRendererInfo; 2184 2185 /** 2186 * Audio state. 2187 * @since 9 2188 * @syscap SystemCapability.Multimedia.Audio.Renderer 2189 * @systemapi 2190 */ 2191 readonly rendererState: AudioState; 2192 2193 /** 2194 * Audio output devices. 2195 * @since 9 2196 * @syscap SystemCapability.Multimedia.Audio.Renderer 2197 */ 2198 readonly deviceDescriptors: AudioDeviceDescriptors; 2199 } 2200 2201 /** 2202 * Array of AudioCapturerChangeInfo, which is read-only. 2203 * @since 9 2204 * @syscap SystemCapability.Multimedia.Audio.Capturer 2205 */ 2206 type AudioCapturerChangeInfoArray = Array<Readonly<AudioCapturerChangeInfo>>; 2207 2208 /** 2209 * Describes audio capturer change information. 2210 * @since 9 2211 * @syscap SystemCapability.Multimedia.Audio.Capturer 2212 */ 2213 interface AudioCapturerChangeInfo { 2214 /** 2215 * Audio stream unique id. 2216 * @since 9 2217 * @syscap SystemCapability.Multimedia.Audio.Capturer 2218 */ 2219 readonly streamId: number; 2220 2221 /** 2222 * Uid for audio capturer client application. 2223 * @since 9 2224 * @syscap SystemCapability.Multimedia.Audio.Capturer 2225 * @systemapi 2226 */ 2227 readonly clientUid: number; 2228 2229 /** 2230 * Audio capturer information. 2231 * @since 9 2232 * @syscap SystemCapability.Multimedia.Audio.Capturer 2233 */ 2234 readonly capturerInfo: AudioCapturerInfo; 2235 2236 /** 2237 * Audio state. 2238 * @since 9 2239 * @syscap SystemCapability.Multimedia.Audio.Capturer 2240 * @systemapi 2241 */ 2242 readonly capturerState: AudioState; 2243 2244 /** 2245 * Audio input devices. 2246 * @since 9 2247 * @syscap SystemCapability.Multimedia.Audio.Capturer 2248 */ 2249 readonly deviceDescriptors: AudioDeviceDescriptors; 2250 } 2251 2252 /** 2253 * Describes an audio device. 2254 * @since 7 2255 * @syscap SystemCapability.Multimedia.Audio.Device 2256 */ 2257 interface AudioDeviceDescriptor { 2258 /** 2259 * Audio device role. 2260 * @since 7 2261 * @syscap SystemCapability.Multimedia.Audio.Device 2262 */ 2263 readonly deviceRole: DeviceRole; 2264 2265 /** 2266 * Audio device type. 2267 * @since 7 2268 * @syscap SystemCapability.Multimedia.Audio.Device 2269 */ 2270 readonly deviceType: DeviceType; 2271 2272 /** 2273 * Audio device id. 2274 * @since 9 2275 * @syscap SystemCapability.Multimedia.Audio.Device 2276 */ 2277 readonly id: number; 2278 2279 /** 2280 * Audio device name. 2281 * @since 9 2282 * @syscap SystemCapability.Multimedia.Audio.Device 2283 */ 2284 readonly name: string; 2285 2286 /** 2287 * Audio device address. 2288 * @since 9 2289 * @syscap SystemCapability.Multimedia.Audio.Device 2290 */ 2291 readonly address: string; 2292 2293 /** 2294 * Supported sampling rates. 2295 * @since 9 2296 * @syscap SystemCapability.Multimedia.Audio.Device 2297 */ 2298 readonly sampleRates: Array<number>; 2299 2300 /** 2301 * Supported channel counts. 2302 * @since 9 2303 * @syscap SystemCapability.Multimedia.Audio.Device 2304 */ 2305 readonly channelCounts: Array<number>; 2306 2307 /** 2308 * Supported channel masks. 2309 * @since 9 2310 * @syscap SystemCapability.Multimedia.Audio.Device 2311 */ 2312 readonly channelMasks: Array<number>; 2313 /** 2314 * Device network id 2315 * @since 9 2316 * @syscap SystemCapability.Multimedia.Audio.Device 2317 * @systemapi 2318 */ 2319 readonly networkId: string; 2320 /** 2321 * Interrupt group id 2322 * @since 9 2323 * @syscap SystemCapability.Multimedia.Audio.Device 2324 * @systemapi 2325 */ 2326 readonly interruptGroupId: number; 2327 /** 2328 * Volume group id 2329 * @since 9 2330 * @syscap SystemCapability.Multimedia.Audio.Device 2331 * @systemapi 2332 */ 2333 readonly volumeGroupId: number; 2334 } 2335 2336 /** 2337 * Array of AudioDeviceDescriptors, which is read-only. 2338 * @since 7 2339 * @syscap SystemCapability.Multimedia.Audio.Device 2340 */ 2341 type AudioDeviceDescriptors = Array<Readonly<AudioDeviceDescriptor>>; 2342 2343 /** 2344 * Describes the volume event received by the app when the volume is changed. 2345 * @since 9 2346 * @syscap SystemCapability.Multimedia.Audio.Volume 2347 */ 2348 interface VolumeEvent { 2349 /** 2350 * Volume type of the current stream. 2351 * @since 9 2352 * @syscap SystemCapability.Multimedia.Audio.Volume 2353 */ 2354 volumeType: AudioVolumeType; 2355 /** 2356 * Volume level. 2357 * @since 9 2358 * @syscap SystemCapability.Multimedia.Audio.Volume 2359 */ 2360 volume: number; 2361 /** 2362 * Whether to show the volume change in UI. 2363 * @since 9 2364 * @syscap SystemCapability.Multimedia.Audio.Volume 2365 */ 2366 updateUi: boolean; 2367 /** 2368 * volumeGroup id 2369 * @since 9 2370 * @syscap SystemCapability.Multimedia.Audio.Volume 2371 * @systemapi 2372 */ 2373 volumeGroupId: number; 2374 /** 2375 * Device network id 2376 * @since 9 2377 * @syscap SystemCapability.Multimedia.Audio.Volume 2378 * @systemapi 2379 */ 2380 networkId: string; 2381 } 2382 2383 /** 2384 * Describes the callback invoked for audio interruption or focus gain events.When the audio of an application 2385 * is interrupted by another application, the callback is invoked to notify the former application. 2386 * @since 7 2387 * @syscap SystemCapability.Multimedia.Audio.Renderer 2388 * @deprecated since 9 2389 * @useinstead ohos.multimedia.audio.InterruptEvent 2390 */ 2391 interface InterruptAction { 2392 2393 /** 2394 * Event type. 2395 * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. 2396 * @since 7 2397 * @syscap SystemCapability.Multimedia.Audio.Renderer 2398 * @deprecated since 9 2399 */ 2400 actionType: InterruptActionType; 2401 2402 /** 2403 * Type of the audio interruption event. 2404 * @since 7 2405 * @syscap SystemCapability.Multimedia.Audio.Renderer 2406 * @deprecated since 9 2407 */ 2408 type?: InterruptType; 2409 2410 /** 2411 * Hint for the audio interruption event. 2412 * @since 7 2413 * @syscap SystemCapability.Multimedia.Audio.Renderer 2414 * @deprecated since 9 2415 */ 2416 hint?: InterruptHint; 2417 2418 /** 2419 * Whether the focus is gained or released. The value true means that the focus is gained or released, 2420 * and false means that the focus fails to be gained or released. 2421 * @since 7 2422 * @syscap SystemCapability.Multimedia.Audio.Renderer 2423 * @deprecated since 9 2424 */ 2425 activated?: boolean; 2426 } 2427 2428 /** 2429 * Describes input parameters of audio listening events. 2430 * @since 7 2431 * @syscap SystemCapability.Multimedia.Audio.Renderer 2432 * @deprecated since 9 2433 */ 2434 interface AudioInterrupt { 2435 2436 /** 2437 * Audio stream usage type. 2438 * @since 7 2439 * @syscap SystemCapability.Multimedia.Audio.Renderer 2440 * @deprecated since 9 2441 */ 2442 streamUsage: StreamUsage; 2443 2444 /** 2445 * Type of the media interrupted. 2446 * @since 7 2447 * @syscap SystemCapability.Multimedia.Audio.Renderer 2448 * @deprecated since 9 2449 */ 2450 contentType: ContentType; 2451 2452 /** 2453 * Whether audio playback can be paused when it is interrupted. 2454 * The value true means that audio playback can be paused when it is interrupted, and false means the opposite. 2455 * @since 7 2456 * @syscap SystemCapability.Multimedia.Audio.Renderer 2457 * @deprecated since 9 2458 */ 2459 pauseWhenDucked: boolean; 2460 } 2461 2462 /** 2463 * Describes the microphone state change event received by the app when the microphone state is changed. 2464 * @since 9 2465 * @syscap SystemCapability.Multimedia.Audio.Device 2466 */ 2467 interface MicStateChangeEvent { 2468 /** 2469 * Mic mute state. 2470 * @since 9 2471 * @syscap SystemCapability.Multimedia.Audio.Device 2472 */ 2473 mute: boolean; 2474 } 2475 /** 2476 * Describes the device change type and device information. 2477 * @since 7 2478 * @syscap SystemCapability.Multimedia.Audio.Device 2479 */ 2480 interface DeviceChangeAction { 2481 /** 2482 * Device change type. 2483 * @since 7 2484 * @syscap SystemCapability.Multimedia.Audio.Device 2485 */ 2486 type: DeviceChangeType; 2487 2488 /** 2489 * Device information. 2490 * @since 7 2491 * @syscap SystemCapability.Multimedia.Audio.Device 2492 */ 2493 deviceDescriptors: AudioDeviceDescriptors; 2494 } 2495 2496 /** 2497 * Provides audio playback APIs. 2498 * @since 8 2499 * @syscap SystemCapability.Multimedia.Audio.Renderer 2500 */ 2501 interface AudioRenderer { 2502 /** 2503 * Defines the current render state. 2504 * @since 8 2505 * @syscap SystemCapability.Multimedia.Audio.Renderer 2506 */ 2507 readonly state: AudioState; 2508 2509 /** 2510 * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous 2511 * callback to return the result. 2512 * @param callback Callback used to return the renderer information. 2513 * @since 8 2514 * @syscap SystemCapability.Multimedia.Audio.Renderer 2515 */ 2516 getRendererInfo(callback: AsyncCallback<AudioRendererInfo>): void; 2517 /** 2518 * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to 2519 * return the result. 2520 * @returns Promise used to return the renderer information. 2521 * @since 8 2522 * @syscap SystemCapability.Multimedia.Audio.Renderer 2523 */ 2524 getRendererInfo(): Promise<AudioRendererInfo>; 2525 2526 /** 2527 * Obtains the renderer stream information. This method uses an asynchronous callback to return the result. 2528 * @param callback Callback used to return the stream information. 2529 * @since 8 2530 * @syscap SystemCapability.Multimedia.Audio.Renderer 2531 */ 2532 getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void; 2533 /** 2534 * Obtains the renderer stream information. This method uses a promise to return the result. 2535 * @returns Promise used to return the stream information. 2536 * @since 8 2537 * @syscap SystemCapability.Multimedia.Audio.Renderer 2538 */ 2539 getStreamInfo(): Promise<AudioStreamInfo>; 2540 2541 /** 2542 * Obtains the renderer stream id. This method uses an asynchronous callback to return the result. 2543 * @param callback Callback used to return the stream id. 2544 * @since 9 2545 * @syscap SystemCapability.Multimedia.Audio.Renderer 2546 */ 2547 getAudioStreamId(callback: AsyncCallback<number>): void; 2548 /** 2549 * Obtains the renderer stream id. This method uses a promise to return the result. 2550 * @returns Promise used to return the stream id. 2551 * @since 9 2552 * @syscap SystemCapability.Multimedia.Audio.Renderer 2553 */ 2554 getAudioStreamId(): Promise<number>; 2555 2556 /** 2557 * Starts the renderer. This method uses an asynchronous callback to return the result. 2558 * @param callback Callback used to return the result. 2559 * @since 8 2560 * @syscap SystemCapability.Multimedia.Audio.Renderer 2561 */ 2562 start(callback: AsyncCallback<void>): void; 2563 /** 2564 * Starts the renderer. This method uses a promise to return the result. 2565 * @returns Promise used to return the result. 2566 * @since 8 2567 * @syscap SystemCapability.Multimedia.Audio.Renderer 2568 */ 2569 start(): Promise<void>; 2570 2571 /** 2572 * Writes the buffer. This method uses an asynchronous callback to return the result. 2573 * @param buffer Buffer to be written. 2574 * @param callback Returns the number of bytes written if the operation is successful; returns an error code 2575 * otherwise. 2576 * @since 8 2577 * @syscap SystemCapability.Multimedia.Audio.Renderer 2578 */ 2579 write(buffer: ArrayBuffer, callback: AsyncCallback<number>): void; 2580 /** 2581 * Writes the buffer. This method uses a promise to return the result. 2582 * @param buffer Buffer to be written. 2583 * @returns Returns the number of bytes written if the operation is successful; returns an error code otherwise. 2584 * @since 8 2585 * @syscap SystemCapability.Multimedia.Audio.Renderer 2586 */ 2587 write(buffer: ArrayBuffer): Promise<number>; 2588 2589 /** 2590 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an 2591 * asynchronous callback to return the result. 2592 * @param callback Callback used to return the timestamp. 2593 * @since 8 2594 * @syscap SystemCapability.Multimedia.Audio.Renderer 2595 */ 2596 getAudioTime(callback: AsyncCallback<number>): void; 2597 /** 2598 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a 2599 * promise to return the result. 2600 * @returns Promise used to return the timestamp. 2601 * @since 8 2602 * @syscap SystemCapability.Multimedia.Audio.Renderer 2603 */ 2604 getAudioTime(): Promise<number>; 2605 2606 /** 2607 * Drains the playback buffer. This method uses an asynchronous callback to return the result. 2608 * @param callback Callback used to return the result. 2609 * @since 8 2610 * @syscap SystemCapability.Multimedia.Audio.Renderer 2611 */ 2612 drain(callback: AsyncCallback<void>): void; 2613 /** 2614 * Drains the playback buffer. This method uses a promise to return the result. 2615 * @returns Promise used to return the result. 2616 * @since 8 2617 * @syscap SystemCapability.Multimedia.Audio.Renderer 2618 */ 2619 drain(): Promise<void>; 2620 2621 /** 2622 * Pauses rendering. This method uses an asynchronous callback to return the result. 2623 * @param callback Callback used to return the result. 2624 * @since 8 2625 * @syscap SystemCapability.Multimedia.Audio.Renderer 2626 */ 2627 pause(callback: AsyncCallback<void>): void; 2628 /** 2629 * Pauses rendering. This method uses a promise to return the result. 2630 * @returns Promise used to return the result. 2631 * @since 8 2632 * @syscap SystemCapability.Multimedia.Audio.Renderer 2633 */ 2634 pause(): Promise<void>; 2635 2636 /** 2637 * Stops rendering. This method uses an asynchronous callback to return the result. 2638 * @param callback Callback used to return the result. 2639 * @since 8 2640 * @syscap SystemCapability.Multimedia.Audio.Renderer 2641 */ 2642 stop(callback: AsyncCallback<void>): void; 2643 /** 2644 * Stops rendering. This method uses a promise to return the result. 2645 * @returns Promise used to return the result. 2646 * @since 8 2647 * @syscap SystemCapability.Multimedia.Audio.Renderer 2648 */ 2649 stop(): Promise<void>; 2650 2651 /** 2652 * Releases the renderer. This method uses an asynchronous callback to return the result. 2653 * @param callback Callback used to return the result. 2654 * @since 8 2655 * @syscap SystemCapability.Multimedia.Audio.Renderer 2656 */ 2657 release(callback: AsyncCallback<void>): void; 2658 /** 2659 * Releases the renderer. This method uses a promise to return the result. 2660 * @returns Promise used to return the result. 2661 * @since 8 2662 * @syscap SystemCapability.Multimedia.Audio.Renderer 2663 */ 2664 release(): Promise<void>; 2665 2666 /** 2667 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to 2668 * return the result. 2669 * @param callback Callback used to return the buffer size. 2670 * @since 8 2671 * @syscap SystemCapability.Multimedia.Audio.Renderer 2672 */ 2673 getBufferSize(callback: AsyncCallback<number>): void; 2674 /** 2675 * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result. 2676 * @returns Promise used to return the buffer size. 2677 * @since 8 2678 * @syscap SystemCapability.Multimedia.Audio.Renderer 2679 */ 2680 getBufferSize(): Promise<number>; 2681 2682 /** 2683 * Sets the render rate. This method uses an asynchronous callback to return the result. 2684 * @param rate Audio render rate. 2685 * @param callback Callback used to return the result. 2686 * @since 8 2687 * @syscap SystemCapability.Multimedia.Audio.Renderer 2688 */ 2689 setRenderRate(rate: AudioRendererRate, callback: AsyncCallback<void>): void; 2690 /** 2691 * Sets the render rate. This method uses a promise to return the result. 2692 * @param rate Audio render rate. 2693 * @returns Promise used to return the result. 2694 * @since 8 2695 * @syscap SystemCapability.Multimedia.Audio.Renderer 2696 */ 2697 setRenderRate(rate: AudioRendererRate): Promise<void>; 2698 2699 /** 2700 * Obtains the current render rate. This method uses an asynchronous callback to return the result. 2701 * @param callback Callback used to return the audio render rate. 2702 * @since 8 2703 * @syscap SystemCapability.Multimedia.Audio.Renderer 2704 */ 2705 getRenderRate(callback: AsyncCallback<AudioRendererRate>): void; 2706 /** 2707 * Obtains the current render rate. This method uses a promise to return the result. 2708 * @returns Promise used to return the audio render rate. 2709 * @since 8 2710 * @syscap SystemCapability.Multimedia.Audio.Renderer 2711 */ 2712 getRenderRate(): Promise<AudioRendererRate>; 2713 2714 /** 2715 * Set interrupt mode. 2716 * @param mode The interrupt mode. 2717 * @param callback Callback used to return the result. 2718 * @since 9 2719 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2720 */ 2721 setInterruptMode(mode: InterruptMode, callback: AsyncCallback<void>): void; 2722 /** 2723 * Set interrupt mode. 2724 * @param mode The interrupt mode. 2725 * @returns Promise used to return the result. 2726 * @since 9 2727 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2728 */ 2729 setInterruptMode(mode: InterruptMode): Promise<void>; 2730 2731 /** 2732 * Sets the volume for this stream. This method uses an asynchronous callback to return the result. 2733 * @param volume Volume to set. The value type is float, form 0.0 to 1.0. 2734 * @param callback Callback used to return the result. 2735 * @since 9 2736 * @syscap SystemCapability.Multimedia.Audio.Renderer 2737 */ 2738 setVolume(volume: number, callback: AsyncCallback<void>): void; 2739 /** 2740 * Sets the volume for a stream. This method uses a promise to return the result. 2741 * @param volume Volume to set. The value type is float, form 0.0 to 1.0. 2742 * @returns Promise used to return the result. 2743 * @since 9 2744 * @syscap SystemCapability.Multimedia.Audio.Renderer 2745 */ 2746 setVolume(volume: number): Promise<void>; 2747 2748 /** 2749 * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is 2750 * triggered when audio playback is interrupted. 2751 * @param callback Callback used to listen for interrupt callback. 2752 * @throws { BusinessError } 401 - if input parameter type or number mismatch 2753 * @throws { BusinessError } 6800101 - if input parameter value error 2754 * @since 9 2755 * @syscap SystemCapability.Multimedia.Audio.Interrupt 2756 */ 2757 on(type: 'audioInterrupt', callback: Callback<InterruptEvent>): void; 2758 2759 /** 2760 * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, 2761 * the callback is invoked. 2762 * @param frame Number of frames to trigger the event. The value must be greater than 0. 2763 * @param callback Callback invoked when the event is triggered. 2764 * @since 8 2765 * @syscap SystemCapability.Multimedia.Audio.Renderer 2766 */ 2767 on(type: "markReach", frame: number, callback: Callback<number>): void; 2768 /** 2769 * Unsubscribes from mark reached events. 2770 * @since 8 2771 * @syscap SystemCapability.Multimedia.Audio.Renderer 2772 */ 2773 off(type: "markReach"): void; 2774 2775 /** 2776 * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, 2777 * the callback is invoked. 2778 * @param frame Period during which frame rendering is listened. The value must be greater than 0. 2779 * @param callback Callback invoked when the event is triggered. 2780 * @since 8 2781 * @syscap SystemCapability.Multimedia.Audio.Renderer 2782 */ 2783 on(type: "periodReach", frame: number, callback: Callback<number>): void; 2784 /** 2785 * Unsubscribes from period reached events. 2786 * @since 8 2787 * @syscap SystemCapability.Multimedia.Audio.Renderer 2788 */ 2789 off(type: "periodReach"): void; 2790 2791 /** 2792 * Subscribes audio state change event callback. 2793 * @param callback Callback invoked when state change. 2794 * @since 8 2795 * @syscap SystemCapability.Multimedia.Audio.Renderer 2796 */ 2797 on(type: "stateChange", callback: Callback<AudioState>): void; 2798 } 2799 2800 /** 2801 * Enumerates source types. 2802 * @since 8 2803 * @syscap SystemCapability.Multimedia.Audio.Core 2804 */ 2805 enum SourceType { 2806 /** 2807 * Invalid source type. 2808 * @since 8 2809 * @syscap SystemCapability.Multimedia.Audio.Core 2810 */ 2811 SOURCE_TYPE_INVALID = -1, 2812 /** 2813 * Mic source type. 2814 * @since 8 2815 * @syscap SystemCapability.Multimedia.Audio.Core 2816 */ 2817 SOURCE_TYPE_MIC = 0, 2818 /** 2819 * Voice recognition source type. 2820 * @since 9 2821 * @syscap SystemCapability.Multimedia.Audio.Core 2822 */ 2823 SOURCE_TYPE_VOICE_RECOGNITION = 1, 2824 /** 2825 * Voice communication source type. 2826 * @since 8 2827 * @syscap SystemCapability.Multimedia.Audio.Core 2828 */ 2829 SOURCE_TYPE_VOICE_COMMUNICATION = 7 2830 } 2831 2832 /** 2833 * Describes audio capturer information. 2834 * @since 8 2835 * @syscap SystemCapability.Multimedia.Audio.Core 2836 */ 2837 interface AudioCapturerInfo { 2838 /** 2839 * Audio source type. 2840 * @since 8 2841 * @syscap SystemCapability.Multimedia.Audio.Core 2842 */ 2843 source: SourceType; 2844 /** 2845 * Audio capturer flags. 2846 * @since 8 2847 * @syscap SystemCapability.Multimedia.Audio.Core 2848 */ 2849 capturerFlags: number; 2850 } 2851 2852 /** 2853 * Describes audio capturer configuration options. 2854 * @since 8 2855 * @syscap SystemCapability.Multimedia.Audio.Capturer 2856 */ 2857 interface AudioCapturerOptions { 2858 /** 2859 * Stream information. 2860 * @since 8 2861 * @syscap SystemCapability.Multimedia.Audio.Capturer 2862 */ 2863 streamInfo: AudioStreamInfo; 2864 /** 2865 * Capturer information. 2866 * @since 8 2867 * @syscap SystemCapability.Multimedia.Audio.Capturer 2868 */ 2869 capturerInfo: AudioCapturerInfo; 2870 } 2871 2872 /** 2873 * Provides APIs for audio recording. 2874 * @since 8 2875 * @syscap SystemCapability.Multimedia.Audio.Capturer 2876 */ 2877 interface AudioCapturer { 2878 /** 2879 * Defines the current capture state. 2880 * @since 8 2881 * @syscap SystemCapability.Multimedia.Audio.Capturer 2882 */ 2883 readonly state: AudioState; 2884 2885 /** 2886 * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous 2887 * callback to return the result. 2888 * @param callback Callback used to return the capturer information. 2889 * @since 8 2890 * @syscap SystemCapability.Multimedia.Audio.Capturer 2891 */ 2892 getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo>): void; 2893 /** 2894 * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to 2895 * return the result. 2896 * @returns Promise used to return the capturer information. 2897 * @since 8 2898 * @syscap SystemCapability.Multimedia.Audio.Capturer 2899 */ 2900 getCapturerInfo(): Promise<AudioCapturerInfo>; 2901 2902 /** 2903 * Obtains the capturer stream information. This method uses an asynchronous callback to return the result. 2904 * @param callback Callback used to return the stream information. 2905 * @since 8 2906 * @syscap SystemCapability.Multimedia.Audio.Capturer 2907 */ 2908 getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void; 2909 /** 2910 * Obtains the capturer stream information. This method uses a promise to return the result. 2911 * @returns Promise used to return the stream information. 2912 * @since 8 2913 * @syscap SystemCapability.Multimedia.Audio.Capturer 2914 */ 2915 getStreamInfo(): Promise<AudioStreamInfo>; 2916 2917 /** 2918 * Obtains the capturer stream id. This method uses an asynchronous callback to return the result. 2919 * @param callback Callback used to return the stream id. 2920 * @since 9 2921 * @syscap SystemCapability.Multimedia.Audio.Capturer 2922 */ 2923 getAudioStreamId(callback: AsyncCallback<number>): void; 2924 /** 2925 * Obtains the capturer stream id. This method uses a promise to return the result. 2926 * @returns Promise used to return the stream id. 2927 * @since 9 2928 * @syscap SystemCapability.Multimedia.Audio.Capturer 2929 */ 2930 getAudioStreamId(): Promise<number>; 2931 2932 /** 2933 * Starts capturing. This method uses an asynchronous callback to return the result. 2934 * @param callback Callback used to return the result. 2935 * @since 8 2936 * @syscap SystemCapability.Multimedia.Audio.Capturer 2937 */ 2938 start(callback: AsyncCallback<void>): void; 2939 /** 2940 * Starts capturing. This method uses a promise to return the result. 2941 * @returns Promise used to return the result. 2942 * @since 8 2943 * @syscap SystemCapability.Multimedia.Audio.Capturer 2944 */ 2945 start(): Promise<void>; 2946 2947 /** 2948 * Reads the buffer from the audio capturer. This method uses an asynchronous callback to return the result. 2949 * @param size Number of bytes to read. 2950 * @param isBlockingRead Whether the read operation should be blocked. 2951 * @param callback Callback used to return the buffer. 2952 * @since 8 2953 * @syscap SystemCapability.Multimedia.Audio.Capturer 2954 */ 2955 read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer>): void; 2956 /** 2957 * Reads the buffer from the audio capturer. This method uses a promise to return the result. 2958 * @param size Number of bytes to read. 2959 * @param isBlockingRead Whether the read operation should be blocked. 2960 * @returns Returns the buffer data read if the operation is successful; returns an error code otherwise. 2961 * @since 8 2962 * @syscap SystemCapability.Multimedia.Audio.Capturer 2963 */ 2964 read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer>; 2965 2966 /** 2967 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an 2968 * asynchronous callback to return the result. 2969 * @param callback Callback used to return the timestamp. 2970 * @since 8 2971 * @syscap SystemCapability.Multimedia.Audio.Capturer 2972 */ 2973 getAudioTime(callback: AsyncCallback<number>): void; 2974 /** 2975 * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a 2976 * promise to return the result. 2977 * @returns Promise used to return the timestamp. 2978 * @since 8 2979 * @syscap SystemCapability.Multimedia.Audio.Capturer 2980 */ 2981 getAudioTime(): Promise<number>; 2982 2983 /** 2984 * Stops capturing. This method uses an asynchronous callback to return the result. 2985 * @param callback Callback used to return the result. 2986 * @since 8 2987 * @syscap SystemCapability.Multimedia.Audio.Capturer 2988 */ 2989 stop(callback: AsyncCallback<void>): void; 2990 /** 2991 * Stops capturing. This method uses a promise to return the result. 2992 * @returns Promise used to return the result. 2993 * @since 8 2994 * @syscap SystemCapability.Multimedia.Audio.Capturer 2995 */ 2996 stop(): Promise<void>; 2997 2998 /** 2999 * Releases the capturer. This method uses an asynchronous callback to return the result. 3000 * @param callback Callback used to return the result. 3001 * @since 8 3002 * @syscap SystemCapability.Multimedia.Audio.Capturer 3003 */ 3004 release(callback: AsyncCallback<void>): void; 3005 /** 3006 * Releases the capturer. This method uses a promise to return the result. 3007 * @returns Promise used to return the result. 3008 * @since 8 3009 * @syscap SystemCapability.Multimedia.Audio.Capturer 3010 */ 3011 release(): Promise<void>; 3012 3013 /** 3014 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to 3015 * return the result. 3016 * @param callback Callback used to return the buffer size. 3017 * @since 8 3018 * @syscap SystemCapability.Multimedia.Audio.Capturer 3019 */ 3020 getBufferSize(callback: AsyncCallback<number>): void; 3021 /** 3022 * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result. 3023 * @returns Promise used to return the buffer size. 3024 * @since 8 3025 * @syscap SystemCapability.Multimedia.Audio.Capturer 3026 */ 3027 getBufferSize(): Promise<number>; 3028 3029 /** 3030 * Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter, 3031 * the callback is invoked. 3032 * @param frame Number of frames to trigger the event. The value must be greater than 0. 3033 * @param callback Callback invoked when the event is triggered. 3034 * @since 8 3035 * @syscap SystemCapability.Multimedia.Audio.Capturer 3036 */ 3037 on(type: "markReach", frame: number, callback: Callback<number>): void; 3038 /** 3039 * Unsubscribes from the mark reached events. 3040 * @since 8 3041 * @syscap SystemCapability.Multimedia.Audio.Capturer 3042 */ 3043 off(type: "markReach"): void; 3044 3045 /** 3046 * Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter, 3047 * the callback is invoked. 3048 * @param frame Period during which frame capturing is listened. The value must be greater than 0. 3049 * @param callback Callback invoked when the event is triggered. 3050 * @since 8 3051 * @syscap SystemCapability.Multimedia.Audio.Capturer 3052 */ 3053 on(type: "periodReach", frame: number, callback: Callback<number>): void; 3054 /** 3055 * Unsubscribes from period reached events. 3056 * @since 8 3057 * @syscap SystemCapability.Multimedia.Audio.Capturer 3058 */ 3059 off(type: "periodReach"): void; 3060 3061 /** 3062 * Subscribes audio state change event callback. 3063 * @param callback Callback used to listen for the audio state change event. 3064 * @since 8 3065 * @syscap SystemCapability.Multimedia.Audio.Capturer 3066 */ 3067 on(type: "stateChange", callback: Callback<AudioState>): void; 3068 } 3069 3070 /** 3071 * Enumerates tone types for player. 3072 * @since 9 3073 * @syscap SystemCapability.Multimedia.Audio.Tone 3074 * @systemapi 3075 */ 3076 enum ToneType { 3077 /** 3078 * Dial tone for key 0. 3079 * @since 9 3080 * @syscap SystemCapability.Multimedia.Audio.Tone 3081 */ 3082 TONE_TYPE_DIAL_0 = 0, 3083 /** 3084 * Dial tone for key 1. 3085 * @since 9 3086 * @syscap SystemCapability.Multimedia.Audio.Tone 3087 */ 3088 TONE_TYPE_DIAL_1 = 1, 3089 /** 3090 * Dial tone for key 2. 3091 * @since 9 3092 * @syscap SystemCapability.Multimedia.Audio.Tone 3093 */ 3094 TONE_TYPE_DIAL_2 = 2, 3095 /** 3096 * Dial tone for key 3. 3097 * @since 9 3098 * @syscap SystemCapability.Multimedia.Audio.Tone 3099 */ 3100 TONE_TYPE_DIAL_3 = 3, 3101 /** 3102 * Dial tone for key 4. 3103 * @since 9 3104 * @syscap SystemCapability.Multimedia.Audio.Tone 3105 */ 3106 TONE_TYPE_DIAL_4 = 4, 3107 /** 3108 * Dial tone for key 5. 3109 * @since 9 3110 * @syscap SystemCapability.Multimedia.Audio.Tone 3111 */ 3112 TONE_TYPE_DIAL_5 = 5, 3113 /** 3114 * Dial tone for key 6. 3115 * @since 9 3116 * @syscap SystemCapability.Multimedia.Audio.Tone 3117 */ 3118 TONE_TYPE_DIAL_6 = 6, 3119 /** 3120 * Dial tone for key 7. 3121 * @since 9 3122 * @syscap SystemCapability.Multimedia.Audio.Tone 3123 */ 3124 TONE_TYPE_DIAL_7 = 7, 3125 /** 3126 * Dial tone for key 8. 3127 * @since 9 3128 * @syscap SystemCapability.Multimedia.Audio.Tone 3129 */ 3130 TONE_TYPE_DIAL_8 = 8, 3131 /** 3132 * Dial tone for key 9. 3133 * @since 9 3134 * @syscap SystemCapability.Multimedia.Audio.Tone 3135 */ 3136 TONE_TYPE_DIAL_9 = 9, 3137 /** 3138 * Dial tone for key *. 3139 * @since 9 3140 * @syscap SystemCapability.Multimedia.Audio.Tone 3141 */ 3142 TONE_TYPE_DIAL_S = 10, 3143 /** 3144 * Dial tone for key #. 3145 * @since 9 3146 * @syscap SystemCapability.Multimedia.Audio.Tone 3147 */ 3148 TONE_TYPE_DIAL_P = 11, 3149 /** 3150 * Dial tone for key A. 3151 * @since 9 3152 * @syscap SystemCapability.Multimedia.Audio.Tone 3153 */ 3154 TONE_TYPE_DIAL_A = 12, 3155 /** 3156 * Dial tone for key B. 3157 * @since 9 3158 * @syscap SystemCapability.Multimedia.Audio.Tone 3159 */ 3160 TONE_TYPE_DIAL_B = 13, 3161 /** 3162 * Dial tone for key C. 3163 * @since 9 3164 * @syscap SystemCapability.Multimedia.Audio.Tone 3165 */ 3166 TONE_TYPE_DIAL_C = 14, 3167 /** 3168 * Dial tone for key D. 3169 * @since 9 3170 * @syscap SystemCapability.Multimedia.Audio.Tone 3171 */ 3172 TONE_TYPE_DIAL_D = 15, 3173 /** 3174 * Supervisory tone for dial. 3175 * @since 9 3176 * @syscap SystemCapability.Multimedia.Audio.Tone 3177 */ 3178 TONE_TYPE_COMMON_SUPERVISORY_DIAL = 100, 3179 /** 3180 * Supervisory tone for busy. 3181 * @since 9 3182 * @syscap SystemCapability.Multimedia.Audio.Tone 3183 */ 3184 TONE_TYPE_COMMON_SUPERVISORY_BUSY = 101, 3185 /** 3186 * Supervisory tone for dial. 3187 * @since 9 3188 * @syscap SystemCapability.Multimedia.Audio.Tone 3189 */ 3190 TONE_TYPE_COMMON_SUPERVISORY_CONGESTION = 102, 3191 /** 3192 * Supervisory tone for radio path acknowledgment. 3193 * @since 9 3194 * @syscap SystemCapability.Multimedia.Audio.Tone 3195 */ 3196 TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK = 103, 3197 /** 3198 * Supervisory tone for radio path not available. 3199 * @since 9 3200 * @syscap SystemCapability.Multimedia.Audio.Tone 3201 */ 3202 TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE = 104, 3203 /** 3204 * Supervisory tone for call waiting. 3205 * @since 9 3206 * @syscap SystemCapability.Multimedia.Audio.Tone 3207 */ 3208 TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING = 106, 3209 /** 3210 * Supervisory tone for ringtone. 3211 * @since 9 3212 * @syscap SystemCapability.Multimedia.Audio.Tone 3213 */ 3214 TONE_TYPE_COMMON_SUPERVISORY_RINGTONE = 107, 3215 /** 3216 * Proprietary tone for beep. 3217 * @since 9 3218 * @syscap SystemCapability.Multimedia.Audio.Tone 3219 */ 3220 TONE_TYPE_COMMON_PROPRIETARY_BEEP = 200, 3221 /** 3222 * Proprietary tone for positive acknowledgment. 3223 * @since 9 3224 * @syscap SystemCapability.Multimedia.Audio.Tone 3225 */ 3226 TONE_TYPE_COMMON_PROPRIETARY_ACK = 201, 3227 /** 3228 * Proprietary tone for prompt. 3229 * @since 9 3230 * @syscap SystemCapability.Multimedia.Audio.Tone 3231 */ 3232 TONE_TYPE_COMMON_PROPRIETARY_PROMPT = 203, 3233 /** 3234 * Proprietary tone for double beep. 3235 * @since 9 3236 * @syscap SystemCapability.Multimedia.Audio.Tone 3237 */ 3238 TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP = 204, 3239 } 3240 3241 /** 3242 * Provides APIs for tone playing. 3243 * @since 9 3244 * @syscap SystemCapability.Multimedia.Audio.Tone 3245 * @systemapi 3246 */ 3247 interface TonePlayer { 3248 /** 3249 * Loads tone. This method uses an asynchronous callback to return the result. 3250 * @param type Tone type to play. 3251 * @param callback Callback used to return the result. 3252 * @since 9 3253 * @syscap SystemCapability.Multimedia.Audio.Tone 3254 */ 3255 load(type: ToneType, callback: AsyncCallback<void>): void; 3256 /** 3257 * Loads tone. This method uses a promise to return the result. 3258 * @param type Tone type to play. 3259 * @returns Promise used to return the result. 3260 * @since 9 3261 * @syscap SystemCapability.Multimedia.Audio.Tone 3262 */ 3263 load(type: ToneType): Promise<void>; 3264 3265 /** 3266 * Starts player. This method uses an asynchronous callback to return the result. 3267 * @param callback Callback used to return the result. 3268 * @since 9 3269 * @syscap SystemCapability.Multimedia.Audio.Tone 3270 */ 3271 start(callback: AsyncCallback<void>): void; 3272 /** 3273 * Starts player. This method uses a promise to return the result. 3274 * @returns Promise used to return the result. 3275 * @since 9 3276 * @syscap SystemCapability.Multimedia.Audio.Tone 3277 */ 3278 start(): Promise<void>; 3279 3280 /** 3281 * Stops player. This method uses an asynchronous callback to return the result. 3282 * @param callback Callback used to return the result. 3283 * @since 9 3284 * @syscap SystemCapability.Multimedia.Audio.Tone 3285 */ 3286 stop(callback: AsyncCallback<void>): void; 3287 /** 3288 * Stops player. This method uses a promise to return the result. 3289 * @returns Promise used to return the result. 3290 * @since 9 3291 * @syscap SystemCapability.Multimedia.Audio.Tone 3292 */ 3293 stop(): Promise<void>; 3294 3295 /** 3296 * Releases the player. This method uses an asynchronous callback to return the result. 3297 * @param callback Callback used to return the result. 3298 * @since 9 3299 * @syscap SystemCapability.Multimedia.Audio.Tone 3300 */ 3301 release(callback: AsyncCallback<void>): void; 3302 /** 3303 * Releases the player. This method uses a promise to return the result. 3304 * @returns Promise used to return the result. 3305 * @since 9 3306 * @syscap SystemCapability.Multimedia.Audio.Tone 3307 */ 3308 release(): Promise<void>; 3309 } 3310} 3311 3312export default audio;