提交 1c5277d3 编写于 作者: J jiao_yanlin

Update device descriptor, focus type and sample format, sample code modification

Signed-off-by: Njiao_yanlin <jiaoyanlin@huawei.com>
上级 3c258b58
...@@ -74,31 +74,31 @@ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\<Audi ...@@ -74,31 +74,31 @@ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\<Audi
``` ```
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1, channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioRendererInfo = { var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH, content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
rendererFlags: 1 rendererFlags: 1
} }
var audioRendererOptions = { var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
audio.createAudioRenderer(audioRendererOptions,(err, data) => { audio.createAudioRenderer(audioRendererOptions,(err, data) => {
if (err) { if (err) {
console.error(`AudioRenderer Created : Error: ${err.message}`); console.error(`AudioRenderer Created : Error: ${err.message}`);
} }
else { else {
console.info('AudioRenderer Created : Success : SUCCESS'); console.info('AudioRenderer Created : Success : SUCCESS');
let audioRenderer = data; let audioRenderer = data;
} }
}); });
``` ```
...@@ -128,29 +128,29 @@ createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer\> ...@@ -128,29 +128,29 @@ createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer\>
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1, channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioRendererInfo = { var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH, content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
rendererFlags: 1 rendererFlags: 1
} }
var audioRendererOptions = { var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
var audioRenderer; var audioRenderer;
audio.createAudioRenderer(audioRendererOptions).then((data) => { audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRenderer Created : ERROR : '+err.message); console.info('AudioFrameworkRenderLog: AudioRenderer Created : ERROR : '+err.message);
}); });
``` ```
...@@ -174,30 +174,30 @@ createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<Audio ...@@ -174,30 +174,30 @@ createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<Audio
``` ```
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2, channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioCapturerInfo = { var audioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC, source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 1 capturerFlags: 1
} }
var audioCapturerOptions = { var audioCapturerOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
capturerInfo: audioCapturerInfo capturerInfo: audioCapturerInfo
} }
audio.createAudioCapturer(audioCapturerOptions,(err, data) => { audio.createAudioCapturer(audioCapturerOptions,(err, data) => {
if (err) { if (err) {
console.error(`AudioCapturer Created : Error: ${err.message}`); console.error(`AudioCapturer Created : Error: ${err.message}`);
} }
else { else {
console.info('AudioCapturer Created : Success : SUCCESS'); console.info('AudioCapturer Created : Success : SUCCESS');
let audioCapturer = data; let audioCapturer = data;
} }
}); });
``` ```
...@@ -227,28 +227,28 @@ createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer\> ...@@ -227,28 +227,28 @@ createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer\>
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2, channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioCapturerInfo = { var audioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC, source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 1 capturerFlags: 1
} }
var audioCapturerOptions = { var audioCapturerOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
capturerInfo: audioCapturerInfo capturerInfo: audioCapturerInfo
} }
var audioCapturer; var audioCapturer;
audio.createAudioCapturer(audioCapturerOptions).then((data) => { audio.createAudioCapturer(audioCapturerOptions).then((data) => {
audioCapturer = data; audioCapturer = data;
console.info('AudioCapturer Created : Success : Stream Type: SUCCESS'); console.info('AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info('AudioCapturer Created : ERROR : '+err.message); console.info('AudioCapturer Created : ERROR : '+err.message);
}); });
``` ```
...@@ -697,10 +697,10 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l ...@@ -697,10 +697,10 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l
``` ```
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
if (err) { if (err) {
console.error('Failed to set the volume. ${err.message}'); console.error('Failed to set the volume. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate a successful volume setting.'); console.log('Callback invoked to indicate a successful volume setting.');
}); });
``` ```
...@@ -732,7 +732,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt; ...@@ -732,7 +732,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt;
``` ```
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
console.log('Promise returned to indicate a successful volume setting.'); console.log('Promise returned to indicate a successful volume setting.');
}); });
``` ```
...@@ -755,11 +755,11 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): v ...@@ -755,11 +755,11 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): v
``` ```
audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the volume. ${err.message}'); console.error('Failed to obtain the volume. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the volume is obtained.'); console.log('Callback invoked to indicate that the volume is obtained.');
}); });
``` ```
...@@ -787,7 +787,7 @@ getVolume(volumeType: AudioVolumeType): Promise&lt;number&gt; ...@@ -787,7 +787,7 @@ getVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
``` ```
audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => {
console.log('Promise returned to indicate that the volume is obtained.' + value); console.log('Promise returned to indicate that the volume is obtained.' + value);
}); });
``` ```
...@@ -810,11 +810,11 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;) ...@@ -810,11 +810,11 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
``` ```
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the minimum volume. ${err.message}'); console.error('Failed to obtain the minimum volume. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the minimum volume is obtained.' + value); console.log('Callback invoked to indicate that the minimum volume is obtained.' + value);
}); });
``` ```
...@@ -842,7 +842,7 @@ getMinVolume(volumeType: AudioVolumeType): Promise&lt;number&gt; ...@@ -842,7 +842,7 @@ getMinVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
``` ```
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => {
console.log('Promised returned to indicate that the minimum volume is obtained.' + value); console.log('Promised returned to indicate that the minimum volume is obtained.' + value);
}); });
``` ```
...@@ -865,11 +865,11 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;) ...@@ -865,11 +865,11 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
``` ```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the maximum volume. ${err.message}'); console.error('Failed to obtain the maximum volume. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the maximum volume is obtained.' + value); console.log('Callback invoked to indicate that the maximum volume is obtained.' + value);
}); });
``` ```
...@@ -897,7 +897,7 @@ getMaxVolume(volumeType: AudioVolumeType): Promise&lt;number&gt; ...@@ -897,7 +897,7 @@ getMaxVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
``` ```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => {
console.log('Promised returned to indicate that the maximum volume is obtained.'); console.log('Promised returned to indicate that the maximum volume is obtained.');
}); });
``` ```
...@@ -923,11 +923,11 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void ...@@ -923,11 +923,11 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void
``` ```
audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
if (err) { if (err) {
console.error('Failed to mute the stream. ${err.message}'); console.error('Failed to mute the stream. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the stream is muted.'); console.log('Callback invoked to indicate that the stream is muted.');
}); });
``` ```
...@@ -959,7 +959,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt; ...@@ -959,7 +959,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt;
``` ```
audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
console.log('Promise returned to indicate that the stream is muted.'); console.log('Promise returned to indicate that the stream is muted.');
}); });
``` ```
...@@ -983,11 +983,11 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): voi ...@@ -983,11 +983,11 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): voi
``` ```
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the mute status. ${err.message}'); console.error('Failed to obtain the mute status. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value); console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value);
}); });
``` ```
...@@ -1016,7 +1016,7 @@ isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt; ...@@ -1016,7 +1016,7 @@ isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
``` ```
audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value); console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value);
}); });
``` ```
...@@ -1039,11 +1039,11 @@ isActive(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): v ...@@ -1039,11 +1039,11 @@ isActive(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): v
``` ```
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the active status of the stream. ${err.message}'); console.error('Failed to obtain the active status of the stream. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value); console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value);
}); });
``` ```
...@@ -1071,7 +1071,7 @@ isActive(volumeType: AudioVolumeType): Promise&lt;boolean&gt; ...@@ -1071,7 +1071,7 @@ isActive(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
``` ```
audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => { audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => {
console.log('Promise returned to indicate that the active status of the stream is obtained.' + value); console.log('Promise returned to indicate that the active status of the stream is obtained.' + value);
}); });
``` ```
...@@ -1096,11 +1096,11 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void ...@@ -1096,11 +1096,11 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void
``` ```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
if (err) { if (err) {
console.error('Failed to set the ringer mode.​ ${err.message}'); console.error('Failed to set the ringer mode.​ ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate a successful setting of the ringer mode.'); console.log('Callback invoked to indicate a successful setting of the ringer mode.');
}); });
``` ```
...@@ -1130,7 +1130,7 @@ setRingerMode(mode: AudioRingMode): Promise&lt;void&gt; ...@@ -1130,7 +1130,7 @@ setRingerMode(mode: AudioRingMode): Promise&lt;void&gt;
``` ```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => { audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => {
console.log('Promise returned to indicate a successful setting of the ringer mode.'); console.log('Promise returned to indicate a successful setting of the ringer mode.');
}); });
``` ```
...@@ -1153,11 +1153,11 @@ getRingerMode(callback: AsyncCallback&lt;AudioRingMode&gt;): void ...@@ -1153,11 +1153,11 @@ getRingerMode(callback: AsyncCallback&lt;AudioRingMode&gt;): void
``` ```
audioManager.getRingerMode((err, value) => { audioManager.getRingerMode((err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the ringer mode.​ ${err.message}'); console.error('Failed to obtain the ringer mode.​ ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the ringer mode is obtained.' + value); console.log('Callback invoked to indicate that the ringer mode is obtained.' + value);
}); });
``` ```
...@@ -1180,7 +1180,7 @@ getRingerMode(): Promise&lt;AudioRingMode&gt; ...@@ -1180,7 +1180,7 @@ getRingerMode(): Promise&lt;AudioRingMode&gt;
``` ```
audioManager.getRingerMode().then((value) => { audioManager.getRingerMode().then((value) => {
console.log('Promise returned to indicate that the ringer mode is obtained.' + value); console.log('Promise returned to indicate that the ringer mode is obtained.' + value);
}); });
``` ```
...@@ -1208,11 +1208,11 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback&lt;void&gt ...@@ -1208,11 +1208,11 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback&lt;void&gt
``` ```
audioManager.setAudioParameter('key_example', 'value_example', (err) => { audioManager.setAudioParameter('key_example', 'value_example', (err) => {
if (err) { if (err) {
console.error('Failed to set the audio parameter. ${err.message}'); console.error('Failed to set the audio parameter. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate a successful setting of the audio parameter.'); console.log('Callback invoked to indicate a successful setting of the audio parameter.');
}); });
``` ```
...@@ -1245,7 +1245,7 @@ setAudioParameter(key: string, value: string): Promise&lt;void&gt; ...@@ -1245,7 +1245,7 @@ setAudioParameter(key: string, value: string): Promise&lt;void&gt;
``` ```
audioManager.setAudioParameter('key_example', 'value_example').then(() => { audioManager.setAudioParameter('key_example', 'value_example').then(() => {
console.log('Promise returned to indicate a successful setting of the audio parameter.'); console.log('Promise returned to indicate a successful setting of the audio parameter.');
}); });
``` ```
...@@ -1270,11 +1270,11 @@ getAudioParameter(key: string, callback: AsyncCallback&lt;string&gt;): void ...@@ -1270,11 +1270,11 @@ getAudioParameter(key: string, callback: AsyncCallback&lt;string&gt;): void
``` ```
audioManager.getAudioParameter('key_example', (err, value) => { audioManager.getAudioParameter('key_example', (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the value of the audio parameter. ${err.message}'); console.error('Failed to obtain the value of the audio parameter. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value); console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value);
}); });
``` ```
...@@ -1304,7 +1304,7 @@ getAudioParameter(key: string): Promise&lt;string&gt; ...@@ -1304,7 +1304,7 @@ getAudioParameter(key: string): Promise&lt;string&gt;
``` ```
audioManager.getAudioParameter('key_example').then((value) => { audioManager.getAudioParameter('key_example').then((value) => {
console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value); console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
}); });
``` ```
...@@ -1326,11 +1326,11 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescrip ...@@ -1326,11 +1326,11 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescrip
**示例:** **示例:**
``` ```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the device list. ${err.message}'); console.error('Failed to obtain the device list. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the device list is obtained.'); console.log('Callback invoked to indicate that the device list is obtained.');
}); });
``` ```
...@@ -1358,7 +1358,7 @@ getDevices(deviceFlag: DeviceFlag): Promise&lt;AudioDeviceDescriptors&gt; ...@@ -1358,7 +1358,7 @@ getDevices(deviceFlag: DeviceFlag): Promise&lt;AudioDeviceDescriptors&gt;
``` ```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
console.log('Promise returned to indicate that the device list is obtained.'); console.log('Promise returned to indicate that the device list is obtained.');
}); });
``` ```
...@@ -1382,11 +1382,11 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCa ...@@ -1382,11 +1382,11 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCa
``` ```
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => { audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
if (err) { if (err) {
console.error('Failed to set the active status of the device. ${err.message}'); console.error('Failed to set the active status of the device. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the device is set to the active status.'); console.log('Callback invoked to indicate that the device is set to the active status.');
}); });
``` ```
...@@ -1416,7 +1416,7 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise&lt;void& ...@@ -1416,7 +1416,7 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise&lt;void&
``` ```
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => { audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => {
console.log('Promise returned to indicate that the device is set to the active status.'); console.log('Promise returned to indicate that the device is set to the active status.');
}); });
``` ```
...@@ -1439,11 +1439,11 @@ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback&lt;boolean& ...@@ -1439,11 +1439,11 @@ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback&lt;boolean&
``` ```
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => { audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the active status of the device. ${err.message}'); console.error('Failed to obtain the active status of the device. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the active status of the device is obtained.'); console.log('Callback invoked to indicate that the active status of the device is obtained.');
}); });
``` ```
...@@ -1472,7 +1472,7 @@ isDeviceActive(deviceType: ActiveDeviceType): Promise&lt;boolean&gt; ...@@ -1472,7 +1472,7 @@ isDeviceActive(deviceType: ActiveDeviceType): Promise&lt;boolean&gt;
``` ```
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => { audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => {
console.log('Promise returned to indicate that the active status of the device is obtained.' + value); console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
}); });
``` ```
...@@ -1497,11 +1497,11 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -1497,11 +1497,11 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback&lt;void&gt;): void
``` ```
audioManager.setMicrophoneMute(true, (err) => { audioManager.setMicrophoneMute(true, (err) => {
if (err) { if (err) {
console.error('Failed to mute the microphone. ${err.message}'); console.error('Failed to mute the microphone. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the microphone is muted.'); console.log('Callback invoked to indicate that the microphone is muted.');
}); });
``` ```
...@@ -1531,7 +1531,7 @@ setMicrophoneMute(mute: boolean): Promise&lt;void&gt; ...@@ -1531,7 +1531,7 @@ setMicrophoneMute(mute: boolean): Promise&lt;void&gt;
``` ```
audioManager.setMicrophoneMute(true).then(() => { audioManager.setMicrophoneMute(true).then(() => {
console.log('Promise returned to indicate that the microphone is muted.'); console.log('Promise returned to indicate that the microphone is muted.');
}); });
``` ```
...@@ -1555,11 +1555,11 @@ isMicrophoneMute(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1555,11 +1555,11 @@ isMicrophoneMute(callback: AsyncCallback&lt;boolean&gt;): void
``` ```
audioManager.isMicrophoneMute((err, value) => { audioManager.isMicrophoneMute((err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the mute status of the microphone. ${err.message}'); console.error('Failed to obtain the mute status of the microphone. ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the mute status of the microphone is obtained.' + value); console.log('Callback invoked to indicate that the mute status of the microphone is obtained.' + value);
}); });
``` ```
...@@ -1584,7 +1584,7 @@ isMicrophoneMute(): Promise&lt;boolean&gt; ...@@ -1584,7 +1584,7 @@ isMicrophoneMute(): Promise&lt;boolean&gt;
``` ```
audioManager.isMicrophoneMute().then((value) => { audioManager.isMicrophoneMute().then((value) => {
console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value); console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
}); });
``` ```
...@@ -1611,9 +1611,9 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void ...@@ -1611,9 +1611,9 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
``` ```
audioManager.on('volumeChange', (volumeEvent) => { audioManager.on('volumeChange', (volumeEvent) => {
console.log('VolumeType of stream: ' + volumeEvent.volumeType); console.log('VolumeType of stream: ' + volumeEvent.volumeType);
console.log('Volume level: ' + volumeEvent.volume); console.log('Volume level: ' + volumeEvent.volume);
console.log('Whether to updateUI: ' + volumeEvent.updateUi); console.log('Whether to updateUI: ' + volumeEvent.updateUi);
}); });
``` ```
...@@ -1638,7 +1638,7 @@ on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void ...@@ -1638,7 +1638,7 @@ on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void
``` ```
audioManager.on('ringerModeChange', (ringerMode) => { audioManager.on('ringerModeChange', (ringerMode) => {
console.log('Updated ringermode: ' + ringerMode); console.log('Updated ringermode: ' + ringerMode);
}); });
``` ```
...@@ -1661,10 +1661,10 @@ on(type: 'deviceChange', callback: Callback<DeviceChangeAction\>): void ...@@ -1661,10 +1661,10 @@ on(type: 'deviceChange', callback: Callback<DeviceChangeAction\>): void
``` ```
audioManager.on('deviceChange', (deviceChanged) => { audioManager.on('deviceChange', (deviceChanged) => {
console.info("device change type : " + deviceChanged.type); console.info("device change type : " + deviceChanged.type);
console.info("device descriptor size : " + deviceChanged.deviceDescriptors.length); console.info("device descriptor size : " + deviceChanged.deviceDescriptors.length);
console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceRole); console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceRole);
console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceType); console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceType);
}); });
``` ```
...@@ -1687,7 +1687,7 @@ off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void ...@@ -1687,7 +1687,7 @@ off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void
``` ```
audioManager.off('deviceChange', (deviceChanged) => { audioManager.off('deviceChange', (deviceChanged) => {
console.log("Should be no callback."); console.log("Should be no callback.");
}); });
``` ```
...@@ -1711,19 +1711,19 @@ on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\<InterruptAc ...@@ -1711,19 +1711,19 @@ on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\<InterruptAc
``` ```
var interAudioInterrupt = { var interAudioInterrupt = {
streamUsage:2, streamUsage:2,
contentType:0, contentType:0,
pauseWhenDucked:true pauseWhenDucked:true
}; };
audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => { audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) { if (InterruptAction.actionType === 0) {
console.log("An event to gain the audio focus starts."); console.log("An event to gain the audio focus starts.");
console.log("Focus gain event:" + JSON.stringify(InterruptAction)); console.log("Focus gain event:" + JSON.stringify(InterruptAction));
} }
if (InterruptAction.actionType === 1) { if (InterruptAction.actionType === 1) {
console.log("An audio interruption event starts."); console.log("An audio interruption event starts.");
console.log("Audio interruption event:" + JSON.stringify(InterruptAction)); console.log("Audio interruption event:" + JSON.stringify(InterruptAction));
} }
}); });
``` ```
...@@ -1747,15 +1747,15 @@ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\<Interrupt ...@@ -1747,15 +1747,15 @@ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\<Interrupt
``` ```
var interAudioInterrupt = { var interAudioInterrupt = {
streamUsage:2, streamUsage:2,
contentType:0, contentType:0,
pauseWhenDucked:true pauseWhenDucked:true
}; };
audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => { audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) { if (InterruptAction.actionType === 0) {
console.log("An event to release the audio focus starts."); console.log("An event to release the audio focus starts.");
console.log("Focus release event:" + JSON.stringify(InterruptAction)); console.log("Focus release event:" + JSON.stringify(InterruptAction));
} }
}); });
``` ```
...@@ -1780,11 +1780,11 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void ...@@ -1780,11 +1780,11 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void
``` ```
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
if (err) { if (err) {
console.error('Failed to set the audio scene mode.​ ${err.message}'); console.error('Failed to set the audio scene mode.​ ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate a successful setting of the audio scene mode.'); console.log('Callback invoked to indicate a successful setting of the audio scene mode.');
}); });
``` ```
...@@ -1814,9 +1814,9 @@ setAudioScene\(scene: AudioScene\): Promise<void\> ...@@ -1814,9 +1814,9 @@ setAudioScene\(scene: AudioScene\): Promise<void\>
``` ```
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
console.log('Promise returned to indicate a successful setting of the audio scene mode.'); console.log('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => { }).catch ((err) => {
console.log('Failed to set the audio scene mode'); console.log('Failed to set the audio scene mode');
}); });
``` ```
...@@ -1838,11 +1838,11 @@ getAudioScene\(callback: AsyncCallback<AudioScene\>\): void ...@@ -1838,11 +1838,11 @@ getAudioScene\(callback: AsyncCallback<AudioScene\>\): void
``` ```
audioManager.getAudioScene((err, value) => { audioManager.getAudioScene((err, value) => {
if (err) { if (err) {
console.error('Failed to obtain the audio scene mode.​ ${err.message}'); console.error('Failed to obtain the audio scene mode.​ ${err.message}');
return; return;
} }
console.log('Callback invoked to indicate that the audio scene mode is obtained.' + value); console.log('Callback invoked to indicate that the audio scene mode is obtained.' + value);
}); });
``` ```
...@@ -1865,9 +1865,9 @@ getAudioScene\(\): Promise<AudioScene\> ...@@ -1865,9 +1865,9 @@ getAudioScene\(\): Promise<AudioScene\>
``` ```
audioManager.getAudioScene().then((value) => { audioManager.getAudioScene().then((value) => {
console.log('Promise returned to indicate that the audio scene mode is obtained.' + value); console.log('Promise returned to indicate that the audio scene mode is obtained.' + value);
}).catch ((err) => { }).catch ((err) => {
console.log('Failed to obtain the audio scene mode'); console.log('Failed to obtain the audio scene mode');
}); });
``` ```
...@@ -1892,36 +1892,35 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback&lt;AudioRendererChangeI ...@@ -1892,36 +1892,35 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback&lt;AudioRendererChangeI
**示例:** **示例:**
``` ```
audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => {
console.info('[GET_RENDERER_STATE_1_CALLBACK] **** Get Callback Called ****'); console.info('[GET_RENDERER_STATE_1_CALLBACK] **** Get Callback Called ****');
if (err) { if (err) {
console.log('getCurrentAudioRendererInfoArray :ERROR: '+err.message); console.log('getCurrentAudioRendererInfoArray :ERROR: '+err.message);
resultFlag = false; resultFlag = false;
} }
else { else {
if (AudioRendererChangeInfoArray !=null) { if (AudioRendererChangeInfoArray !=null) {
for (let i=0;i<AudioRendererChangeInfoArray.length;i++) { for (let i=0;i<AudioRendererChangeInfoArray.length;i++) {
AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
console.info('StreamId for '+i+' is:'+AudioRendererChangeInfo.streamId); console.info('StreamId for '+i+' is:'+AudioRendererChangeInfo.streamId);
console.info('ClientUid for '+i+' is:'+AudioRendererChangeInfo.clientUid); console.info('ClientUid for '+i+' is:'+AudioRendererChangeInfo.clientUid);
console.info('Content '+i+' is:'+AudioRendererChangeInfo.rendererInfo.content); console.info('Content '+i+' is:'+AudioRendererChangeInfo.rendererInfo.content);
console.info('Stream'+i+' is:'+AudioRendererChangeInfo.rendererInfo.usage); console.info('Stream'+i+' is:'+AudioRendererChangeInfo.rendererInfo.usage);
console.info('Flag'+i+' is:'+AudioRendererChangeInfo.rendererInfo.rendererFlags); console.info('Flag'+i+' is:'+AudioRendererChangeInfo.rendererInfo.rendererFlags);
console.info('State for '+i+' is:'+AudioRendererChangeInfo.rendererState); console.info('State for '+i+' is:'+AudioRendererChangeInfo.rendererState);
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors;
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; for (let j=0;j<AudioRendererChangeInfo.deviceDescriptors.length; j++) {
for (let j=0;j<AudioRendererChangeInfo.deviceDescriptors.length; j++) { console.info('Id:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].id);
console.info('Id:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].id); console.info('Type:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceType);
console.info('Type:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceType); console.info('Role:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceRole);
console.info('Role:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); console.info('Name:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].name);
console.info('Name:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].name); console.info('Address:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].address);
console.info('Address:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].address); console.info('SampleRates:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]);
console.info('SampleRates:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); console.info('ChannelCount'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]);
console.info('ChannelCount'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); console.info('ChannelMask:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
console.info('ChannelMask:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
}
}
} }
}
} }
}
}); });
``` ```
...@@ -1942,33 +1941,32 @@ getCurrentAudioRendererInfoArray(): Promise&lt;AudioRendererChangeInfoArray&gt; ...@@ -1942,33 +1941,32 @@ getCurrentAudioRendererInfoArray(): Promise&lt;AudioRendererChangeInfoArray&gt;
**示例:** **示例:**
``` ```
await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) {
console.info('[GET_RENDERER_STATE_3_PROMISE] ######### Get Promise is called ##########'); console.info('[GET_RENDERER_STATE_3_PROMISE] ######### Get Promise is called ##########');
if (AudioRendererChangeInfoArray!=null) { if (AudioRendererChangeInfoArray!=null) {
for (let i=0;i<AudioRendererChangeInfoArray.length;i++) { for (let i=0;i<AudioRendererChangeInfoArray.length;i++) {
AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
console.info('StreamId for '+i+' is:'+AudioRendererChangeInfo.streamId); console.info('StreamId for '+i+' is:'+AudioRendererChangeInfo.streamId);
console.info('ClientUid for '+i+' is:'+AudioRendererChangeInfo.clientUid); console.info('ClientUid for '+i+' is:'+AudioRendererChangeInfo.clientUid);
console.info('Content '+i+' is:'+AudioRendererChangeInfo.rendererInfo.content); console.info('Content '+i+' is:'+AudioRendererChangeInfo.rendererInfo.content);
console.info('Stream'+i+' is:'+AudioRendererChangeInfo.rendererInfo.usage); console.info('Stream'+i+' is:'+AudioRendererChangeInfo.rendererInfo.usage);
console.info('Flag'+i+' is:'+AudioRendererChangeInfo.rendererInfo.rendererFlags); console.info('Flag'+i+' is:'+AudioRendererChangeInfo.rendererInfo.rendererFlags);
console.info('State for '+i+' is:'+AudioRendererChangeInfo.rendererState); console.info('State for '+i+' is:'+AudioRendererChangeInfo.rendererState);
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors;
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; for (let j=0;j<AudioRendererChangeInfo.deviceDescriptors.length; j++) {
for (let j=0;j<AudioRendererChangeInfo.deviceDescriptors.length; j++) { console.info('Id:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].id);
console.info('Id:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].id); console.info('Type:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceType);
console.info('Type:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceType); console.info('Role:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceRole);
console.info('Role:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); console.info('Name:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].name);
console.info('Name:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].name); console.info('Address:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].address);
console.info('Address:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].address); console.info('SampleRates:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]);
console.info('SampleRates:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); console.info('ChannelCounts'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]);
console.info('ChannelCounts'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); console.info('ChannnelMask:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
console.info('ChannnelMask:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); }
}
}
} }
}
}).catch((err) => { }).catch((err) => {
console.log('getCurrentAudioRendererInfoArray :ERROR: '+err.message); console.log('getCurrentAudioRendererInfoArray :ERROR: '+err.message);
resultFlag = false; resultFlag = false;
}); });
``` ```
...@@ -1989,34 +1987,33 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback&lt;AudioCapturerChangeI ...@@ -1989,34 +1987,33 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback&lt;AudioCapturerChangeI
**示例:** **示例:**
``` ```
audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => {
console.info('[GET_CAPTURER_STATE_1_CALLBACK] **** Get Callback Called ****'); console.info('[GET_CAPTURER_STATE_1_CALLBACK] **** Get Callback Called ****');
if (err) { if (err) {
console.log('getCurrentAudioCapturerInfoArray :ERROR: '+err.message); console.log('getCurrentAudioCapturerInfoArray :ERROR: '+err.message);
resultFlag = false; resultFlag = false;
} }
else { else {
if (AudioCapturerChangeInfoArray !=null) { if (AudioCapturerChangeInfoArray !=null) {
for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) { for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) {
console.info('StreamId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId); console.info('StreamId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId);
console.info('ClientUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid); console.info('ClientUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid);
console.info('Source for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source); console.info('Source for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info('Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); console.info('Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info('State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState); console.info('State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState);
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { console.info('Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info('Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); console.info('Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info('Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); console.info('Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info('Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); console.info('Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name);
console.info('Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); console.info('Address:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
console.info('Address:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); console.info('SampleRates:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info('SampleRates:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); console.info('ChannelCounts'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info('ChannelCounts'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info('ChannelMask:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info('ChannelMask:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
}
}
} }
}
} }
}
}); });
``` ```
...@@ -2037,31 +2034,30 @@ getCurrentAudioCapturerInfoArray(): Promise&lt;AudioCapturerChangeInfoArray&gt; ...@@ -2037,31 +2034,30 @@ getCurrentAudioCapturerInfoArray(): Promise&lt;AudioCapturerChangeInfoArray&gt;
**示例:** **示例:**
``` ```
await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) {
console.info('AFCapturerChangeLog: [GET_CAP_STA_1_PR] **** Get Promise Called ****'); console.info('AFCapturerChangeLog: [GET_CAP_STA_1_PR] **** Get Promise Called ****');
if (AudioCapturerChangeInfoArray!=null) { if (AudioCapturerChangeInfoArray!=null) {
for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) { for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) {
console.info('StreamId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId); console.info('StreamId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId);
console.info('ClientUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid); console.info('ClientUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid);
console.info('Source for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source); console.info('Source for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info('Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); console.info('Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info('State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState); console.info('State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState);
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { console.info('Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info('Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); console.info('Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info('Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); console.info('Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info('Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); console.info('Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name)
console.info('Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name) console.info('Address:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
console.info('Address:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); console.info('SampleRates:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info('SampleRates:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); console.info('ChannelCounts'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info('ChannelCounts'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info('ChannelMask:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info('ChannelMask:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); }
}
}
} }
}
}).catch((err) => { }).catch((err) => {
console.log('getCurrentAudioCapturerInfoArray :ERROR: '+err.message); console.log('getCurrentAudioCapturerInfoArray :ERROR: '+err.message);
resultFlag = false; resultFlag = false;
}); });
``` ```
...@@ -2083,28 +2079,27 @@ on(type: "audioRendererChange", callback: Callback&lt;AudioRendererChangeInfoArr ...@@ -2083,28 +2079,27 @@ on(type: "audioRendererChange", callback: Callback&lt;AudioRendererChangeInfoArr
**示例:** **示例:**
``` ```
audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => {
for (let i=0;i<AudioRendererChangeInfoArray.length;i++) { for (let i=0;i<AudioRendererChangeInfoArray.length;i++) {
AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
console.info('## RendererChange on is called for '+i+' ##'); console.info('## RendererChange on is called for '+i+' ##');
console.info('StreamId for '+i+' is:'+AudioRendererChangeInfo.streamId); console.info('StreamId for '+i+' is:'+AudioRendererChangeInfo.streamId);
console.info('ClientUid for '+i+' is:'+AudioRendererChangeInfo.clientUid); console.info('ClientUid for '+i+' is:'+AudioRendererChangeInfo.clientUid);
console.info('Content for '+i+' is:'+AudioRendererChangeInfo.rendererInfo.content); console.info('Content for '+i+' is:'+AudioRendererChangeInfo.rendererInfo.content);
console.info('Stream for '+i+' is:'+AudioRendererChangeInfo.rendererInfo.usage); console.info('Stream for '+i+' is:'+AudioRendererChangeInfo.rendererInfo.usage);
console.info('Flag '+i+' is:'+AudioRendererChangeInfo.rendererInfo.rendererFlags); console.info('Flag '+i+' is:'+AudioRendererChangeInfo.rendererInfo.rendererFlags);
console.info('State for '+i+' is:'+AudioRendererChangeInfo.rendererState); console.info('State for '+i+' is:'+AudioRendererChangeInfo.rendererState);
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors;
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; for (let j=0;j<AudioRendererChangeInfo.deviceDescriptors.length; j++) {
for (let j=0;j<AudioRendererChangeInfo.deviceDescriptors.length; j++) { console.info('Id:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].id);
console.info('Id:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].id); console.info('Type:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceType);
console.info('Type:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceType); console.info('Role:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceRole);
console.info('Role:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); console.info('Name:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].name);
console.info('Name:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].name); console.info('Address:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].address);
console.info('Address:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].address); console.info('SampleRates:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]);
console.info('SampleRates:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); console.info('ChannelCounts'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]);
console.info('ChannelCounts'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); console.info('ChannelMask:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
console.info('ChannelMask:'+i+':'+AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
}
} }
}
}); });
``` ```
...@@ -2146,25 +2141,24 @@ on(type: "audioCapturerChange", callback: Callback&lt;AudioCapturerChangeInfoArr ...@@ -2146,25 +2141,24 @@ on(type: "audioCapturerChange", callback: Callback&lt;AudioCapturerChangeInfoArr
**示例:** **示例:**
``` ```
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) { for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) {
console.info(' ## CapChange on is called for element '+i+' ##'); console.info(' ## CapChange on is called for element '+i+' ##');
console.info('StreamId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId); console.info('StreamId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId);
console.info('ClientUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid); console.info('ClientUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid);
console.info('Source for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source); console.info('Source for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info('Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); console.info('Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info('State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState); console.info('State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState);
for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { console.info('Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info('Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); console.info('Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info('Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); console.info('Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info('Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); console.info('Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name);
console.info('Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); console.info('Address:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
console.info('Address:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); console.info('SampleRates:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info('SampleRates:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); console.info('ChannelCounts'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info('ChannelCounts'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info('ChannelMask:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info('ChannelMask:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
}
} }
}
}); });
``` ```
...@@ -2215,49 +2209,50 @@ import audio from '@ohos.multimedia.audio'; ...@@ -2215,49 +2209,50 @@ import audio from '@ohos.multimedia.audio';
var audioStreamManager; var audioStreamManager;
var audioStreamManagerCB; var audioStreamManagerCB;
var Tag = "AFCapLog : ";
await audioManager.getStreamManager().then(async function (data) { await audioManager.getStreamManager().then(async function (data) {
audioStreamManager = data; audioStreamManager = data;
console.info(Tag+'Get AudioStream Manager : Success '); console.info(Tag+'Get AudioStream Manager : Success ');
}).catch((err) => { }).catch((err) => {
console.info(Tag+'Get AudioStream Manager : ERROR : '+err.message); console.info(Tag+'Get AudioStream Manager : ERROR : '+err.message);
}); });
audioManager.getStreamManager((err, data) => { audioManager.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(Tag+'Get AudioStream Manager : ERROR : '+err.message); console.error(Tag+'Get AudioStream Manager : ERROR : '+err.message);
} }
else { else {
audioStreamManagerCB = data; audioStreamManagerCB = data;
console.info(Tag+'Get AudioStream Manager : Success '); console.info(Tag+'Get AudioStream Manager : Success ');
} }
}); });
audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => {
for (let i=0;i<AudioRendererChangeInfoArray.length;i++) { for (let i=0;i<AudioRendererChangeInfoArray.length;i++) {
console.info(Tag+'## RendererChange on is called for '+i+' ##'); console.info(Tag+'## RendererChange on is called for '+i+' ##');
console.info(Tag+'StreamId for '+i+' is:'+AudioRendererChangeInfoArray[i].streamId); console.info(Tag+'StreamId for '+i+' is:'+AudioRendererChangeInfoArray[i].streamId);
console.info(Tag+'ClientUid for '+i+' is:'+AudioRendererChangeInfoArray[i].clientUid); console.info(Tag+'ClientUid for '+i+' is:'+AudioRendererChangeInfoArray[i].clientUid);
console.info(Tag+'Content for '+i+' is:'+AudioRendererChangeInfoArray[i].rendererInfo.content); console.info(Tag+'Content for '+i+' is:'+AudioRendererChangeInfoArray[i].rendererInfo.content);
console.info(Tag+'Stream for '+i+' is:'+AudioRendererChangeInfoArray[i].rendererInfo.usage); console.info(Tag+'Stream for '+i+' is:'+AudioRendererChangeInfoArray[i].rendererInfo.usage);
console.info(Tag+'Flag '+i+' is:'+AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags); console.info(Tag+'Flag '+i+' is:'+AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags);
console.info(Tag+'State for '+i+' is:'+AudioRendererChangeInfoArray[i].rendererState); console.info(Tag+'State for '+i+' is:'+AudioRendererChangeInfoArray[i].rendererState);
var devDescriptor = AudioRendererChangeInfoArray[i].deviceDescriptors; var devDescriptor = AudioRendererChangeInfoArray[i].deviceDescriptors;
for (let j=0;j<AudioRendererChangeInfoArray[i].deviceDescriptors.length; j++) { for (let j=0;j<AudioRendererChangeInfoArray[i].deviceDescriptors.length; j++) {
console.info(Tag+'Id:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].id); console.info(Tag+'Id:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].id);
console.info(Tag+'Type:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType); console.info(Tag+'Type:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info(Tag+'Role:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole); console.info(Tag+'Role:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info(Tag+'Name:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].name); console.info(Tag+'Name:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].name);
console.info(Tag+'Addr:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].address); console.info(Tag+'Addr:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].address);
console.info(Tag+'SR:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); console.info(Tag+'SR:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info(Tag+'C'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info(Tag+'C'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(Tag+'CM:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag+'CM:'+i+':'+AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) { if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) {
resultFlag = true; resultFlag = true;
console.info(Tag+'[RENDERER-CHANGE-ON-001] ResultFlag for '+i+' is:'+resultFlag); console.info(Tag+'[RENDERER-CHANGE-ON-001] ResultFlag for '+i+' is:'+resultFlag);
}
} }
}
}); });
``` ```
...@@ -2287,29 +2282,29 @@ import audio from '@ohos.multimedia.audio'; ...@@ -2287,29 +2282,29 @@ import audio from '@ohos.multimedia.audio';
var Tag = "AFCapLog : "; var Tag = "AFCapLog : ";
const audioManager = audio.getAudioManager(); const audioManager = audio.getAudioManager();
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) { for (let i=0;i<AudioCapturerChangeInfoArray.length;i++) {
console.info(Tag+' ## CapChange on is called for element '+i+' ##'); console.info(Tag+' ## CapChange on is called for element '+i+' ##');
console.info(Tag+'StrId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId); console.info(Tag+'StrId for '+i+'is:'+AudioCapturerChangeInfoArray[i].streamId);
console.info(Tag+'CUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid); console.info(Tag+'CUid for '+i+'is:'+AudioCapturerChangeInfoArray[i].clientUid);
console.info(Tag+'Src for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source); console.info(Tag+'Src for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info(Tag+'Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); console.info(Tag+'Flag '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info(Tag+'State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState); console.info(Tag+'State for '+i+'is:'+AudioCapturerChangeInfoArray[i].capturerState);
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { for (let j=0;j<AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
console.info(Tag+'Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); console.info(Tag+'Id:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info(Tag+'Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); console.info(Tag+'Type:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info(Tag+'Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); console.info(Tag+'Role:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info(Tag+'Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); console.info(Tag+'Name:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name);
console.info(Tag+'Addr:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); console.info(Tag+'Addr:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
console.info(Tag+'SR:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); console.info(Tag+'SR:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info(Tag+'C'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info(Tag+'C'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(Tag+'CM:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag+'CM:'+i+':'+AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
}
if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) {
resultFlag = true;
console.info(Tag+'[CAPTURER-CHANGE-ON-001] ResultFlag for element '+i +' is: '+ resultFlag);
}
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) {
resultFlag = true;
console.info(Tag+'[CAPTURER-CHANGE-ON-001] ResultFlag for element '+i +' is: '+ resultFlag);
}
}
}); });
``` ```
...@@ -2340,23 +2335,22 @@ audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => ...@@ -2340,23 +2335,22 @@ audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) =>
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
function displayDeviceProp(value) { function displayDeviceProp(value) {
deviceRoleValue = value.deviceRole; deviceRoleValue = value.deviceRole;
deviceTypeValue = value.deviceType; deviceTypeValue = value.deviceType;
} }
var deviceRoleValue = null; var deviceRoleValue = null;
var deviceTypeValue = null; var deviceTypeValue = null;
const promise = audio.getAudioManager().getDevices(1); const promise = audio.getAudioManager().getDevices(1);
promise.then(function (value) { promise.then(function (value) {
console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG'); console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp); value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){ if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS'); console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS');
} }
else{ else{
console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL'); console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL');
} }
}); });
``` ```
...@@ -2396,10 +2390,10 @@ getRendererInfo(callback: AsyncCallback<AudioRendererInfo\>): void ...@@ -2396,10 +2390,10 @@ getRendererInfo(callback: AsyncCallback<AudioRendererInfo\>): void
``` ```
audioRenderer.getRendererInfo((err, rendererInfo) => { audioRenderer.getRendererInfo((err, rendererInfo) => {
console.log('Renderer GetRendererInfo:'); console.log('Renderer GetRendererInfo:');
console.log('Renderer content:' + rendererInfo.content); console.log('Renderer content:' + rendererInfo.content);
console.log('Renderer usage:' + rendererInfo.usage); console.log('Renderer usage:' + rendererInfo.usage);
console.log('Renderer flags:' + rendererInfo.rendererFlags); console.log('Renderer flags:' + rendererInfo.rendererFlags);
}); });
``` ```
...@@ -2422,13 +2416,13 @@ getRendererInfo(): Promise<AudioRendererInfo\> ...@@ -2422,13 +2416,13 @@ getRendererInfo(): Promise<AudioRendererInfo\>
``` ```
var resultFlag = true; var resultFlag = true;
audioRenderer.getRendererInfo().then((rendererInfo) => { audioRenderer.getRendererInfo().then((rendererInfo) => {
console.log('Renderer GetRendererInfo:'); console.log('Renderer GetRendererInfo:');
console.log('Renderer content:' + rendererInfo.content); console.log('Renderer content:' + rendererInfo.content);
console.log('Renderer usage:' + rendererInfo.usage); console.log('Renderer usage:' + rendererInfo.usage);
console.log('Renderer flags:' + rendererInfo.rendererFlags); console.log('Renderer flags:' + rendererInfo.rendererFlags);
}).catch((err) => { }).catch((err) => {
console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message);
resultFlag = false; resultFlag = false;
}); });
``` ```
...@@ -2450,11 +2444,11 @@ getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void ...@@ -2450,11 +2444,11 @@ getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void
``` ```
audioRenderer.getStreamInfo((err, streamInfo) => { audioRenderer.getStreamInfo((err, streamInfo) => {
console.log('Renderer GetStreamInfo:'); console.log('Renderer GetStreamInfo:');
console.log('Renderer sampling rate:' + streamInfo.samplingRate); console.log('Renderer sampling rate:' + streamInfo.samplingRate);
console.log('Renderer channel:' + streamInfo.channels); console.log('Renderer channel:' + streamInfo.channels);
console.log('Renderer format:' + streamInfo.sampleFormat); console.log('Renderer format:' + streamInfo.sampleFormat);
console.log('Renderer encoding type:' + streamInfo.encodingType); console.log('Renderer encoding type:' + streamInfo.encodingType);
}); });
``` ```
...@@ -2476,13 +2470,13 @@ getStreamInfo(): Promise<AudioStreamInfo\> ...@@ -2476,13 +2470,13 @@ getStreamInfo(): Promise<AudioStreamInfo\>
``` ```
audioRenderer.getStreamInfo().then((streamInfo) => { audioRenderer.getStreamInfo().then((streamInfo) => {
console.log('Renderer GetStreamInfo:'); console.log('Renderer GetStreamInfo:');
console.log('Renderer sampling rate:' + streamInfo.samplingRate); console.log('Renderer sampling rate:' + streamInfo.samplingRate);
console.log('Renderer channel:' + streamInfo.channels); console.log('Renderer channel:' + streamInfo.channels);
console.log('Renderer format:' + streamInfo.sampleFormat); console.log('Renderer format:' + streamInfo.sampleFormat);
console.log('Renderer encoding type:' + streamInfo.encodingType); console.log('Renderer encoding type:' + streamInfo.encodingType);
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -2504,11 +2498,11 @@ start(callback: AsyncCallback<void\>): void ...@@ -2504,11 +2498,11 @@ start(callback: AsyncCallback<void\>): void
``` ```
audioRenderer.start((err) => { audioRenderer.start((err) => {
if (err) { if (err) {
console.error('Renderer start failed.'); console.error('Renderer start failed.');
} else { } else {
console.info('Renderer start success.'); console.info('Renderer start success.');
} }
}); });
``` ```
...@@ -2530,9 +2524,9 @@ start(): Promise<void\> ...@@ -2530,9 +2524,9 @@ start(): Promise<void\>
``` ```
audioRenderer.start().then(() => { audioRenderer.start().then(() => {
console.log('Renderer started'); console.log('Renderer started');
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -2554,11 +2548,11 @@ pause(callback: AsyncCallback\<void>): void ...@@ -2554,11 +2548,11 @@ pause(callback: AsyncCallback\<void>): void
``` ```
audioRenderer.pause((err) => { audioRenderer.pause((err) => {
if (err) { if (err) {
console.error('Renderer pause failed'); console.error('Renderer pause failed');
} else { } else {
console.log('Renderer paused.'); console.log('Renderer paused.');
} }
}); });
``` ```
...@@ -2580,9 +2574,9 @@ pause(): Promise\<void> ...@@ -2580,9 +2574,9 @@ pause(): Promise\<void>
``` ```
audioRenderer.pause().then(() => { audioRenderer.pause().then(() => {
console.log('Renderer paused'); console.log('Renderer paused');
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -2604,11 +2598,11 @@ drain(callback: AsyncCallback\<void>): void ...@@ -2604,11 +2598,11 @@ drain(callback: AsyncCallback\<void>): void
``` ```
audioRenderer.drain((err) => { audioRenderer.drain((err) => {
if (err) { if (err) {
console.error('Renderer drain failed'); console.error('Renderer drain failed');
} else { } else {
console.log('Renderer drained.'); console.log('Renderer drained.');
} }
}); });
``` ```
...@@ -2630,9 +2624,9 @@ drain(): Promise\<void> ...@@ -2630,9 +2624,9 @@ drain(): Promise\<void>
``` ```
audioRenderer.drain().then(() => { audioRenderer.drain().then(() => {
console.log('Renderer drained successfully'); console.log('Renderer drained successfully');
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -2654,11 +2648,11 @@ stop(callback: AsyncCallback\<void>): void ...@@ -2654,11 +2648,11 @@ stop(callback: AsyncCallback\<void>): void
``` ```
audioRenderer.stop((err) => { audioRenderer.stop((err) => {
if (err) { if (err) {
console.error('Renderer stop failed'); console.error('Renderer stop failed');
} else { } else {
console.log('Renderer stopped.'); console.log('Renderer stopped.');
} }
}); });
``` ```
...@@ -2680,9 +2674,9 @@ stop(): Promise\<void> ...@@ -2680,9 +2674,9 @@ stop(): Promise\<void>
``` ```
audioRenderer.stop().then(() => { audioRenderer.stop().then(() => {
console.log('Renderer stopped successfully'); console.log('Renderer stopped successfully');
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -2704,11 +2698,11 @@ release(callback: AsyncCallback\<void>): void ...@@ -2704,11 +2698,11 @@ release(callback: AsyncCallback\<void>): void
``` ```
audioRenderer.release((err) => { audioRenderer.release((err) => {
if (err) { if (err) {
console.error('Renderer release failed'); console.error('Renderer release failed');
} else { } else {
console.log('Renderer released.'); console.log('Renderer released.');
} }
}); });
``` ```
...@@ -2730,9 +2724,9 @@ release(): Promise\<void> ...@@ -2730,9 +2724,9 @@ release(): Promise\<void>
``` ```
audioRenderer.release().then(() => { audioRenderer.release().then(() => {
console.log('Renderer released successfully'); console.log('Renderer released successfully');
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -2759,36 +2753,35 @@ import fileio from '@ohos.fileio'; ...@@ -2759,36 +2753,35 @@ import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_2, channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioRendererInfo = { var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH, content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION
rendererFlags: 1 rendererFlags: 1
}
var audioRendererOptions = { var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
var audioRenderer; var audioRenderer;
audio.createAudioRenderer(audioRendererOptions).then((data)=> { audio.createAudioRenderer(audioRendererOptions).then((data)=> {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message); console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message);
}); });
var bufferSize; var bufferSize;
audioRenderer.getBufferSize().then((data)=> { audioRenderer.getBufferSize().then((data)=> {
console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data); console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info.('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message); console.info.('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message);
}); });
console.info('Buffer size:'+bufferSize); console.info('Buffer size:'+bufferSize);
var context = featureAbility.getContext(); var context = featureAbility.getContext();
var path = await context.getCacheDir(); var path = await context.getCacheDir();
...@@ -2797,11 +2790,11 @@ let ss = fileio.createStreamSync(filePath, 'r'); ...@@ -2797,11 +2790,11 @@ let ss = fileio.createStreamSync(filePath, 'r');
let buf = new ArrayBuffer(bufferSize); let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf); ss.readSync(buf);
audioRenderer.write(buf, (err, writtenbytes) => { audioRenderer.write(buf, (err, writtenbytes) => {
if (writtenbytes < 0) { if (writtenbytes < 0) {
console.error('write failed.'); console.error('write failed.');
} else { } else {
console.log('Actual written bytes: ' + writtenbytes); console.log('Actual written bytes: ' + writtenbytes);
} }
}); });
``` ```
...@@ -2827,36 +2820,36 @@ import fileio from '@ohos.fileio'; ...@@ -2827,36 +2820,36 @@ import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var audioStreamInfo = { var audioStreamInfo = {
samplingRate:audio.AudioSamplingRate.SAMPLE_RATE_48000, samplingRate:audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels:audio.AudioChannel.CHANNEL_2, channels:audio.AudioChannel.CHANNEL_2,
sampleFormat:audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, sampleFormat:audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType:audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType:audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioRendererInfo = { var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH, content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
rendererFlags: 1 rendererFlags: 1
} }
var audioRendererOptions = { var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
var audioRenderer; var audioRenderer;
audio.createAudioRenderer(audioRendererOptions).then((data) => { audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message); console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message);
}); });
var bufferSize; var bufferSize;
audioRenderer.getBufferSize().then((data) => { audioRenderer.getBufferSize().then((data) => {
console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data); console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message); console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message);
}); });
console.info('BufferSize: ' + bufferSize); console.info('BufferSize: ' + bufferSize);
var context = featureAbility.getContext(); var context = featureAbility.getContext();
var path = await context.getCacheDir(); var path = await context.getCacheDir();
...@@ -2865,11 +2858,11 @@ let ss = fileio.createStreamSync(filePath, 'r'); ...@@ -2865,11 +2858,11 @@ let ss = fileio.createStreamSync(filePath, 'r');
let buf = new ArrayBuffer(bufferSize); let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf); ss.readSync(buf);
audioRenderer.write(buf).then((writtenbytes) => { audioRenderer.write(buf).then((writtenbytes) => {
if (writtenbytes < 0) { if (writtenbytes < 0) {
console.error('write failed.'); console.error('write failed.');
} else { } else {
console.log('Actual written bytes: ' + writtenbytes); console.log('Actual written bytes: ' + writtenbytes);
} }
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
...@@ -2893,7 +2886,7 @@ getAudioTime(callback: AsyncCallback\<number>): void ...@@ -2893,7 +2886,7 @@ getAudioTime(callback: AsyncCallback\<number>): void
``` ```
audioRenderer.getAudioTime((err, timestamp) => { audioRenderer.getAudioTime((err, timestamp) => {
console.log('Current timestamp: ' + timestamp); console.log('Current timestamp: ' + timestamp);
}); });
``` ```
...@@ -2915,9 +2908,9 @@ getAudioTime(): Promise\<number> ...@@ -2915,9 +2908,9 @@ getAudioTime(): Promise\<number>
``` ```
audioRenderer.getAudioTime().then((timestamp) => { audioRenderer.getAudioTime().then((timestamp) => {
console.log('Current timestamp: ' + timestamp); console.log('Current timestamp: ' + timestamp);
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -2939,9 +2932,9 @@ getBufferSize(callback: AsyncCallback\<number>): void ...@@ -2939,9 +2932,9 @@ getBufferSize(callback: AsyncCallback\<number>): void
``` ```
var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => { var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
if (err) { if (err) {
console.error('getBufferSize error'); console.error('getBufferSize error');
} }
}); });
``` ```
...@@ -2966,35 +2959,35 @@ import audio from '@ohos.multimedia.audio'; ...@@ -2966,35 +2959,35 @@ import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
var audioStreamInfo = { var audioStreamInfo = {
samplingRate:audio.AudioSamplingRate.SAMPLE_RATE_48000, samplingRate:audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels:audio.AudioChannel.CHANNEL_2, channels:audio.AudioChannel.CHANNEL_2,
sampleFormat:audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, sampleFormat:audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType:audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType:audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioRendererInfo = { var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH, content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
rendererFlags: 1 rendererFlags: 1
} }
var audioRendererOptions = { var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
var audioRenderer; var audioRenderer;
audio.createAudioRenderer(audioRendererOptions).then((data) => { audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message); console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message);
}); });
var bufferSize; var bufferSize;
audioRenderer.getBufferSize().then((data) => { audioRenderer.getBufferSize().then((data) => {
console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data); console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data);
bufferSize=data; bufferSize=data;
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message); console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message);
}); });
``` ```
...@@ -3017,11 +3010,11 @@ setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\<void>): void ...@@ -3017,11 +3010,11 @@ setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\<void>): void
``` ```
audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => { audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => {
if (err) { if (err) {
console.error('Failed to set params'); console.error('Failed to set params');
} else { } else {
console.log('Callback invoked to indicate a successful render rate setting.'); console.log('Callback invoked to indicate a successful render rate setting.');
} }
}); });
``` ```
...@@ -3049,9 +3042,9 @@ setRenderRate(rate: AudioRendererRate): Promise\<void> ...@@ -3049,9 +3042,9 @@ setRenderRate(rate: AudioRendererRate): Promise\<void>
``` ```
audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => { audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => {
console.log('setRenderRate SUCCESS'); console.log('setRenderRate SUCCESS');
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
...@@ -3073,7 +3066,7 @@ getRenderRate(callback: AsyncCallback\<AudioRendererRate>): void ...@@ -3073,7 +3066,7 @@ getRenderRate(callback: AsyncCallback\<AudioRendererRate>): void
``` ```
audioRenderer.getRenderRate((err, renderrate) => { audioRenderer.getRenderRate((err, renderrate) => {
console.log('getRenderRate: ' + renderrate); console.log('getRenderRate: ' + renderrate);
}); });
``` ```
...@@ -3095,9 +3088,9 @@ getRenderRate(): Promise\<AudioRendererRate> ...@@ -3095,9 +3088,9 @@ getRenderRate(): Promise\<AudioRendererRate>
``` ```
audioRenderer.getRenderRate().then((renderRate) => { audioRenderer.getRenderRate().then((renderRate) => {
console.log('getRenderRate: ' + renderRate); console.log('getRenderRate: ' + renderRate);
}).catch((err) => { }).catch((err) => {
console.log('ERROR: '+err.message); console.log('ERROR: '+err.message);
}); });
``` ```
### setInterruptMode<sup>9+</sup> ### setInterruptMode<sup>9+</sup>
...@@ -3124,26 +3117,26 @@ setInterruptMode(mode: InterruptMode): Promise&lt;void&gt; ...@@ -3124,26 +3117,26 @@ setInterruptMode(mode: InterruptMode): Promise&lt;void&gt;
``` ```
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_1, channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioRendererInfo = { var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_MUSIC, content: audio.ContentType.CONTENT_TYPE_MUSIC,
usage: audio.StreamUsage.STREAM_USAGE_MEDIA, usage: audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags: 0 rendererFlags: 0
} }
var audioRendererOptions = { var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
let mode = 0; let mode = 0;
audioRenderer.setInterruptMode(mode).then(data=>{ audioRenderer.setInterruptMode(mode).then(data=>{
console.log("setInterruptMode Success!"); console.log("setInterruptMode Success!");
}).catch(err=>{ }).catch(err=>{
console.log("setInterruptMode Fail:" + err.message); console.log("setInterruptMode Fail:" + err.message);
}); });
``` ```
### setInterruptMode<sup>9+</sup> ### setInterruptMode<sup>9+</sup>
...@@ -3165,27 +3158,27 @@ setInterruptMode(mode: InterruptMode, callback: Callback\<void>): void ...@@ -3165,27 +3158,27 @@ setInterruptMode(mode: InterruptMode, callback: Callback\<void>): void
``` ```
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_1, channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioRendererInfo = { var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_MUSIC, content: audio.ContentType.CONTENT_TYPE_MUSIC,
usage: audio.StreamUsage.STREAM_USAGE_MEDIA, usage: audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags: 0 rendererFlags: 0
} }
var audioRendererOptions = { var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
let mode = 1; let mode = 1;
audioRenderer.setInterruptMode(mode,(err,data)=>{ audioRenderer.setInterruptMode(mode,(err,data)=>{
if(err){ if(err){
console.log("setInterruptMode Fail:" + err.message); console.log("setInterruptMode Fail:" + err.message);
} }
console.log("setInterruptMode Success!"); console.log("setInterruptMode Success!");
}); });
``` ```
### on('interrupt')<sup>9+</sup> ### on('interrupt')<sup>9+</sup>
...@@ -3209,49 +3202,48 @@ on(type: 'interrupt', callback: Callback\<InterruptEvent>): void ...@@ -3209,49 +3202,48 @@ on(type: 'interrupt', callback: Callback\<InterruptEvent>): void
var isPlay; var isPlay;
var started; var started;
audioRenderer.on('interrupt', async(interruptEvent) => { audioRenderer.on('interrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
switch (interruptEvent.hintType) { switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE: case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
console.log('Force paused. Stop writing'); console.log('Force paused. Stop writing');
isPlay = false; isPlay = false;
break; break;
case audio.InterruptHint.INTERRUPT_HINT_STOP: case audio.InterruptHint.INTERRUPT_HINT_STOP:
console.log('Force stopped. Stop writing'); console.log('Force stopped. Stop writing');
isPlay = false; isPlay = false;
break; break;
} }
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
switch (interruptEvent.hintType) { switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME: case audio.InterruptHint.INTERRUPT_HINT_RESUME:
console.log('Resume force paused renderer or ignore'); console.log('Resume force paused renderer or ignore');
await audioRenderer.start().then(async function () { await audioRenderer.start().then(async function () {
console.info('AudioInterruptMusic: renderInstant started :SUCCESS '); console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
started = true; started = true;
}).catch((err) => { }).catch((err) => {
console.info('AudioInterruptMusic: renderInstant start :ERROR : '+err.message); console.info('AudioInterruptMusic: renderInstant start :ERROR : '+err.message);
started = false; started = false;
}); });
if (started) { if (started) {
isPlay = true; isPlay = true;
console.info('AudioInterruptMusic Renderer started : isPlay : '+isPlay); console.info('AudioInterruptMusic Renderer started : isPlay : '+isPlay);
} else { } else {
console.error('AudioInterruptMusic Renderer start failed'); console.error('AudioInterruptMusic Renderer start failed');
}
break;
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
console.log('Choose to pause or ignore');
if (isPlay == true) {
isPlay == false;
console.info('AudioInterruptMusic: Media PAUSE : TRUE');
}
else {
isPlay = true;
console.info('AudioInterruptMusic: Media PLAY : TRUE');
}
break;
} }
break;
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
console.log('Choose to pause or ignore');
if (isPlay == true) {
isPlay == false;
console.info('AudioInterruptMusic: Media PAUSE : TRUE');
}else {
isPlay = true;
console.info('AudioInterruptMusic: Media PLAY : TRUE');
}
break;
} }
}); }
});
``` ```
### on('markReach')<sup>8+</sup> ### on('markReach')<sup>8+</sup>
...@@ -3274,9 +3266,9 @@ on(type: 'markReach', frame: number, callback: (position: number) => {}): void ...@@ -3274,9 +3266,9 @@ on(type: 'markReach', frame: number, callback: (position: number) => {}): void
``` ```
audioRenderer.on('markReach', 1000, (position) => { audioRenderer.on('markReach', 1000, (position) => {
if (position == 1000) { if (position == 1000) {
console.log('ON Triggered successfully'); console.log('ON Triggered successfully');
} }
}); });
``` ```
...@@ -3321,9 +3313,9 @@ on(type: "periodReach", frame: number, callback: (position: number) => {}): void ...@@ -3321,9 +3313,9 @@ on(type: "periodReach", frame: number, callback: (position: number) => {}): void
``` ```
audioRenderer.on('periodReach', 1000, (position) => { audioRenderer.on('periodReach', 1000, (position) => {
if (position == 1000) { if (position == 1000) {
console.log('ON Triggered successfully'); console.log('ON Triggered successfully');
} }
}); });
``` ```
...@@ -3366,12 +3358,12 @@ on(type: 'stateChange', callback: Callback<AudioState\>): void ...@@ -3366,12 +3358,12 @@ on(type: 'stateChange', callback: Callback<AudioState\>): void
``` ```
audioRenderer.on('stateChange', (state) => { audioRenderer.on('stateChange', (state) => {
if (state == 1) { if (state == 1) {
console.log("audio renderer state is: STATE_PREPARED"); console.log("audio renderer state is: STATE_PREPARED");
} }
if (state == 2) { if (state == 2) {
console.log("audio renderer state is: STATE_RUNNING"); console.log("audio renderer state is: STATE_RUNNING");
} }
}); });
``` ```
...@@ -3411,13 +3403,13 @@ getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo\>): void ...@@ -3411,13 +3403,13 @@ getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo\>): void
``` ```
audioCapturer.getCapturerInfo((err, capturerInfo) => { audioCapturer.getCapturerInfo((err, capturerInfo) => {
if (err) { if (err) {
console.error('Failed to get capture info'); console.error('Failed to get capture info');
} else { } else {
console.log('Capturer getCapturerInfo:'); console.log('Capturer getCapturerInfo:');
console.log('Capturer source:' + capturerInfo.source); console.log('Capturer source:' + capturerInfo.source);
console.log('Capturer flags:' + capturerInfo.capturerFlags); console.log('Capturer flags:' + capturerInfo.capturerFlags);
} }
}); });
``` ```
...@@ -3440,16 +3432,16 @@ getCapturerInfo(): Promise<AudioCapturerInfo\> ...@@ -3440,16 +3432,16 @@ getCapturerInfo(): Promise<AudioCapturerInfo\>
``` ```
audioCapturer.getCapturerInfo().then((audioParamsGet) => { audioCapturer.getCapturerInfo().then((audioParamsGet) => {
if (audioParamsGet != undefined) { if (audioParamsGet != undefined) {
console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); console.info('AudioFrameworkRecLog: Capturer CapturerInfo:');
console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source);
console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags);
}else { }else {
console.info('AudioFrameworkRecLog: audioParamsGet is : '+audioParamsGet); console.info('AudioFrameworkRecLog: audioParamsGet is : '+audioParamsGet);
console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect: '); console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect: ');
} }
}).catch((err) => { }).catch((err) => {
console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message); console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message);
}); });
``` ```
...@@ -3471,15 +3463,15 @@ getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void ...@@ -3471,15 +3463,15 @@ getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void
``` ```
audioCapturer.getStreamInfo((err, streamInfo) => { audioCapturer.getStreamInfo((err, streamInfo) => {
if (err) { if (err) {
console.error('Failed to get stream info'); console.error('Failed to get stream info');
} else { } else {
console.log('Capturer GetStreamInfo:'); console.log('Capturer GetStreamInfo:');
console.log('Capturer sampling rate:' + streamInfo.samplingRate); console.log('Capturer sampling rate:' + streamInfo.samplingRate);
console.log('Capturer channel:' + streamInfo.channels); console.log('Capturer channel:' + streamInfo.channels);
console.log('Capturer format:' + streamInfo.sampleFormat); console.log('Capturer format:' + streamInfo.sampleFormat);
console.log('Capturer encoding type:' + streamInfo.encodingType); console.log('Capturer encoding type:' + streamInfo.encodingType);
} }
}); });
``` ```
...@@ -3501,13 +3493,13 @@ getStreamInfo(): Promise<AudioStreamInfo\> ...@@ -3501,13 +3493,13 @@ getStreamInfo(): Promise<AudioStreamInfo\>
``` ```
audioCapturer.getStreamInfo().then((audioParamsGet) => { audioCapturer.getStreamInfo().then((audioParamsGet) => {
console.info('getStreamInfo:'); console.info('getStreamInfo:');
console.info('sampleFormat:' + audioParamsGet.sampleFormat); console.info('sampleFormat:' + audioParamsGet.sampleFormat);
console.info('samplingRate:' + audioParamsGet.samplingRate); console.info('samplingRate:' + audioParamsGet.samplingRate);
console.info('channels:' + audioParamsGet.channels); console.info('channels:' + audioParamsGet.channels);
console.info('encodingType:' + audioParamsGet.encodingType); console.info('encodingType:' + audioParamsGet.encodingType);
}).catch((err) => { }).catch((err) => {
console.log('getStreamInfo :ERROR: ' + err.message); console.log('getStreamInfo :ERROR: ' + err.message);
}); });
``` ```
...@@ -3529,11 +3521,11 @@ start(callback: AsyncCallback<void\>): void ...@@ -3529,11 +3521,11 @@ start(callback: AsyncCallback<void\>): void
``` ```
audioCapturer.start((err) => { audioCapturer.start((err) => {
if (err) { if (err) {
console.error('Capturer start failed.'); console.error('Capturer start failed.');
} else { } else {
console.info('Capturer start success.'); console.info('Capturer start success.');
} }
}); });
``` ```
...@@ -3559,36 +3551,36 @@ import audio from '@ohos.multimedia.audio'; ...@@ -3559,36 +3551,36 @@ import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
var audioStreamInfo = { var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2, channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioCapturerInfo = { var audioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC, source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 1 capturerFlags: 1
} }
var audioCapturer; var audioCapturer;
var stateFlag; var stateFlag;
audio.createAudioCapturer(audioCapturerOptions).then((data) => { audio.createAudioCapturer(audioCapturerOptions).then((data) => {
audioCapturer = data; audioCapturer = data;
console.info('AudioFrameworkRecLog: AudioCapturer Created: SUCCESS'); console.info('AudioFrameworkRecLog: AudioCapturer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: AudioCapturer Created: ERROR: '+err.message); console.info('AudioFrameworkRecLog: AudioCapturer Created: ERROR: '+err.message);
}); });
audioCapturer.start().then(() => { audioCapturer.start().then(() => {
console.info('AudioFrameworkRecLog: ---------START---------'); console.info('AudioFrameworkRecLog: ---------START---------');
console.info('AudioFrameworkRecLog: Capturer started: SUCCESS'); console.info('AudioFrameworkRecLog: Capturer started: SUCCESS');
console.info('AudioFrameworkRecLog: AudioCapturer: STATE: '+audioCapturer.state); console.info('AudioFrameworkRecLog: AudioCapturer: STATE: '+audioCapturer.state);
console.info('AudioFrameworkRecLog: Capturer started: SUCCESS '); console.info('AudioFrameworkRecLog: Capturer started: SUCCESS ');
if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) { if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) {
console.info('AudioFrameworkRecLog: AudioCapturer is in Running State'); console.info('AudioFrameworkRecLog: AudioCapturer is in Running State');
} }
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message);
stateFlag=false; stateFlag=false;
}); });
``` ```
...@@ -3610,11 +3602,11 @@ stop(callback: AsyncCallback<void\>): void ...@@ -3610,11 +3602,11 @@ stop(callback: AsyncCallback<void\>): void
``` ```
audioCapturer.stop((err) => { audioCapturer.stop((err) => {
if (err) { if (err) {
console.error('Capturer stop failed'); console.error('Capturer stop failed');
} else { } else {
console.log('Capturer stopped.'); console.log('Capturer stopped.');
} }
}); });
``` ```
...@@ -3637,13 +3629,13 @@ stop(): Promise<void\> ...@@ -3637,13 +3629,13 @@ stop(): Promise<void\>
``` ```
audioCapturer.stop().then(() => { audioCapturer.stop().then(() => {
console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); console.info('AudioFrameworkRecLog: ---------STOP RECORD---------');
console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS'); console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS');
if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){ if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){
console.info('AudioFrameworkRecLog: State is Stopped': '); console.info('AudioFrameworkRecLog: State is Stopped': ');
} }
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer stop: ERROR: '+err.message); console.info('AudioFrameworkRecLog: Capturer stop: ERROR: '+err.message);
}); });
``` ```
...@@ -3665,11 +3657,11 @@ release(callback: AsyncCallback<void\>): void ...@@ -3665,11 +3657,11 @@ release(callback: AsyncCallback<void\>): void
``` ```
audioCapturer.release((err) => { audioCapturer.release((err) => {
if (err) { if (err) {
console.error('capturer release failed'); console.error('capturer release failed');
} else { } else {
console.log('capturer released.'); console.log('capturer released.');
} }
}); });
``` ```
...@@ -3693,12 +3685,12 @@ release(): Promise<void\> ...@@ -3693,12 +3685,12 @@ release(): Promise<void\>
``` ```
var stateFlag; var stateFlag;
audioCapturer.release().then(() => { audioCapturer.release().then(() => {
console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------');
console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); console.info('AudioFrameworkRecLog: Capturer release : SUCCESS');
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapturer.state); console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapturer.state);
console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer stop: ERROR: '+err.message); console.info('AudioFrameworkRecLog: Capturer stop: ERROR: '+err.message);
}); });
``` ```
...@@ -3724,15 +3716,15 @@ read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer\ ...@@ -3724,15 +3716,15 @@ read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer\
``` ```
var bufferSize; var bufferSize;
audioCapturer.getBufferSize().then((data) => { audioCapturer.getBufferSize().then((data) => {
console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS '+data); console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS '+data);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: getBufferSize: EROOR: '+err.message); console.info('AudioFrameworkRecLog: getBufferSize: EROOR: '+err.message);
}); });
audioCapturer.read(bufferSize, true, async(err, buffer) => { audioCapturer.read(bufferSize, true, async(err, buffer) => {
if (!err) { if (!err) {
console.log("Success in reading the buffer data"); console.log("Success in reading the buffer data");
} }
}); });
``` ```
...@@ -3763,16 +3755,16 @@ read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer\> ...@@ -3763,16 +3755,16 @@ read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer\>
``` ```
var bufferSize; var bufferSize;
audioCapturer.getBufferSize().then((data) => { audioCapturer.getBufferSize().then((data) => {
console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS '+data); console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS '+data);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: getBufferSize: ERROR '+err.message); console.info('AudioFrameworkRecLog: getBufferSize: ERROR '+err.message);
}); });
console.info('Buffer size: ' + bufferSize); console.info('Buffer size: ' + bufferSize);
audioCapturer.read(bufferSize, true).then((buffer) => { audioCapturer.read(bufferSize, true).then((buffer) => {
console.info('buffer read successfully'); console.info('buffer read successfully');
}).catch((err) => { }).catch((err) => {
console.info('ERROR : '+err.message); console.info('ERROR : '+err.message);
}); });
``` ```
...@@ -3795,7 +3787,7 @@ getAudioTime(callback: AsyncCallback<number\>): void ...@@ -3795,7 +3787,7 @@ getAudioTime(callback: AsyncCallback<number\>): void
``` ```
audioCapturer.getAudioTime((err, timestamp) => { audioCapturer.getAudioTime((err, timestamp) => {
console.log('Current timestamp: ' + timestamp); console.log('Current timestamp: ' + timestamp);
}); });
``` ```
...@@ -3818,9 +3810,9 @@ getAudioTime(): Promise<number\> ...@@ -3818,9 +3810,9 @@ getAudioTime(): Promise<number\>
``` ```
audioCapturer.getAudioTime().then((audioTime) => { audioCapturer.getAudioTime().then((audioTime) => {
console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime : Success' + audioTime ); console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime : Success' + audioTime );
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message);
}); });
``` ```
...@@ -3843,14 +3835,14 @@ getBufferSize(callback: AsyncCallback<number\>): void ...@@ -3843,14 +3835,14 @@ getBufferSize(callback: AsyncCallback<number\>): void
``` ```
audioCapturer.getBufferSize((err, bufferSize) => { audioCapturer.getBufferSize((err, bufferSize) => {
if (!err) { if (!err) {
console.log('BufferSize : ' + bufferSize); console.log('BufferSize : ' + bufferSize);
audioCapturer.read(bufferSize, true).then((buffer) => { audioCapturer.read(bufferSize, true).then((buffer) => {
console.info('Buffer read is ' + buffer ); console.info('Buffer read is ' + buffer );
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message);
}); });
} }
}); });
``` ```
...@@ -3874,10 +3866,10 @@ getBufferSize(): Promise<number\> ...@@ -3874,10 +3866,10 @@ getBufferSize(): Promise<number\>
``` ```
var bufferSize; var bufferSize;
audioCapturer.getBufferSize().then((data) => { audioCapturer.getBufferSize().then((data) => {
console.info('AudioFrameworkRecLog: getBufferSize :SUCCESS '+ data); console.info('AudioFrameworkRecLog: getBufferSize :SUCCESS '+ data);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: getBufferSize :ERROR : '+ err.message); console.info('AudioFrameworkRecLog: getBufferSize :ERROR : '+ err.message);
}); });
``` ```
...@@ -3902,9 +3894,9 @@ on(type: 'markReach', frame: number, callback: (position: number) => {}): void ...@@ -3902,9 +3894,9 @@ on(type: 'markReach', frame: number, callback: (position: number) => {}): void
``` ```
audioCapturer.on('markReach', 1000, (position) => { audioCapturer.on('markReach', 1000, (position) => {
if (position == 1000) { if (position == 1000) {
console.log('ON Triggered successfully'); console.log('ON Triggered successfully');
} }
}); });
``` ```
...@@ -3948,9 +3940,9 @@ on(type: "periodReach", frame: number, callback: (position: number) => {}): void ...@@ -3948,9 +3940,9 @@ on(type: "periodReach", frame: number, callback: (position: number) => {}): void
``` ```
audioCapturer.on('periodReach', 1000, (position) => { audioCapturer.on('periodReach', 1000, (position) => {
if (position == 1000) { if (position == 1000) {
console.log('ON Triggered successfully'); console.log('ON Triggered successfully');
} }
}); });
``` ```
...@@ -3993,11 +3985,11 @@ on(type: 'stateChange', callback: Callback<AudioState\>): void ...@@ -3993,11 +3985,11 @@ on(type: 'stateChange', callback: Callback<AudioState\>): void
``` ```
audioCapturer.on('stateChange', (state) => { audioCapturer.on('stateChange', (state) => {
if (state == 1) { if (state == 1) {
console.log("audio capturer state is: STATE_PREPARED"); console.log("audio capturer state is: STATE_PREPARED");
} }
if (state == 2) { if (state == 2) {
console.log("audio capturer state is: STATE_RUNNING"); console.log("audio capturer state is: STATE_RUNNING");
} }
}); });
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册