source
stringlengths
14
113
code
stringlengths
10
21.3k
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err: BusinessError) => { if (err) { console.error(`Failed to set the active status of the device. ${err}`); return; } console.info('Callback invoked to indicate that the device is se...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => { console.info('Promise returned to indicate that the device is set to the active status.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err: BusinessError, value: boolean) => { if (err) { console.error(`Failed to obtain the active status of the device. ${err}`); return; } console.info('Callback invoked to indicate that the ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value: boolean) => { console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioManager.setMicrophoneMute(true, (err: BusinessError) => { if (err) { console.error(`Failed to mute the microphone. ${err}`); return; } console.info('Callback invoked to indicate that the microphone is muted.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioManager.setMicrophoneMute(true).then(() => { console.info('Promise returned to indicate that the microphone is muted.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioManager.isMicrophoneMute((err: BusinessError, value: boolean) => { if (err) { console.error(`Failed to obtain the mute status of the microphone. ${err}`); return; } console.info(`Callback invoked to indicate that the mute status of the microphon...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioManager.isMicrophoneMute().then((value: boolean) => { console.info(`Promise returned to indicate that the mute status of the microphone is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioManager.on('deviceChange', (deviceChanged: audio.DeviceChangeAction) => { console.info(`device change type : ${deviceChanged.type} `); console.info(`device descriptor size : ${deviceChanged.deviceDescriptors.length} `); console.info(`device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceRole}...
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioManager.off('deviceChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let deviceChangeCallback = (deviceChanged: ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; let interAudioInterrupt: audio.AudioInterrupt = { streamUsage:2, contentType:0, pauseWhenDucked:true }; audioManager.on('interrupt', interAudioInterrupt, (interruptAction: audio.InterruptAction) => { if (interruptAction.actionType === 0) { console.info('An event to g...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; let interAudioInterrupt: audio.AudioInterrupt = { streamUsage:2, contentType:0, pauseWhenDucked:true }; // Cancel all subscriptions to the event. audioManager.off('interrupt', interAudioInterrupt); // For the same event, if the callback parameter passed to the off API is ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; let groupId: number = audio.DEFAULT_VOLUME_GROUP_ID; audioVolumeManager.getVolumeGroupManager(groupId, (err: BusinessError, value: audio.AudioVolumeGroupManager) => { if (err) { console.error(`Failed to obtain the volume group infos list. ${err}`); retu...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; let groupId: number = audio.DEFAULT_VOLUME_GROUP_ID; let audioVolumeGroupManager: audio.AudioVolumeGroupManager | undefined = undefined; async function getVolumeGroupManager(){ audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupId); console.info('P...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let audioVolumeGroupManager: audio.AudioVolumeGroupManager = audioVolumeManager.getVolumeGroupManagerSync(audio.DEFAULT_VOLUME_GROUP_ID); console.info(`Get audioVolumeGroupManager success.`); } catch (err) { let error = err as BusinessError; console....
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; audioVolumeManager.getAppVolumePercentage().then((value: number) => { console.info(`app volume is ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; audioVolumeManager.setAppVolumePercentage(20).then(() => { console.info(`set app volume success.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeManager.on('volumeChange', (volumeEvent: audio.VolumeEvent) => { console.info(`VolumeType of stream: ${volumeEvent.volumeType} `); console.info(`Volume level: ${volumeEvent.volume} `); console.info(`Whether to updateUI: ${volumeEvent.updateUi} `); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioVolumeManager.off('volumeChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let volumeChangeCallback = (volumeEve...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeManager.on('appVolumeChange', (volumeEvent: audio.VolumeEvent) => { console.info(`VolumeType of stream: ${volumeEvent.volumeType} `); console.info(`Volume level: ${volumeEvent.volume} `); console.info(`Whether to updateUI: ${volumeEvent.updateUi} `); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioVolumeManager.off('appVolumeChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let appVolumeChangeCallback = (vol...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA, (err: BusinessError, value: number) => { if (err) { console.error(`Failed to obtain the volume. ${err}`); return; } console.info('Callback invoked to indicate that the volume is obtained....
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA).then((value: number) => { console.info(`Promise returned to indicate that the volume is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: number = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.MEDIA); console.info(`Indicate that the volume is obtained ${value}.`); } catch (err) { let error = err as BusinessError; console.error(`Failed to obtain the volume, erro...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err: BusinessError, value: number) => { if (err) { console.error(`Failed to obtain the minimum volume. ${err}`); return; } console.info(`Callback invoked to indicate that the minimum ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value: number) => { console.info(`Promised returned to indicate that the minimum volume is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: number = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.MEDIA); console.info(`Indicate that the minimum volume is obtained ${value}.`); } catch (err) { let error = err as BusinessError; console.error(`Failed to obtain the m...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err: BusinessError, value: number) => { if (err) { console.error(`Failed to obtain the maximum volume. ${err}`); return; } console.info(`Callback invoked to indicate that the maximum ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data: number) => { console.info('Promised returned to indicate that the maximum volume is obtained.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: number = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.MEDIA); console.info(`Indicate that the maximum volume is obtained. ${value}`); } catch (err) { let error = err as BusinessError; console.error(`Failed to obtain the m...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.isMute(audio.AudioVolumeType.MEDIA, (err: BusinessError, value: boolean) => { if (err) { console.error(`Failed to obtain the mute status. ${err}`); return; } console.info(`Callback invoked to indicate that the mute status of t...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value: boolean) => { console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: boolean = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.MEDIA); console.info(`Indicate that the mute status of the stream is obtained ${value}.`); } catch (err) { let error = err as BusinessError; console.error(`Failed to obtain...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.getRingerMode((err: BusinessError, value: audio.AudioRingMode) => { if (err) { console.error(`Failed to obtain the ringer mode. ${err}`); return; } console.info(`Callback invoked to indicate that the ringer mode is obtained ${...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.getRingerMode().then((value: audio.AudioRingMode) => { console.info(`Promise returned to indicate that the ringer mode is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: audio.AudioRingMode = audioVolumeGroupManager.getRingerModeSync(); console.info(`Indicate that the ringer mode is obtained ${value}.`); } catch (err) { let error = err as BusinessError; console.error(`Failed to obtain the ringer mode, erro...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.on('ringerModeChange', (ringerMode: audio.AudioRingMode) => { console.info(`Updated ringermode: ${ringerMode}`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioVolumeGroupManager.off('ringerModeChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let ringerModeChangeCallback...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.setMicrophoneMute(true, (err: BusinessError) => { if (err) { console.error(`Failed to mute the microphone. ${err}`); return; } console.info('Callback invoked to indicate that the microphone is muted.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.setMicrophoneMute(true).then(() => { console.info('Promise returned to indicate that the microphone is muted.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.isMicrophoneMute((err: BusinessError, value: boolean) => { if (err) { console.error(`Failed to obtain the mute status of the microphone. ${err}`); return; } console.info(`Callback invoked to indicate that the mute status of th...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.isMicrophoneMute().then((value: boolean) => { console.info(`Promise returned to indicate that the mute status of the microphone is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: boolean = audioVolumeGroupManager.isMicrophoneMuteSync(); console.info(`Indicate that the mute status of the microphone is obtained ${value}.`); } catch (err) { let error = err as BusinessError; console.error(`Failed to obtain the mute sta...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioVolumeGroupManager.on('micStateChange', (micStateChange: audio.MicStateChangeEvent) => { console.info(`Current microphone status is: ${micStateChange.mute} `); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioVolumeGroupManager.off('micStateChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let micStateChangeCallback = (...
application-dev\reference\apis-audio-kit\js-apis-audio.md
let volumeAdjustSwitch: boolean = audioVolumeGroupManager.isVolumeUnadjustable(); console.info(`Whether it is volume unadjustable: ${volumeAdjustSwitch}.`);
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER, (err: BusinessError, dB: number) => { if (err) { console.error(`Failed to get the volume DB. ${err}`); } else { console.info(`Success to get the volum...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER).then((value: number) => { console.info(`Success to get the volume DB. ${value}`); }).catch((error: BusinessError) => { console.error(`Fail to adjust the syste...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: number = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER); console.info(`Success to get the volume DB. ${value}`); } catch (err) { let error = err as BusinessError; console.error(`Fa...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; let capturerInfo: audio.AudioCapturerInfo = { source: audio.SourceType.SOURCE_TYPE_MIC, // Audio source type: microphone. Set this parameter based on the service scenario. capturerFlags: 0 // AudioCapturer flag. }; audio.getAudioManager().getRoutingManager()....
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; let rendererInfo: audio.AudioRendererInfo = { usage: audio.StreamUsage.STREAM_USAGE_MUSIC, // Audio stream usage type: music. Set this parameter based on the service scenario. rendererFlags: 0 // AudioRenderer flag. }; audio.getAudioManager().getRoutingManage...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioStreamManager.getCurrentAudioRendererInfoArray(async (err: BusinessError, AudioRendererChangeInfoArray: audio.AudioRendererChangeInfoArray) => { console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****'); if (err) { console.error(`...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; async function getCurrentAudioRendererInfoArray(){ await audioStreamManager.getCurrentAudioRendererInfoArray().then((AudioRendererChangeInfoArray: audio.AudioRendererChangeInfoArray) => { console.info(`getCurrentAudioRendererInfoArray ######### Get Promise i...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let audioRendererChangeInfoArray: audio.AudioRendererChangeInfoArray = audioStreamManager.getCurrentAudioRendererInfoArraySync(); console.info(`getCurrentAudioRendererInfoArraySync success.`); if (audioRendererChangeInfoArray != null) { for (let i ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioStreamManager.getCurrentAudioCapturerInfoArray(async (err: BusinessError, AudioCapturerChangeInfoArray: audio.AudioCapturerChangeInfoArray) => { console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****'); if (err) { console.error(`...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; async function getCurrentAudioCapturerInfoArray(){ await audioStreamManager.getCurrentAudioCapturerInfoArray().then((AudioCapturerChangeInfoArray: audio.AudioCapturerChangeInfoArray) => { console.info('getCurrentAudioCapturerInfoArray **** Get Promise Called...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let audioCapturerChangeInfoArray: audio.AudioCapturerChangeInfoArray = audioStreamManager.getCurrentAudioCapturerInfoArraySync(); console.info('getCurrentAudioCapturerInfoArraySync success.'); if (audioCapturerChangeInfoArray != null) { for (let i ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioStreamManager.on('audioRendererChange', (audioRendererChangeInfoArray: audio.AudioRendererChangeInfoArray) => { for (let i = 0; i < audioRendererChangeInfoArray.length; i++) { let audioRendererChangeInfo: audio.AudioRendererChangeInfo = audioRendererChangeInfoArray[i]; console.info(`## RendererChange on...
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioStreamManager.off('audioRendererChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let audioRendererChangeCallbac...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray: audio.AudioCapturerChangeInfoArray) => { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { console.info(`## CapChange on is called for element ${i} ##`); console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArra...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioStreamManager.off('audioCapturerChange'); // Cancel all subscriptions to the event. audioStreamManager.off('audioCapturerChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified cal...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioStreamManager.isActive(audio.AudioVolumeType.MEDIA, (err: BusinessError, value: boolean) => { if (err) { console.error(`Failed to obtain the active status of the stream. ${err}`); return; } console.info(`Callback invoked to indicate that the active stat...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioStreamManager.isActive(audio.AudioVolumeType.MEDIA).then((value: boolean) => { console.info(`Promise returned to indicate that the active status of the stream is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: boolean = audioStreamManager.isActiveSync(audio.AudioVolumeType.MEDIA); console.info(`Indicate that the active status of the stream is obtained ${value}.`); } catch (err) { let error = err as BusinessError; console.error(`Failed to obtain ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MUSIC, async (err: BusinessError, audioEffectInfoArray: audio.AudioEffectInfoArray) => { console.info('getAudioEffectInfoArray **** Get Callback Called ****'); if (err) { console.err...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MUSIC).then((audioEffectInfoArray: audio.AudioEffectInfoArray) => { console.info('getAudioEffectInfoArray ######### Get Promise is called ##########'); console.info(`The effect modes are...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let audioEffectInfoArray: audio.AudioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(audio.StreamUsage.STREAM_USAGE_MUSIC); console.info(`The effect modes are: ${audioEffectInfoArray}`); } catch (err) { let error = err as BusinessError...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err: BusinessError, value: audio.AudioDeviceDescriptors) => { if (err) { console.error(`Failed to obtain the device list. ${err}`); return; } console.info('Callback invoked to indi...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data: audio.AudioDeviceDescriptors) => { console.info('Promise returned to indicate that the device list is obtained.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let data: audio.AudioDeviceDescriptors = audioRoutingManager.getDevicesSync(audio.DeviceFlag.OUTPUT_DEVICES_FLAG); console.info(`Indicate that the device list is obtained ${data}`); } catch (err) { let error = err as BusinessError; console.error(`Fai...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioRoutingManager.isMicBlockDetectionSupported().then((value: boolean) => { console.info(`Query whether microphone block detection is supported on current device result is ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Before the subscription, check whether the current device supports detection. audioRoutingManager.isMicBlockDetectionSupported().then((value: boolean) => { console.info(`Query whether microphone block detection is supported on current device result is ${value}.`); if (value) { audioRoutingManager.on('micBloc...
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioRoutingManager.off('micBlockStatusChanged'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let micBlockStatusCallback ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged: audio.DeviceChangeAction) => { console.info('device change type : ' + deviceChanged.type); console.info('device descriptor size : ' + deviceChanged.deviceDescriptors.length); console.info('device change descriptor : ' + d...
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioRoutingManager.off('deviceChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let deviceChangeCallback = (deviceCh...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioRoutingManager.setCommunicationDevice(audio.CommunicationDeviceType.SPEAKER, true, (err: BusinessError) => { if (err) { console.error(`Failed to set the active status of the device. ${err}`); return; } console.info('Callback invoked to indicate ...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let data: audio.AudioDeviceDescriptors = audioRoutingManager.getAvailableDevices(audio.DeviceUsage.MEDIA_OUTPUT_DEVICES); console.info(`Indicate that the device list is obtained ${data}`); } catch (err) { let error = err as BusinessError; console.err...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioRoutingManager.on('availableDeviceChange', audio.DeviceUsage.MEDIA_OUTPUT_DEVICES, (deviceChanged: audio.DeviceChangeAction) => { console.info('device change type : ' + deviceChanged.type); console.info('device descriptor size : ' + deviceChanged.deviceDescriptors.length); console.info('device change descrip...
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioRoutingManager.off('availableDeviceChange'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let availableDeviceChangeCa...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioRoutingManager.setCommunicationDevice(audio.CommunicationDeviceType.SPEAKER, true).then(() => { console.info('Promise returned to indicate that the device is set to the active status.'); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioRoutingManager.isCommunicationDeviceActive(audio.CommunicationDeviceType.SPEAKER, (err: BusinessError, value: boolean) => { if (err) { console.error(`Failed to obtain the active status of the device. ${err}`); return; } console.info('Callback in...
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioRoutingManager.isCommunicationDeviceActive(audio.CommunicationDeviceType.SPEAKER).then((value: boolean) => { console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; try { let value: boolean = audioRoutingManager.isCommunicationDeviceActiveSync(audio.CommunicationDeviceType.SPEAKER); console.info(`Indicate that the active status of the device is obtained ${value}.`); } catch (err) { let error = err as BusinessError; co...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; import { BusinessError } from '@kit.BasicServicesKit'; let rendererInfo: audio.AudioRendererInfo = { usage: audio.StreamUsage.STREAM_USAGE_MUSIC, // Audio stream usage type: music. Set this parameter based on the service scenario. rendererFlags: 0 // AudioRenderer flag. }; a...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; import { BusinessError } from '@kit.BasicServicesKit'; let rendererInfo: audio.AudioRendererInfo = { usage: audio.StreamUsage.STREAM_USAGE_MUSIC, // Audio stream usage type: music. Set this parameter based on the service scenario. rendererFlags: 0 // AudioRenderer flag. }; a...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; import { BusinessError } from '@kit.BasicServicesKit'; let rendererInfo: audio.AudioRendererInfo = { usage: audio.StreamUsage.STREAM_USAGE_MUSIC, // Audio stream usage type: music. Set this parameter based on the service scenario. rendererFlags: 0 // AudioRenderer flag. }; t...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; let rendererInfo: audio.AudioRendererInfo = { usage: audio.StreamUsage.STREAM_USAGE_MUSIC, // Audio stream usage type: music. Set this parameter based on the service scenario. rendererFlags: 0 // AudioRenderer flag. }; audioRoutingManager.on('preferOutputDeviceChangeForRende...
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioRoutingManager.off('preferOutputDeviceChangeForRendererInfo'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let prefe...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; import { BusinessError } from '@kit.BasicServicesKit'; let capturerInfo: audio.AudioCapturerInfo = { source: audio.SourceType.SOURCE_TYPE_MIC, // Audio source type: microphone. Set this parameter based on the service scenario. capturerFlags: 0 // AudioCapturer flag. }; audio...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; import { BusinessError } from '@kit.BasicServicesKit'; let capturerInfo: audio.AudioCapturerInfo = { source: audio.SourceType.SOURCE_TYPE_MIC, // Audio source type: microphone. Set this parameter based on the service scenario. capturerFlags: 0 // AudioCapturer flag. }; audio...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; import { BusinessError } from '@kit.BasicServicesKit'; let capturerInfo: audio.AudioCapturerInfo = { source: audio.SourceType.SOURCE_TYPE_MIC, // Audio source type: microphone. Set this parameter based on the service scenario. capturerFlags: 0 // AudioCapturer flag. }; try {...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; let capturerInfo: audio.AudioCapturerInfo = { source: audio.SourceType.SOURCE_TYPE_MIC, // Audio source type: microphone. Set this parameter based on the service scenario. capturerFlags: 0 // AudioCapturer flag. }; audioRoutingManager.on('preferredInputDeviceChangeForCapture...
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioRoutingManager.off('preferredInputDeviceChangeForCapturerInfo'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let pre...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; let strategy: audio.AudioSessionStrategy = { concurrencyMode: audio.AudioConcurrencyMode.CONCURRENCY_MIX_WITH_OTHERS }; audioSessionManager.activateAudioSession(strategy).then(() => { console.info('activateAudioSession SUCCESS'); }).catch((err: BusinessError)...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { BusinessError } from '@kit.BasicServicesKit'; audioSessionManager.deactivateAudioSession().then(() => { console.info('deactivateAudioSession SUCCESS'); }).catch((err: BusinessError) => { console.error(`ERROR: ${err}`); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
let isActivated = audioSessionManager.isAudioSessionActivated();
application-dev\reference\apis-audio-kit\js-apis-audio.md
audioSessionManager.on('audioSessionDeactivated', (audioSessionDeactivatedEvent: audio.AudioSessionDeactivatedEvent) => { console.info(`reason of audioSessionDeactivated: ${audioSessionDeactivatedEvent.reason} `); });
application-dev\reference\apis-audio-kit\js-apis-audio.md
// Cancel all subscriptions to the event. audioSessionManager.off('audioSessionDeactivated'); // For the same event, if the callback parameter passed to the off API is the same as that passed to the on API, the off API cancels the subscription registered with the specified callback parameter. let audioSessionDeactivat...
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; let isSpatializationEnabledForCurrentDevice: boolean = audioSpatializationManager.isSpatializationEnabledForCurrentDevice(); console.info(`AudioSpatializationManager isSpatializationEnabledForCurrentDevice: ${isSpatializationEnabledForCurrentDevice}`);
application-dev\reference\apis-audio-kit\js-apis-audio.md
import { audio } from '@kit.AudioKit'; audioSpatializationManager.on('spatializationEnabledChangeForCurrentDevice', (isSpatializationEnabledForCurrentDevice: boolean) => { console.info(`isSpatializationEnabledForCurrentDevice: ${isSpatializationEnabledForCurrentDevice}`); });