未验证 提交 52e05595 编写于 作者: O openharmony_ci 提交者: Gitee

!9142 翻译完成:8076+8266+8276 apis-audio更新

Merge pull request !9142 from wusongqing/TR8076
......@@ -14,7 +14,7 @@ This module provides the following common audio-related functions:
## Modules to Import
```
```js
import audio from '@ohos.multimedia.audio';
```
......@@ -28,12 +28,14 @@ Obtains an **AudioManager** instance.
**System capability**: SystemCapability.Multimedia.Audio.Core
**Return value**
| Type | Description |
| ----------------------------- | ------------ |
| [AudioManager](#audiomanager) | **AudioManager** instance.|
**Example**
```
```js
var audioManager = audio.getAudioManager();
```
......@@ -41,17 +43,19 @@ var audioManager = audio.getAudioManager();
getStreamManager(): AudioStreamManager
Obtains an **AudioStreamManager** instance.
Obtains an **AudioStreamManager** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Audio.Core
**Return value**
| Type | Description |
| -------------------------------------------------| ------------------------------- |
| [AudioStreamManager](#audiostreammanager9) | **AudioStreamManager** instance. |
| ---------------------------------------------------- | ---------------- |
| Promise<[AudioStreamManager](#audiostreammanager9)> | **AudioStreamManager** instance.|
**Example**
```
```js
var audioStreamManager = audio.getStreamManager();
```
......@@ -72,7 +76,7 @@ Obtains an **AudioRenderer** instance. This API uses an asynchronous callback to
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
......@@ -96,7 +100,7 @@ audio.createAudioRenderer(audioRendererOptions,(err, data) => {
if (err) {
console.error(`AudioRenderer Created : Error: ${err.message}`);
} else {
console.info(`AudioRenderer Created: Success: SUCCESS`);
console.info('AudioRenderer Created: Success: SUCCESS');
let audioRenderer = data;
}
});
......@@ -124,7 +128,7 @@ Obtains an **AudioRenderer** instance. This API uses a promise to return the res
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
var audioStreamInfo = {
......@@ -148,9 +152,9 @@ var audioRendererOptions = {
var audioRenderer;
audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data;
console.info(`AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS`);
console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info(`AudioFrameworkRenderLog: AudioRenderer Created : ERROR :` + err.message);
console.error(`AudioFrameworkRenderLog: AudioRenderer Created : ERROR : ${err.message}`);
});
```
......@@ -171,7 +175,7 @@ Obtains an **AudioCapturer** instance. This API uses an asynchronous callback to
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
......@@ -194,7 +198,7 @@ audio.createAudioCapturer(audioCapturerOptions, (err, data) => {
if (err) {
console.error(`AudioCapturer Created : Error: ${err.message}`);
} else {
console.info(`AudioCapturer Created : Success : SUCCESS`);
console.info('AudioCapturer Created : Success : SUCCESS');
let audioCapturer = data;
}
});
......@@ -222,7 +226,7 @@ Obtains an **AudioCapturer** instance. This API uses a promise to return the res
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
var audioStreamInfo = {
......@@ -245,9 +249,9 @@ var audioCapturerOptions = {
var audioCapturer;
audio.createAudioCapturer(audioCapturerOptions).then((data) => {
audioCapturer = data;
console.info(`AudioCapturer Created : Success : Stream Type: SUCCESS`);
console.info('AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info(`AudioCapturer Created : ERROR : ` + err.message);
console.error(`AudioCapturer Created : ERROR : ${err.message}`);
});
```
......@@ -282,8 +286,8 @@ Enumerates the audio device flags.
**System capability**: SystemCapability.Multimedia.Audio.Device
| Name | Default Value| Description |
| ------------------- | ------ | ---------- |
| Name | Default Value | Description |
| ------------------------------- | ------ | ------------------------------------------------- |
| OUTPUT_DEVICES_FLAG | 1 | Output device.|
| INPUT_DEVICES_FLAG | 2 | Input device.|
| ALL_DEVICES_FLAG | 3 | All devices.|
......@@ -308,7 +312,7 @@ Enumerates the audio device types.
**System capability**: SystemCapability.Multimedia.Audio.Device
| Name | Default Value| Description |
| ---------------- | ------ | --------------------------------------------------------- |
| ---------------------| ------ | --------------------------------------------------------- |
| INVALID | 0 | Invalid device. |
| EARPIECE | 1 | Earpiece. |
| SPEAKER | 2 | Speaker. |
......@@ -591,7 +595,7 @@ Describes the callback invoked for audio interruption or focus gain events.
Describes the event received by the application when the volume is changed.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Audio.Volume
......@@ -694,13 +698,13 @@ Sets the volume for a stream. This API uses an asynchronous callback to return t
**Example**
```
```js
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
if (err) {
console.error(`Failed to set the volume. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate a successful volume setting.`);
console.info('Callback invoked to indicate a successful volume setting.');
});
```
......@@ -729,9 +733,9 @@ Sets the volume for a stream. This API uses a promise to return the result.
**Example**
```
```js
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
console.log(`Promise returned to indicate a successful volume setting.`);
console.info('Promise returned to indicate a successful volume setting.');
});
```
......@@ -752,13 +756,13 @@ Obtains the volume of a stream. This API uses an asynchronous callback to return
**Example**
```
```js
audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error(`Failed to obtain the volume. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the volume is obtained.`);
console.info('Callback invoked to indicate that the volume is obtained.');
});
```
......@@ -784,9 +788,9 @@ Obtains the volume of a stream. This API uses a promise to return the result.
**Example**
```
```js
audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => {
console.log(`Promise returned to indicate that the volume is obtained.` + value);
console.info(`Promise returned to indicate that the volume is obtained ${value} .`);
});
```
......@@ -807,13 +811,13 @@ Obtains the minimum volume allowed for a stream. This API uses an asynchronous c
**Example**
```
```js
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error(`Failed to obtain the minimum volume. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the minimum volume is obtained.` + value);
console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`);
});
```
......@@ -839,9 +843,9 @@ Obtains the minimum volume allowed for a stream. This API uses a promise to retu
**Example**
```
```js
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => {
console.log(`Promised returned to indicate that the minimum volume is obtained.` + value);
console.info(`Promised returned to indicate that the minimum volume is obtained. ${value}`);
});
```
......@@ -862,13 +866,13 @@ Obtains the maximum volume allowed for a stream. This API uses an asynchronous c
**Example**
```
```js
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error(`Failed to obtain the maximum volume. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the maximum volume is obtained.` + value);
console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`);
});
```
......@@ -894,9 +898,9 @@ Obtains the maximum volume allowed for a stream. This API uses a promise to retu
**Example**
```
```js
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => {
console.log(`Promised returned to indicate that the maximum volume is obtained.`);
console.info('Promised returned to indicate that the maximum volume is obtained.');
});
```
......@@ -920,13 +924,13 @@ Mutes or unmutes a stream. This API uses an asynchronous callback to return the
**Example**
```
```js
audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
if (err) {
console.error(`Failed to mute the stream. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the stream is muted.`);
console.info('Callback invoked to indicate that the stream is muted.');
});
```
......@@ -955,10 +959,9 @@ Mutes or unmutes a stream. This API uses a promise to return the result.
**Example**
```
```js
audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
console.log(`Promise returned to indicate that the stream is muted.`);
console.info('Promise returned to indicate that the stream is muted.');
});
```
......@@ -980,17 +983,16 @@ Checks whether a stream is muted. This API uses an asynchronous callback to retu
**Example**
```
```js
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error(`Failed to obtain the mute status. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the mute status of the stream is obtained.` + value);
console.info(`Callback invoked to indicate that the mute status of the stream is obtained. ${value}`);
});
```
### isMute
isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
......@@ -1013,9 +1015,9 @@ Checks whether a stream is muted. This method uses a promise to return the resul
**Example**
```
```js
audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
console.log(`Promise returned to indicate that the mute status of the stream is obtained.` + value);
console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`);
});
```
......@@ -1036,13 +1038,13 @@ Checks whether a stream is active. This API uses an asynchronous callback to ret
**Example**
```
```js
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error(`Failed to obtain the active status of the stream. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the active status of the stream is obtained.` + value);
console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`);
});
```
......@@ -1068,9 +1070,9 @@ Checks whether a stream is active. This method uses a promise to return the resu
**Example**
```
```js
audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => {
console.log(`Promise returned to indicate that the active status of the stream is obtained.` + value);
console.info(`Promise returned to indicate that the active status of the stream is obtained ${value}.`);
});
```
......@@ -1093,13 +1095,13 @@ Sets the ringer mode. This API uses an asynchronous callback to return the resul
**Example**
```
```js
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
if (err) {
console.error(`Failed to set the ringer mode.​ ${err.message}`);
return;
}
console.log(`Callback invoked to indicate a successful setting of the ringer mode.`);
console.info('Callback invoked to indicate a successful setting of the ringer mode.');
});
```
......@@ -1109,7 +1111,7 @@ setRingerMode(mode: AudioRingMode): Promise&lt;void&gt;
Sets the ringer mode. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY (This permission is required only for muting or unmuting the ringer.)
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY (This permission is required only for muting or unmuting the ringer.
**System capability**: SystemCapability.Multimedia.Audio.Communication
......@@ -1127,9 +1129,9 @@ Sets the ringer mode. This API uses a promise to return the result.
**Example**
```
```js
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => {
console.log(`Promise returned to indicate a successful setting of the ringer mode.`);
console.info('Promise returned to indicate a successful setting of the ringer mode.');
});
```
......@@ -1150,13 +1152,13 @@ Obtains the ringer mode. This API uses an asynchronous callback to return the re
**Example**
```
```js
audioManager.getRingerMode((err, value) => {
if (err) {
console.error(`Failed to obtain the ringer mode.​ ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the ringer mode is obtained.` + value);
console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`);
});
```
......@@ -1177,9 +1179,9 @@ Obtains the ringer mode. This API uses a promise to return the result.
**Example**
```
```js
audioManager.getRingerMode().then((value) => {
console.log(`Promise returned to indicate that the ringer mode is obtained.` + value);
console.info(`Promise returned to indicate that the ringer mode is obtained ${value}.`);
});
```
......@@ -1205,13 +1207,13 @@ This API is used to extend the audio configuration based on the hardware capabil
**Example**
```
```js
audioManager.setAudioParameter('key_example', 'value_example', (err) => {
if (err) {
console.error(`Failed to set the audio parameter. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate a successful setting of the audio parameter.`);
console.info('Callback invoked to indicate a successful setting of the audio parameter.');
});
```
......@@ -1242,9 +1244,9 @@ This API is used to extend the audio configuration based on the hardware capabil
**Example**
```
```js
audioManager.setAudioParameter('key_example', 'value_example').then(() => {
console.log(`Promise returned to indicate a successful setting of the audio parameter.`);
console.info('Promise returned to indicate a successful setting of the audio parameter.');
});
```
......@@ -1267,13 +1269,13 @@ This API is used to extend the audio configuration based on the hardware capabil
**Example**
```
```js
audioManager.getAudioParameter('key_example', (err, value) => {
if (err) {
console.error(`Failed to obtain the value of the audio parameter. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the value of the audio parameter is obtained.` + value);
console.info(`Callback invoked to indicate that the value of the audio parameter is obtained ${value}.`);
});
```
......@@ -1301,9 +1303,9 @@ This API is used to extend the audio configuration based on the hardware capabil
**Example**
```
```js
audioManager.getAudioParameter('key_example').then((value) => {
console.log(`Promise returned to indicate that the value of the audio parameter is obtained.` + value);
console.info(`Promise returned to indicate that the value of the audio parameter is obtained ${value}.`);
});
```
......@@ -1323,13 +1325,14 @@ Obtains the audio devices with a specific flag. This API uses an asynchronous ca
| callback | AsyncCallback&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Yes | Callback used to return the device list.|
**Example**
```
```js
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
if (err) {
console.error(`Failed to obtain the device list. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the device list is obtained.`);
console.info('Callback invoked to indicate that the device list is obtained.');
});
```
......@@ -1355,9 +1358,9 @@ Obtains the audio devices with a specific flag. This API uses a promise to retur
**Example**
```
```js
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
console.log(`Promise returned to indicate that the device list is obtained.`);
console.info('Promise returned to indicate that the device list is obtained.');
});
```
......@@ -1379,13 +1382,13 @@ Sets a device to the active state. This API uses an asynchronous callback to ret
**Example**
```
```js
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
if (err) {
console.error(`Failed to set the active status of the device. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the device is set to the active status.`);
console.info('Callback invoked to indicate that the device is set to the active status.');
});
```
......@@ -1412,10 +1415,9 @@ Sets a device to the active state. This API uses a promise to return the result.
**Example**
```
```js
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => {
console.log(`Promise returned to indicate that the device is set to the active status.`);
console.info('Promise returned to indicate that the device is set to the active status.');
});
```
......@@ -1436,17 +1438,16 @@ Checks whether a device is active. This API uses an asynchronous callback to ret
**Example**
```
```js
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
if (err) {
console.error(`Failed to obtain the active status of the device. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the active status of the device is obtained.`);
console.info('Callback invoked to indicate that the active status of the device is obtained.');
});
```
### isDeviceActive
isDeviceActive(deviceType: ActiveDeviceType): Promise&lt;boolean&gt;
......@@ -1469,9 +1470,9 @@ Checks whether a device is active. This API uses a promise to return the result.
**Example**
```
```js
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => {
console.log(`Promise returned to indicate that the active status of the device is obtained.` + value);
console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`);
});
```
......@@ -1494,13 +1495,13 @@ Mutes or unmutes the microphone. This API uses an asynchronous callback to retur
**Example**
```
```js
audioManager.setMicrophoneMute(true, (err) => {
if (err) {
console.error(`Failed to mute the microphone. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the microphone is muted.`);
console.info('Callback invoked to indicate that the microphone is muted.');
});
```
......@@ -1528,9 +1529,9 @@ Mutes or unmutes the microphone. This API uses a promise to return the result.
**Example**
```
```js
audioManager.setMicrophoneMute(true).then(() => {
console.log(`Promise returned to indicate that the microphone is muted.`);
console.info('Promise returned to indicate that the microphone is muted.');
});
```
......@@ -1552,13 +1553,13 @@ Checks whether the microphone is muted. This API uses an asynchronous callback t
**Example**
```
```js
audioManager.isMicrophoneMute((err, value) => {
if (err) {
console.error(`Failed to obtain the mute status of the microphone. ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the mute status of the microphone is obtained.` + value);
console.info(`Callback invoked to indicate that the mute status of the microphone is obtained ${value}.`);
});
```
......@@ -1580,10 +1581,9 @@ Checks whether the microphone is muted. This API uses a promise to return the re
**Example**
```
```js
audioManager.isMicrophoneMute().then((value) => {
console.log(`Promise returned to indicate that the mute status of the microphone is obtained.`, + value);
console.info(`Promise returned to indicate that the mute status of the microphone is obtained ${value}.`);
});
```
......@@ -1593,7 +1593,7 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
Subscribes to system volume change events.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
Currently, when multiple **AudioManager** instances are used in a single process, only the subscription of the last instance takes effect, and the subscription of other instances is overwritten (even if the last instance does not initiate a subscription). Therefore, you are advised to use a single **AudioManager** instance.
......@@ -1608,11 +1608,11 @@ Currently, when multiple **AudioManager** instances are used in a single process
**Example**
```
```js
audioManager.on('volumeChange', (volumeEvent) => {
console.log(`VolumeType of stream: ` + volumeEvent.volumeType);
console.log(`Volume level: ` + volumeEvent.volume);
console.log(`Whether to updateUI: ` + volumeEvent.updateUi);
console.info(`VolumeType of stream: ${volumeEvent.volumeType} `);
console.info(`Volume level: ${volumeEvent.volume} `);
console.info(`Whether to updateUI: ${volumeEvent.updateUi} `);
});
```
......@@ -1622,7 +1622,7 @@ on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void
Subscribes to ringer mode change events.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Audio.Communication
......@@ -1631,13 +1631,13 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value **ringerModeChange** means the ringer mode change event, which is triggered when a ringer mode change is detected.|
| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the updated ringer mode. |
| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the system volume change event. |
**Example**
```
```js
audioManager.on('ringerModeChange', (ringerMode) => {
console.log(`Updated ringermode: ` + ringerMode);
console.info(`Updated ringermode: ${ringerMode}`);
});
```
......@@ -1658,12 +1658,12 @@ Subscribes to device change events. When a device is connected or disconnected,
**Example**
```
```js
audioManager.on('deviceChange', (deviceChanged) => {
console.info(`device change type : ` + deviceChanged.type);
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].deviceType);
console.info(`device change type : ${deviceChanged.type} `);
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].deviceType} `);
});
```
......@@ -1684,9 +1684,9 @@ Unsubscribes from device change events.
**Example**
```
```js
audioManager.off('deviceChange', (deviceChanged) => {
console.log(`Should be no callback.`);
console.info('Should be no callback.');
});
```
......@@ -1708,7 +1708,7 @@ Subscribes to audio interruption events. When the application's audio is interru
**Example**
```
```js
var interAudioInterrupt = {
streamUsage:2,
contentType:0,
......@@ -1716,12 +1716,12 @@ var interAudioInterrupt = {
};
audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log(`An event to gain the audio focus starts.`);
console.log(`Focus gain event:` + JSON.stringify(InterruptAction));
console.info('An event to gain the audio focus starts.');
console.info(`Focus gain event: ${InterruptAction} `);
}
if (InterruptAction.actionType === 1) {
console.log(`An audio interruption event starts.`);
console.log(`Audio interruption event:` + JSON.stringify(InterruptAction));
console.info('An audio interruption event starts.');
console.info(`Audio interruption event: ${InterruptAction} `);
}
});
```
......@@ -1744,7 +1744,7 @@ Unsubscribes from audio interruption events.
**Example**
```
```js
var interAudioInterrupt = {
streamUsage:2,
contentType:0,
......@@ -1752,8 +1752,8 @@ var interAudioInterrupt = {
};
audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log(`An event to release the audio focus starts.`);
console.log(`Focus release event:` + JSON.stringify(InterruptAction));
console.info('An event to release the audio focus starts.');
console.info(`Focus release event: ${InterruptAction} `);
}
});
```
......@@ -1764,7 +1764,7 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void
Sets an audio scene. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Audio.Communication
......@@ -1777,13 +1777,13 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
if (err) {
console.error(`Failed to set the audio scene mode.​ ${err.message}`);
return;
}
console.log(`Callback invoked to indicate a successful setting of the audio scene mode.`);
console.info('Callback invoked to indicate a successful setting of the audio scene mode.');
});
```
......@@ -1793,7 +1793,7 @@ setAudioScene\(scene: AudioScene\): Promise<void\>
Sets an audio scene. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Audio.Communication
......@@ -1811,11 +1811,11 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
console.log(`Promise returned to indicate a successful setting of the audio scene mode.`);
console.info('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => {
console.log(`Failed to set the audio scene mode`);
console.error(`Failed to set the audio scene mode ${err.message}`);
});
```
......@@ -1835,13 +1835,13 @@ Obtains the audio scene. This API uses an asynchronous callback to return the re
**Example**
```
```js
audioManager.getAudioScene((err, value) => {
if (err) {
console.error(`Failed to obtain the audio scene mode.​ ${err.message}`);
return;
}
console.log(`Callback invoked to indicate that the audio scene mode is obtained.` + value);
console.info(`Callback invoked to indicate that the audio scene mode is obtained ${value}.`);
});
```
......@@ -1862,11 +1862,11 @@ Obtains the audio scene. This API uses a promise to return the result.
**Example**
```
```js
audioManager.getAudioScene().then((value) => {
console.log(`Promise returned to indicate that the audio scene mode is obtained.` + value);
console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`);
}).catch ((err) => {
console.log(`Failed to obtain the audio scene mode`);
console.error(`Failed to obtain the audio scene mode ${err.message}`);
});
```
......@@ -1889,32 +1889,31 @@ Obtains the information about the current audio renderers. This API uses an asyn
| callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the audio renderer information.|
**Example**
```
```js
audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => {
console.info(`getCurrentAudioRendererInfoArray **** Get Callback Called ****`);
console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****');
if (err) {
console.log(`getCurrentAudioRendererInfoArray :ERROR: `+ err.message);
resultFlag = false;
console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err.message}`);
} else {
if (AudioRendererChangeInfoArray != null) {
for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
console.info(`StreamId for` + i + `is:` + AudioRendererChangeInfo.streamId);
console.info(`ClientUid for` + i + `is:` + AudioRendererChangeInfo.clientUid);
console.info(`Content` + i + `is:` + AudioRendererChangeInfo.rendererInfo.content);
console.info(`Stream`+ i + `is:` + AudioRendererChangeInfo.rendererInfo.usage);
console.info(`Flag`+ i + `is:` + AudioRendererChangeInfo.rendererInfo.rendererFlags);
console.info(`State for` + i + `is:` + AudioRendererChangeInfo.rendererState);
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors;
console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`);
console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`);
console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`);
console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`);
console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`);
console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`);
for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
console.info(`Id:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].id);
console.info(`Type:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].deviceType);
console.info(`Role:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole);
console.info(`Name:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].name);
console.info(`Address:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].address);
console.info(`SampleRates:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]);
console.info(`ChannelCount` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]);
console.info(`ChannelMask:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`);
console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`);
console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`);
console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`);
console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`);
}
}
}
......@@ -1937,33 +1936,33 @@ Obtains the information about the current audio renderers. This API uses a promi
| Promise<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Promise used to return the audio renderer information. |
**Example**
```
```js
await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) {
console.info(`getCurrentAudioRendererInfoArray ######### Get Promise is called ##########`);
if (AudioRendererChangeInfoArray != null) {
for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
console.info(`StreamId for` + i + ` is:` + AudioRendererChangeInfo.streamId);
console.info(`ClientUid for` + i + ` is:` + AudioRendererChangeInfo.clientUid);
console.info(`Content` + i + ` is:` + AudioRendererChangeInfo.rendererInfo.content);
console.info(`Stream` + i + ` is:` + AudioRendererChangeInfo.rendererInfo.usage);
console.info(`Flag` + i + ` is:` + AudioRendererChangeInfo.rendererInfo.rendererFlags);
console.info(`State for` + i + ` is:` + AudioRendererChangeInfo.rendererState);
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors;
for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
console.info(`Id:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].id);
console.info(`Type:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].deviceType);
console.info(`Role:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole);
console.info(`Name:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].name);
console.info(`Address:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].address);
console.info(`SampleRates:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]);
console.info(`ChannelCounts` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]);
console.info(`ChannnelMask:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`);
console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`);
console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`);
console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`);
console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`);
console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`);
for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`);
console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`);
console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`);
console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`);
console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`);
}
}
}
}).catch((err) => {
console.log(`getCurrentAudioRendererInfoArray :ERROR: ` + err.message);
console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err.message}`);
});
```
......@@ -1982,29 +1981,29 @@ Obtains the information about the current audio capturers. This API uses an asyn
| callback | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the audio capturer information.|
**Example**
```
```js
audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => {
console.info(`getCurrentAudioCapturerInfoArray **** Get Callback Called ****`);
console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****');
if (err) {
console.log(`getCurrentAudioCapturerInfoArray :ERROR: ` + err.message);
console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err.message}`);
} else {
if (AudioCapturerChangeInfoArray != null) {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(`StreamId for ` + i + `is:` + AudioCapturerChangeInfoArray[i].streamId);
console.info(`ClientUid for ` + i + `is:` + AudioCapturerChangeInfoArray[i].clientUid);
console.info(`Source for `+ i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info(`Flag ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info(`State for ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerState);
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
console.info(`Id:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info(`Type:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info(`Role:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info(`Name:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name);
console.info(`Address:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
console.info(`SampleRates:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info(`ChannelCounts` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(`ChannelMask:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
}
}
}
......@@ -2027,31 +2026,31 @@ Obtains the information about the current audio capturers. This API uses a promi
| Promise<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Promise used to return the audio capturer information. |
**Example**
```
```js
await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) {
console.info(`getCurrentAudioCapturerInfoArray **** Get Promise Called ****`);
console.info('getCurrentAudioCapturerInfoArray **** Get Promise Called ****');
if (AudioCapturerChangeInfoArray != null) {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(`StreamId for ` + i + `is:` + AudioCapturerChangeInfoArray[i].streamId);
console.info(`ClientUid for ` + i + `is:` + AudioCapturerChangeInfoArray[i].clientUid);
console.info(`Source for ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info(`Flag ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info(`State for ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerState);
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
console.info(`Id:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info(`Type:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info(`Role:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info(`Name:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name)
console.info(`Address:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
console.info(`SampleRates:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info(`ChannelCounts` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(`ChannelMask:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
}
}
}
}).catch((err) => {
console.log(`getCurrentAudioCapturerInfoArray :ERROR: ` + err.message);
console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err.message}`);
});
```
......@@ -2071,27 +2070,27 @@ Subscribes to audio renderer change events.
| callback | Callback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the result. |
**Example**
```
```js
audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => {
for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
console.info(`## RendererChange on is called for ` + i + ` ##`);
console.info(`StreamId for ` + i + ` is:` + AudioRendererChangeInfo.streamId);
console.info(`ClientUid for ` + i + ` is:` + AudioRendererChangeInfo.clientUid);
console.info(`Content for ` + i + ` is:` + AudioRendererChangeInfo.rendererInfo.content);
console.info(`Stream for ` + i + ` is:` + AudioRendererChangeInfo.rendererInfo.usage);
console.info(`Flag ` + i + ` is:` + AudioRendererChangeInfo.rendererInfo.rendererFlags);
console.info(`State for ` + i + ` is:` + AudioRendererChangeInfo.rendererState);
var devDescriptor = AudioRendererChangeInfo.deviceDescriptors;
for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
console.info(`Id:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].id);
console.info(`Type:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].deviceType);
console.info(`Role:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole);
console.info(`Name:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].name);
console.info(`Address:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].address);
console.info(`SampleRates:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]);
console.info(`ChannelCounts` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]);
console.info(`ChannelMask:` + i + `:` + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
console.info(`## RendererChange on is called for ${i} ##`);
console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`);
console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`);
console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`);
console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`);
console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`);
console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`);
for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`);
console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`);
console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`);
console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`);
console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`);
}
}
});
......@@ -2112,9 +2111,10 @@ Unsubscribes from audio renderer change events.
| type | string | Yes | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes.|
**Example**
```
```js
audioStreamManager.off('audioRendererChange');
console.info(`######### RendererChange Off is called #########`);
console.info('######### RendererChange Off is called #########');
```
### on('audioCapturerChange')<sup>9+</sup>
......@@ -2128,29 +2128,31 @@ Subscribes to audio capturer change events.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------- | --------- | ------------------------------------------------------------------- ---- |
| -------- | ------- | --------- | ----------------------------------------------------------------------- |
| type | string | Yes | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes. |
| callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the result. |
**Example**
```
```js
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(` ## CapChange on is called for element ' + i + ' ##');
console.info(`StreamId for ` + i + `is:` + AudioCapturerChangeInfoArray[i].streamId);
console.info(`ClientUid for ` + i + `is:` + AudioCapturerChangeInfoArray[i].clientUid);
console.info(`Source for ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info(`Flag ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info(`State for ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerState);
console.info(`## CapChange on is called for element ${i} ##');
console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
console.info(`Id:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info(`Type:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info(`Role:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info(`Name:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name);
console.info(`Address:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
console.info(`SampleRates:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]);
console.info(`ChannelCounts` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(`ChannelMask:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
}
}
});
......@@ -2171,9 +2173,10 @@ Unsubscribes from audio capturer change events.
| type | string |Yes | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes.|
**Example**
```
```js
audioStreamManager.off('audioCapturerChange');
console.info(`######### CapturerChange Off is called #########`);
console.info('######### CapturerChange Off is called #########');
```
......@@ -2198,53 +2201,52 @@ Describes the **AudioRenderChangeInfo** array, which is read-only.
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
var audioStreamManager;
var audioStreamManagerCB;
var Tag = "AFCapLog : ";
var resultFlag = false;
await audioManager.getStreamManager().then(async function (data) {
audioStreamManager = data;
console.info(Tag + `Get AudioStream Manager : Success `);
console.info('Get AudioStream Manager : Success');
}).catch((err) => {
console.info(Tag + `Get AudioStream Manager : ERROR : ` + err.message);
console.error(`Get AudioStream Manager : ERROR : ${err.message}`);
});
audioManager.getStreamManager((err, data) => {
if (err) {
console.error(Tag + `Get AudioStream Manager : ERROR : ` + err.message);
console.error(`Get AudioStream Manager : ERROR : ${err.message}`);
} else {
audioStreamManagerCB = data;
console.info(Tag + `Get AudioStream Manager : Success `);
console.info('Get AudioStream Manager : Success');
}
});
audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => {
for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
console.info(Tag + `## RendererChange on is called for ` + i + ` ##`);
console.info(Tag + `StreamId for ` + i + `is:` + AudioRendererChangeInfoArray[i].streamId);
console.info(Tag + `ClientUid for ` + i + `is:` + AudioRendererChangeInfoArray[i].clientUid);
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 + `Flag ` + i + `is:` + AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags);
console.info(Tag + `State for ` + i + `is:` + AudioRendererChangeInfoArray[i].rendererState);
console.info(`## RendererChange on is called for ${i} ##`);
console.info(`StreamId for ${i} is: ${AudioRendererChangeInfoArray[i].streamId}`);
console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfoArray[i].clientUid}`);
console.info(`Content for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.content}`);
console.info(`Stream for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.usage}`);
console.info(`Flag ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags}`);
console.info(`State for ${i} is: ${AudioRendererChangeInfoArray[i].rendererState}`);
var devDescriptor = AudioRendererChangeInfoArray[i].deviceDescriptors;
for (let j = 0; j < AudioRendererChangeInfoArray[i].deviceDescriptors.length; j++) {
console.info(Tag + `Id:` + i + `:` + AudioRendererChangeInfoArray[i].deviceDescriptors[j].id);
console.info(Tag + `Type:` + i + `:` + AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info(Tag + `Role:` + i + `:` + AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info(Tag + `Name:` + i + `:` + AudioRendererChangeInfoArray[i].deviceDescriptors[j].name);
console.info(Tag + `Addr:` + i + `:` + AudioRendererChangeInfoArray[i].deviceDescriptors[j].address);
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 + `CM:` + i + `:` + AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info(`Id: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].name}`);
console.info(`Addr: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].address}`);
console.info(`SR: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
console.info(`C ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
console.info(`CM: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
}
if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) {
resultFlag = true;
console.info(Tag + `ResultFlag for ` + i + ` is:` + resultFlag);
console.info(`ResultFlag for ${i} is: ${resultFlag}`);
}
}
});
......@@ -2271,34 +2273,33 @@ Describes the **AudioCapturerChangeInfo** array, which is read-only.
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
const audioManager = audio.getAudioManager();
var Tag = "AFCapLog : ";
var resultFlag = false;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ` ## CapChange on is called for element ' + i + ' ##');
console.info(Tag + `StrId for ` + i + `is:` + AudioCapturerChangeInfoArray[i].streamId);
console.info(Tag + `CUid for ` + i + `is:` + AudioCapturerChangeInfoArray[i].clientUid);
console.info(Tag + `Src for ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.source);
console.info(Tag + `Flag ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags);
console.info(Tag + `State for ` + i + `is:` + AudioCapturerChangeInfoArray[i].capturerState);
console.info(`## CapChange on is called for element ${i} ##`);
console.info(`StrId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
console.info(`CUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
console.info(`Src for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
console.info(Tag + `Id:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id);
console.info(Tag + `Type:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType);
console.info(Tag + `Role:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole);
console.info(Tag + `Name:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name);
console.info(Tag + `Addr:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address);
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 + `CM:` + i + `:` + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
console.info(`Addr: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
console.info(`SR: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
console.info(`C ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
console.info(`CM ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
}
if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) {
resultFlag = true;
console.info(Tag + `ResultFlag for element ` + i + ` is: ` + resultFlag);
console.info(`ResultFlag for element ${i} is: ${resultFlag}`);
}
}
});
......@@ -2311,7 +2312,7 @@ Describes an audio device.
**System capability**: SystemCapability.Multimedia.Audio.Device
| Name | Type | Readable| Writable| Description |
| -------------------------- | -------------------------- | ---- | ---- | ---------- |
| ----------------------------- | -------------------------- | ---- | ---- | ---------- |
| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.|
| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.|
| id<sup>9+</sup> | number | Yes | No | Device ID. |
......@@ -2327,7 +2328,7 @@ Array of [AudioDeviceDescriptor](#audiodevicedescriptor), which is read-only.
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
function displayDeviceProp(value) {
......@@ -2339,12 +2340,12 @@ var deviceRoleValue = null;
var deviceTypeValue = null;
const promise = audio.getAudioManager().getDevices(1);
promise.then(function (value) {
console.info(`AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG`);
console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info(`AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS`);
console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS');
} else {
console.info(`AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL`);
console.error('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL');
}
});
```
......@@ -2363,7 +2364,7 @@ Provides APIs for audio rendering. Before calling any API in **AudioRenderer**,
**Example**
```
```js
var state = audioRenderer.state;
```
......@@ -2383,12 +2384,12 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us
**Example**
```
```js
audioRenderer.getRendererInfo((err, rendererInfo) => {
console.log(`Renderer GetRendererInfo:`);
console.log(`Renderer content:` + rendererInfo.content);
console.log(`Renderer usage:` + rendererInfo.usage);
console.log(`Renderer flags:` + rendererInfo.rendererFlags);
console.info('Renderer GetRendererInfo:');
console.info(`Renderer content: ${rendererInfo.content}`);
console.info(`Renderer usage: ${rendererInfo.usage}`);
console.info(`Renderer flags: ${rendererInfo.rendererFlags}`);
});
```
......@@ -2408,16 +2409,14 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us
**Example**
```
var resultFlag = true;
```js
audioRenderer.getRendererInfo().then((rendererInfo) => {
console.log(`Renderer GetRendererInfo:`);
console.log(`Renderer content:` + rendererInfo.content);
console.log(`Renderer usage:` + rendererInfo.usage);
console.log(`Renderer flags:` + rendererInfo.rendererFlags);
console.info('Renderer GetRendererInfo:');
console.info(`Renderer content: ${rendererInfo.content}`);
console.info(`Renderer usage: ${rendererInfo.usage}`);
console.info(`Renderer flags: ${rendererInfo.rendererFlags}`)
}).catch((err) => {
console.log(`AudioFrameworkRenderLog: RendererInfo :ERROR: ` + err.message);
resultFlag = false;
console.error(`AudioFrameworkRenderLog: RendererInfo :ERROR: ${err.message}`);
});
```
......@@ -2437,13 +2436,13 @@ Obtains the stream information of this **AudioRenderer** instance. This API uses
**Example**
```
```js
audioRenderer.getStreamInfo((err, streamInfo) => {
console.log(`Renderer GetStreamInfo:`);
console.log(`Renderer sampling rate:` + streamInfo.samplingRate);
console.log(`Renderer channel:` + streamInfo.channels);
console.log(`Renderer format:` + streamInfo.sampleFormat);
console.log(`Renderer encoding type:` + streamInfo.encodingType);
console.info('Renderer GetStreamInfo:');
console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`);
console.info(`Renderer channel: ${streamInfo.channels}`);
console.info(`Renderer format: ${streamInfo.sampleFormat}`);
console.info(`Renderer encoding type: ${streamInfo.encodingType}`);
});
```
......@@ -2463,15 +2462,15 @@ Obtains the stream information of this **AudioRenderer** instance. This API uses
**Example**
```
```js
audioRenderer.getStreamInfo().then((streamInfo) => {
console.log(`Renderer GetStreamInfo:`);
console.log(`Renderer sampling rate:` + streamInfo.samplingRate);
console.log(`Renderer channel:` + streamInfo.channels);
console.log(`Renderer format:` + streamInfo.sampleFormat);
console.log(`Renderer encoding type:` + streamInfo.encodingType);
console.info('Renderer GetStreamInfo:');
console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`);
console.info(`Renderer channel: ${streamInfo.channels}`);
console.info(`Renderer format: ${streamInfo.sampleFormat}`);
console.info(`Renderer encoding type: ${streamInfo.encodingType}`);
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2491,12 +2490,12 @@ Starts the renderer. This API uses an asynchronous callback to return the result
**Example**
```
```js
audioRenderer.start((err) => {
if (err) {
console.error(`Renderer start failed.`);
console.error('Renderer start failed.');
} else {
console.info(`Renderer start success.`);
console.info('Renderer start success.');
}
});
```
......@@ -2517,11 +2516,11 @@ Starts the renderer. This API uses a promise to return the result.
**Example**
```
```js
audioRenderer.start().then(() => {
console.log(`Renderer started`);
console.info('Renderer started');
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2541,12 +2540,12 @@ Pauses rendering. This API uses an asynchronous callback to return the result.
**Example**
```
```js
audioRenderer.pause((err) => {
if (err) {
console.error(`Renderer pause failed`);
console.error('Renderer pause failed');
} else {
console.log(`Renderer paused.`);
console.info('Renderer paused.');
}
});
```
......@@ -2567,11 +2566,11 @@ Pauses rendering. This API uses a promise to return the result.
**Example**
```
```js
audioRenderer.pause().then(() => {
console.log(`Renderer paused`);
console.info('Renderer paused');
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2591,12 +2590,12 @@ Drains the playback buffer. This API uses an asynchronous callback to return the
**Example**
```
```js
audioRenderer.drain((err) => {
if (err) {
console.error(`Renderer drain failed`);
console.error('Renderer drain failed');
} else {
console.log(`Renderer drained.`);
console.info('Renderer drained.');
}
});
```
......@@ -2617,11 +2616,11 @@ Drains the playback buffer. This API uses a promise to return the result.
**Example**
```
```js
audioRenderer.drain().then(() => {
console.log(`Renderer drained successfully`);
console.info('Renderer drained successfully');
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2641,12 +2640,12 @@ Stops rendering. This API uses an asynchronous callback to return the result.
**Example**
```
```js
audioRenderer.stop((err) => {
if (err) {
console.error(`Renderer stop failed`);
console.error('Renderer stop failed');
} else {
console.log(`Renderer stopped.`);
console.info('Renderer stopped.');
}
});
```
......@@ -2667,11 +2666,11 @@ Stops rendering. This API uses a promise to return the result.
**Example**
```
```js
audioRenderer.stop().then(() => {
console.log(`Renderer stopped successfully`);
console.info('Renderer stopped successfully');
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2691,12 +2690,12 @@ Releases the renderer. This API uses an asynchronous callback to return the resu
**Example**
```
```js
audioRenderer.release((err) => {
if (err) {
console.error(`Renderer release failed`);
console.error('Renderer release failed');
} else {
console.log(`Renderer released.`);
console.info('Renderer released.');
}
});
```
......@@ -2717,11 +2716,11 @@ Releases the renderer. This API uses a promise to return the result.
**Example**
```
```js
audioRenderer.release().then(() => {
console.log(`Renderer released successfully`);
console.info('Renderer released successfully');
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2742,7 +2741,7 @@ Writes the buffer. This API uses an asynchronous callback to return the result.
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility'
......@@ -2767,29 +2766,29 @@ var audioRendererOptions = {
var audioRenderer;
audio.createAudioRenderer(audioRendererOptions).then((data)=> {
audioRenderer = data;
console.info(`AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS`);
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => {
console.info(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ` + err.message);
console.error(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err.message}`);
});
var bufferSize;
audioRenderer.getBufferSize().then((data)=> {
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ` + data);
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data;
}).catch((err) => {
console.info.(`AudioFrameworkRenderLog: getBufferSize: ERROR: ` + err.message);
console.error.(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err.message}`);
});
console.info(`Buffer size:` + bufferSize);
console.info(`Buffer size: ${bufferSize}`);
var context = featureAbility.getContext();
var path = await context.getCacheDir();
var filePath = path + "/StarWars10s-2C-48000-4SW.wav";
var filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let ss = fileio.createStreamSync(filePath, 'r');
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
audioRenderer.write(buf, (err, writtenbytes) => {
if (writtenbytes < 0) {
console.error(`write failed.`);
console.error('write failed.');
} else {
console.log(`Actual written bytes: ` + writtenbytes);
console.info(`Actual written bytes: ${writtenbytes}`);
}
});
```
......@@ -2810,7 +2809,7 @@ Writes the buffer. This API uses a promise to return the result.
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility'
......@@ -2835,18 +2834,18 @@ var audioRendererOptions = {
var audioRenderer;
audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data;
console.info(`AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS`);
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => {
console.info(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ` + err.message);
console.error(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err.message}`);
});
var bufferSize;
audioRenderer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ` + data);
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data;
}).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 path = await context.getCacheDir();
var filePath = 'data/StarWars10s-2C-48000-4SW.wav';
......@@ -2855,12 +2854,12 @@ let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
audioRenderer.write(buf).then((writtenbytes) => {
if (writtenbytes < 0) {
console.error(`write failed.`);
console.error('write failed.');
} else {
console.log(`Actual written bytes: ` + writtenbytes);
console.info(`Actual written bytes: ${writtenbytes}`);
}
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2880,9 +2879,9 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
**Example**
```
```js
audioRenderer.getAudioTime((err, timestamp) => {
console.log(`Current timestamp: ` + timestamp);
console.info(`Current timestamp: ${timestamp}`);
});
```
......@@ -2902,11 +2901,11 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
**Example**
```
```js
audioRenderer.getAudioTime().then((timestamp) => {
console.log(`Current timestamp: ` + timestamp);
console.info(`Current timestamp: ${timestamp}`);
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -2926,10 +2925,10 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a
**Example**
```
```js
var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
if (err) {
console.error(`getBufferSize error`);
console.error('getBufferSize error');
}
});
```
......@@ -2950,7 +2949,7 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio';
......@@ -2976,14 +2975,14 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ' + err.message);
console.info(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err.message}`);
});
var bufferSize;
audioRenderer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ` + data);
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data;
}).catch((err) => {
console.info(`AudioFrameworkRenderLog: getBufferSize: ERROR: ` + err.message);
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err.message}`);
});
```
......@@ -3004,12 +3003,12 @@ Sets the render rate. This API uses an asynchronous callback to return the resul
**Example**
```
```js
audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => {
if (err) {
console.error(`Failed to set params`);
console.error('Failed to set params');
} else {
console.log(`Callback invoked to indicate a successful render rate setting.`);
console.info('Callback invoked to indicate a successful render rate setting.');
}
});
```
......@@ -3036,11 +3035,11 @@ Sets the render rate. This API uses a promise to return the result.
**Example**
```
```js
audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => {
console.log(`setRenderRate SUCCESS`);
console.info('setRenderRate SUCCESS');
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
......@@ -3060,9 +3059,9 @@ Obtains the current render rate. This API uses an asynchronous callback to retur
**Example**
```
```js
audioRenderer.getRenderRate((err, renderrate) => {
console.log(`getRenderRate: ` + renderrate);
console.info(`getRenderRate: ${renderrate}`);
});
```
......@@ -3082,11 +3081,11 @@ Obtains the current render rate. This API uses a promise to return the result.
**Example**
```
```js
audioRenderer.getRenderRate().then((renderRate) => {
console.log(`getRenderRate: ` + renderRate);
console.info(`getRenderRate: ${renderRate}`);
}).catch((err) => {
console.log(`ERROR: ` + err.message);
console.error(`ERROR: ${err.message}`);
});
```
### setInterruptMode<sup>9+</sup>
......@@ -3111,7 +3110,7 @@ Sets the audio interruption mode for the application. This API uses a promise to
**Example**
```
```js
var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_1,
......@@ -3130,9 +3129,9 @@ var audioRendererOptions = {
let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
let mode = 0;
audioRenderer.setInterruptMode(mode).then(data=>{
console.log(`setInterruptMode Success!`);
}).catch(err=>{
console.log(`setInterruptMode Fail:` + err.message);
console.info('setInterruptMode Success!');
}).catch((err) => {
console.error(`setInterruptMode Fail: ${err.message}`);
});
```
### setInterruptMode<sup>9+</sup>
......@@ -3152,7 +3151,7 @@ Sets the audio interruption mode for the application. This API uses a callback t
**Example**
```
```js
var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_1,
......@@ -3172,9 +3171,9 @@ let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
let mode = 1;
audioRenderer.setInterruptMode(mode, (err, data)=>{
if(err){
console.log(`setInterruptMode Fail:` + err.message);
console.error(`setInterruptMode Fail: ${err.message}`);
}
console.log(`setInterruptMode Success!`);
console.info('setInterruptMode Success!');
});
```
### on('interrupt')<sup>9+</sup>
......@@ -3194,47 +3193,47 @@ Subscribes to audio interruption events. This API uses a callback to get interru
**Example**
```
```js
var isPlay;
var started;
audioRenderer.on('interrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
console.log(`Force paused. Stop writing`);
console.info('Force paused. Stop writing');
isPlay = false;
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
console.log(`Force stopped. Stop writing`);
console.info('Force stopped. Stop writing');
isPlay = false;
break;
}
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
console.log(`Resume force paused renderer or ignore`);
console.info('Resume force paused renderer or ignore');
await audioRenderer.start().then(async function () {
console.info(`AudioInterruptMusic: renderInstant started :SUCCESS `);
console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
started = true;
}).catch((err) => {
console.info(`AudioInterruptMusic: renderInstant start :ERROR : ` + err.message);
console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err.message}`);
started = false;
});
if (started) {
isPlay = true;
console.info(`AudioInterruptMusic Renderer started : isPlay : ` + isPlay);
console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`);
} 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');
console.info('Choose to pause or ignore');
if (isPlay == true) {
isPlay == false;
console.info(`AudioInterruptMusic: Media PAUSE : TRUE`);
console.info('AudioInterruptMusic: Media PAUSE : TRUE');
} else {
isPlay = true;
console.info(`AudioInterruptMusic: Media PLAY : TRUE`);
console.info('AudioInterruptMusic: Media PLAY : TRUE');
}
break;
}
......@@ -3260,10 +3259,10 @@ Subscribes to mark reached events. When the number of frames rendered reaches th
**Example**
```
```js
audioRenderer.on('markReach', 1000, (position) => {
if (position == 1000) {
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
});
```
......@@ -3285,7 +3284,7 @@ Unsubscribes from mark reached events.
**Example**
```
```js
audioRenderer.off('markReach');
```
......@@ -3302,15 +3301,15 @@ Subscribes to period reached events. When the period of frame rendering reaches
| Name | Type | Mandatory| Description |
| :------- | :----------------------- | :--- | :------------------------------------------ |
| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter.|
| frame | number | Yes | Period during which frame rendering is listened. The value must be greater than **0**. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
**Example**
```
```js
audioRenderer.on('periodReach', 1000, (position) => {
if (position == 1000) {
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
});
```
......@@ -3331,7 +3330,7 @@ Unsubscribes from period reached events.
**Example**
```
```js
audioRenderer.off('periodReach')
```
......@@ -3352,13 +3351,13 @@ Subscribes to state change events.
**Example**
```
```js
audioRenderer.on('stateChange', (state) => {
if (state == 1) {
console.log(`audio renderer state is: STATE_PREPARED`);
console.info('audio renderer state is: STATE_PREPARED');
}
if (state == 2) {
console.log(`audio renderer state is: STATE_RUNNING`);
console.info('audio renderer state is: STATE_RUNNING');
}
});
```
......@@ -3377,7 +3376,7 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
**Example**
```
```js
var state = audioCapturer.state;
```
......@@ -3397,14 +3396,14 @@ Obtains the capturer information of this **AudioCapturer** instance. This API us
**Example**
```
```js
audioCapturer.getCapturerInfo((err, capturerInfo) => {
if (err) {
console.error(`Failed to get capture info`);
console.error('Failed to get capture info');
} else {
console.log(`Capturer getCapturerInfo:`);
console.log(`Capturer source:` + capturerInfo.source);
console.log(`Capturer flags:` + capturerInfo.capturerFlags);
console.info('Capturer getCapturerInfo:');
console.info(`Capturer source: ${capturerInfo.source}`);
console.info(`Capturer flags: ${capturerInfo.capturerFlags}`);
}
});
```
......@@ -3426,18 +3425,18 @@ Obtains the capturer information of this **AudioCapturer** instance. This API us
**Example**
```
```js
audioCapturer.getCapturerInfo().then((audioParamsGet) => {
if (audioParamsGet != undefined) {
console.info(`AudioFrameworkRecLog: Capturer CapturerInfo:`);
console.info(`AudioFrameworkRecLog: Capturer SourceType:` + audioParamsGet.source);
console.info(`AudioFrameworkRecLog: Capturer capturerFlags:` + audioParamsGet.capturerFlags);
console.info('AudioFrameworkRecLog: Capturer CapturerInfo:');
console.info(`AudioFrameworkRecLog: Capturer SourceType: ${audioParamsGet.source}`);
console.info(`AudioFrameworkRecLog: Capturer capturerFlags: ${audioParamsGet.capturerFlags}`);
} else {
console.info(`AudioFrameworkRecLog: audioParamsGet is : ` + audioParamsGet);
console.info(`AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect: `);
console.info(`AudioFrameworkRecLog: audioParamsGet is : ${audioParamsGet}`);
console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect');
}
}).catch((err) => {
console.log(`AudioFrameworkRecLog: CapturerInfo :ERROR: ` + err.message);
console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err.message}`);
});
```
......@@ -3457,16 +3456,16 @@ Obtains the stream information of this **AudioCapturer** instance. This API uses
**Example**
```
```js
audioCapturer.getStreamInfo((err, streamInfo) => {
if (err) {
console.error(`Failed to get stream info');
console.error('Failed to get stream info');
} else {
console.log(`Capturer GetStreamInfo:`);
console.log(`Capturer sampling rate:` + streamInfo.samplingRate);
console.log(`Capturer channel:` + streamInfo.channels);
console.log(`Capturer format:` + streamInfo.sampleFormat);
console.log(`Capturer encoding type:` + streamInfo.encodingType);
console.info('Capturer GetStreamInfo:');
console.info(`Capturer sampling rate: ${streamInfo.samplingRate}`);
console.info(`Capturer channel: ${streamInfo.channels}`);
console.info(`Capturer format: ${streamInfo.sampleFormat}`);
console.info(`Capturer encoding type: ${streamInfo.encodingType}`);
}
});
```
......@@ -3487,15 +3486,15 @@ Obtains the stream information of this **AudioCapturer** instance. This API uses
**Example**
```
```js
audioCapturer.getStreamInfo().then((audioParamsGet) => {
console.info(`getStreamInfo:`);
console.info(`sampleFormat:` + audioParamsGet.sampleFormat);
console.info(`samplingRate:` + audioParamsGet.samplingRate);
console.info(`channels:` + audioParamsGet.channels);
console.info(`encodingType:` + audioParamsGet.encodingType);
console.info('getStreamInfo:');
console.info(`sampleFormat: ${audioParamsGet.sampleFormat}`);
console.info(`samplingRate: ${audioParamsGet.samplingRate}`);
console.info(`channels: ${audioParamsGet.channels}`);
console.info(`encodingType: ${audioParamsGet.encodingType}`);
}).catch((err) => {
console.log(`getStreamInfo :ERROR: ` + err.message);
console.error(`getStreamInfo :ERROR: ${err.message}`);
});
```
......@@ -3515,12 +3514,12 @@ Starts capturing. This API uses an asynchronous callback to return the result.
**Example**
```
```js
audioCapturer.start((err) => {
if (err) {
console.error(`Capturer start failed.`);
console.error('Capturer start failed.');
} else {
console.info(`Capturer start success.`);
console.info('Capturer start success.');
}
});
```
......@@ -3542,7 +3541,7 @@ Starts capturing. This API uses a promise to return the result.
**Example**
```
```js
import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio';
......@@ -3559,23 +3558,22 @@ var audioCapturerInfo = {
}
var audioCapturer;
var stateFlag;
audio.createAudioCapturer(audioCapturerOptions).then((data) => {
audioCapturer = data;
console.info(`AudioFrameworkRecLog: AudioCapturer Created: SUCCESS`);
console.info('AudioFrameworkRecLog: AudioCapturer Created: SUCCESS');
}).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created: ERROR: ` + err.message);
console.info(`AudioFrameworkRecLog: AudioCapturer Created: ERROR: ${err.message}`);
});
audioCapturer.start().then(() => {
console.info(`AudioFrameworkRecLog: ---------START---------`);
console.info(`AudioFrameworkRecLog: Capturer started: SUCCESS`);
console.info(`AudioFrameworkRecLog: AudioCapturer: STATE: ` + audioCapturer.state);
console.info(`AudioFrameworkRecLog: Capturer started: SUCCESS `);
console.info('AudioFrameworkRecLog: ---------START---------');
console.info('AudioFrameworkRecLog: Capturer started: SUCCESS');
console.info(`AudioFrameworkRecLog: AudioCapturer: STATE: ${audioCapturer.state}`);
console.info('AudioFrameworkRecLog: Capturer started: SUCCESS');
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) => {
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ` + err.message);
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err.message}`);
stateFlag = false;
});
```
......@@ -3596,12 +3594,12 @@ Stops capturing. This API uses an asynchronous callback to return the result.
**Example**
```
```js
audioCapturer.stop((err) => {
if (err) {
console.error(`Capturer stop failed`);
console.error('Capturer stop failed');
} else {
console.log(`Capturer stopped.`);
console.info('Capturer stopped.');
}
});
```
......@@ -3623,15 +3621,15 @@ Stops capturing. This API uses a promise to return the result.
**Example**
```
```js
audioCapturer.stop().then(() => {
console.info(`AudioFrameworkRecLog: ---------STOP RECORD---------`);
console.info(`AudioFrameworkRecLog: Capturer stopped: SUCCESS`);
console.info('AudioFrameworkRecLog: ---------STOP RECORD---------');
console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS');
if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){
console.info(`AudioFrameworkRecLog: State is Stopped: `);
console.info('AudioFrameworkRecLog: State is Stopped:');
}
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ` + err.message);
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err.message}`);
});
```
......@@ -3651,12 +3649,12 @@ Releases this **AudioCapturer** instance. This API uses an asynchronous callback
**Example**
```
```js
audioCapturer.release((err) => {
if (err) {
console.error(`capturer release failed`);
console.error('capturer release failed');
} else {
console.log(`capturer released.`);
console.info('capturer released.');
}
});
```
......@@ -3678,15 +3676,15 @@ Releases this **AudioCapturer** instance. This API uses a promise to return the
**Example**
```
```js
var stateFlag;
audioCapturer.release().then(() => {
console.info(`AudioFrameworkRecLog: ---------RELEASE RECORD---------`);
console.info(`AudioFrameworkRecLog: Capturer release : SUCCESS`);
console.info(`AudioFrameworkRecLog: AudioCapturer : STATE : ` + audioCapturer.state);
console.info(`AudioFrameworkRecLog: stateFlag : ` + stateFlag);
console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------');
console.info('AudioFrameworkRecLog: Capturer release : SUCCESS');
console.info(`AudioFrameworkRecLog: AudioCapturer : STATE : ${audioCapturer.state}`);
console.info(`AudioFrameworkRecLog: stateFlag : ${stateFlag}`);
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ` + err.message);
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err.message}`);
});
```
......@@ -3709,17 +3707,17 @@ Reads the buffer. This API uses an asynchronous callback to return the result.
**Example**
```
```js
var bufferSize;
audioCapturer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ` + data);
console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data;
}).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize: EROOR: ` + err.message);
console.error(`AudioFrameworkRecLog: getBufferSize: EROOR: ${err.message}`);
});
audioCapturer.read(bufferSize, true, async(err, buffer) => {
if (!err) {
console.log(`Success in reading the buffer data`);
console.info('Success in reading the buffer data');
}
});
```
......@@ -3748,19 +3746,19 @@ Reads the buffer. This API uses a promise to return the result.
**Example**
```
```js
var bufferSize;
audioCapturer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ` + data);
console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data;
}).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) => {
console.info(`buffer read successfully`);
console.info('buffer read successfully');
}).catch((err) => {
console.info(`ERROR : ` + err.message);
console.info(`ERROR : ${err.message}`);
});
```
......@@ -3777,13 +3775,13 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
| Name | Type | Mandatory| Description |
| :------- | :--------------------- | :--- | :----------------------------- |
| callback | AsyncCallback<number\> | Yes | Callback used to return the timestamp. |
| callback | AsyncCallback<number\> | Yes | Callback used to return the result.|
**Example**
```
```js
audioCapturer.getAudioTime((err, timestamp) => {
console.log(`Current timestamp: ` + timestamp);
console.info(`Current timestamp: ${timestamp}`);
});
```
......@@ -3804,11 +3802,11 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
**Example**
```
```js
audioCapturer.getAudioTime().then((audioTime) => {
console.info(`AudioFrameworkRecLog: AudioCapturer getAudioTime : Success` + audioTime );
console.info(`AudioFrameworkRecLog: AudioCapturer getAudioTime : Success ${audioTime}`);
}).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ` + err.message);
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err.message}`);
});
```
......@@ -3829,14 +3827,14 @@ Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a
**Example**
```
```js
audioCapturer.getBufferSize((err, bufferSize) => {
if (!err) {
console.log(`BufferSize : ` + bufferSize);
console.info(`BufferSize : ${bufferSize}`);
audioCapturer.read(bufferSize, true).then((buffer) => {
console.info(`Buffer read is ` + buffer );
console.info(`Buffer read is ${buffer}`);
}).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ` + err.message);
console.error(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err.message}`);
});
}
});
......@@ -3859,13 +3857,13 @@ Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a
**Example**
```
```js
var bufferSize;
audioCapturer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRecLog: getBufferSize :SUCCESS ` + data);
console.info(`AudioFrameworkRecLog: getBufferSize :SUCCESS ${data}`);
bufferSize = data;
}).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ` + err.message);
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err.message}`);
});
```
......@@ -3884,14 +3882,14 @@ Subscribes to mark reached events. When the number of frames captured reaches th
| :------- | :---------------------- | :--- | :----------------------------------------- |
| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | position: number) => {} | Yes | Callback invoked when the event is triggered.|
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered.|
**Example**
```
```js
audioCapturer.on('markReach', 1000, (position) => {
if (position == 1000) {
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
});
```
......@@ -3912,7 +3910,7 @@ Unsubscribes from mark reached events.
**Example**
```
```js
audioCapturer.off('markReach');
```
......@@ -3928,16 +3926,16 @@ Subscribes to mark reached events. When the period of frame capturing reaches th
| Name | Type | Mandatory| Description |
| :------- | :----------------------- | :--- | :------------------------------------------ |
| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame capturing reaches the value of the **frame** parameter. |
| frame | number | Yes | Period during which frame capturing is listened. The value must be greater than **0**. |
| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter.|
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
**Example**
```
```js
audioCapturer.on('periodReach', 1000, (position) => {
if (position == 1000) {
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
});
```
......@@ -3958,7 +3956,7 @@ Unsubscribes from period reached events.
**Example**
```
```js
audioCapturer.off('periodReach')
```
......@@ -3979,13 +3977,13 @@ Subscribes to state change events.
**Example**
```
```js
audioCapturer.on('stateChange', (state) => {
if (state == 1) {
console.log(`audio capturer state is: STATE_PREPARED`);
console.info('audio capturer state is: STATE_PREPARED');
}
if (state == 2) {
console.log(`audio capturer state is: STATE_RUNNING`);
console.info('audio capturer state is: STATE_RUNNING');
}
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册