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} from './basic'; 17 18/** 19 * @name audio 20 * @sysCap SystemCapability.Multimedia.Audio 21 * @import import audio from '@ohos.multimedia.audio'; 22 * This part of the function is temporarily unavailable due to permission issues in the standard system, 23 * waiting for update 24 */ 25declare namespace audio { 26 27 /** 28 * get the audiomanager of the audio 29 * @devices phone 30 * @sysCap SystemCapability.Multimedia.Audio 31 */ 32 function getAudioManager(): AudioManager; 33 34 /** 35 * the type of audio stream 36 * @devices phone 37 * @sysCap SystemCapability.Multimedia.Audio 38 */ 39 enum AudioVolumeType { 40 /** 41 * the media stream 42 */ 43 MEDIA = 1, 44 /** 45 * the ringtone stream 46 */ 47 RINGTONE = 2, 48 } 49 50 /** 51 * the flag type of device 52 * @devices phone 53 * @sysCap SystemCapability.Multimedia.Audio 54 */ 55 enum DeviceFlag { 56 /** 57 * the device flag of output 58 */ 59 OUTPUT_DEVICES_FLAG = 1, 60 /** 61 * the device flag of input 62 */ 63 INPUT_DEVICES_FLAG = 2, 64 /** 65 * the device flag of all devices 66 */ 67 ALL_DEVICES_FLAG = 3, 68 } 69 /** 70 * the role of device 71 * @devices phone 72 * @sysCap SystemCapability.Multimedia.Audio 73 */ 74 enum DeviceRole { 75 /** 76 * the role of input devices 77 */ 78 INPUT_DEVICE = 1, 79 /** 80 * the role of output devices 81 */ 82 OUTPUT_DEVICE = 2, 83 } 84 /** 85 * the type of device 86 * @devices phone 87 * @sysCap SystemCapability.Multimedia.Audio 88 */ 89 enum DeviceType { 90 /** 91 * invalid 92 */ 93 INVALID = 0, 94 /** 95 * speaker 96 */ 97 SPEAKER = 1, 98 /** 99 * wired headset 100 */ 101 WIRED_HEADSET = 2, 102 /** 103 * bluetooth sco 104 */ 105 BLUETOOTH_SCO = 3, 106 /** 107 * bluetooth a2dp 108 */ 109 BLUETOOTH_A2DP = 4, 110 /** 111 * mic 112 */ 113 MIC = 5, 114 } 115 /** 116 * the audiomanager of the audio 117 * @devices phone 118 * @sysCap SystemCapability.Multimedia.Audio 119 */ 120 interface AudioManager { 121 /** 122 * set the volume of the audiovolumetype 123 * @devices phone 124 * @sysCap SystemCapability.Multimedia.Audio 125 */ 126 setVolume(audioType: AudioVolumeType,volume: number,callback: AsyncCallback<void>): void; 127 /** 128 * set the volume of the audiovolumetype 129 * @devices phone 130 * @sysCap SystemCapability.Multimedia.Audio 131 */ 132 setVolume(audioType: AudioVolumeType,volume: number): Promise<void>; 133 /** 134 * get the volume of the audiovolumetype 135 * @devices phone 136 * @sysCap SystemCapability.Multimedia.Audio 137 */ 138 getVolume(audioType: AudioVolumeType, callback: AsyncCallback<number>): void; 139 /** 140 * get the volume of the audiovolumetype 141 * @devices phone 142 * @sysCap SystemCapability.Multimedia.Audio 143 */ 144 getVolume(audioType: AudioVolumeType): Promise<number>; 145 /** 146 * get the min volume of the audiovolumetype 147 * @devices phone 148 * @sysCap SystemCapability.Multimedia.Audio 149 */ 150 getMinVolume(audioType: AudioVolumeType, callback: AsyncCallback<number>): void 151 /** 152 * get the min volume of the audiovolumetype 153 * @devices phone 154 * @sysCap SystemCapability.Multimedia.Audio 155 */ 156 getMinVolume(audioType: AudioVolumeType): Promise<number>; 157 /** 158 * get the max volume of the audiovolumetype 159 * @devices phone 160 * @sysCap SystemCapability.Multimedia.Audio 161 */ 162 getMaxVolume(audioType: AudioVolumeType, callback: AsyncCallback<number>): void 163 /** 164 * get the max volume of the audiovolumetype 165 * @devices phone 166 * @sysCap SystemCapability.Multimedia.Audio 167 */ 168 getMaxVolume(audioType: AudioVolumeType): Promise<number>; 169 /** 170 * get the device list of the audio devices by the audio flag 171 * @devices phone 172 * @sysCap SystemCapability.Multimedia.Audio 173 */ 174 getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void; 175 /** 176 * get the device list of the audio devices by the audio flag 177 * @devices phone 178 * @sysCap SystemCapability.Multimedia.Audio 179 */ 180 getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>; 181 } 182 183 /** 184 * the Descriptor of the device 185 * @devices phone 186 * @sysCap SystemCapability.Multimedia.Audio 187 */ 188 interface AudioDeviceDescriptor { 189 /** 190 * the role of device 191 * @devices phone 192 * @sysCap SystemCapability.Multimedia.Audio 193 */ 194 readonly deviceRole: DeviceRole; 195 /** 196 * the type of device 197 * @devices phone 198 * @sysCap SystemCapability.Multimedia.Audio 199 */ 200 readonly deviceType: DeviceType; 201 } 202 203 /** 204 * the Descriptor list of the devices 205 * @devices phone 206 * @sysCap SystemCapability.Multimedia.Audio 207 */ 208 type AudioDeviceDescriptors = Array<Readonly<AudioDeviceDescriptor>>; 209} 210 211export default audio;