diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index a992de969d6b6e673b89eff8f14f28f5328ce017..0f4e0f79339043054cd47b5e76e58752012fd48f 100644
--- a/en/application-dev/reference/apis/js-apis-audio.md
+++ b/en/application-dev/reference/apis/js-apis-audio.md
@@ -75,7 +75,7 @@ Creates an **AudioRenderer** instance. This API uses an asynchronous callback to
```js
import featureAbility from '@ohos.ability.featureAbility';
-import fileio from '@ohos.fileio';
+import fs from '@ohos.file.fs';
import audio from '@ohos.multimedia.audio';
let audioStreamInfo = {
@@ -130,7 +130,7 @@ Creates an **AudioRenderer** instance. This API uses a promise to return the res
```js
import featureAbility from '@ohos.ability.featureAbility';
-import fileio from '@ohos.fileio';
+import fs from '@ohos.file.fs';
import audio from '@ohos.multimedia.audio';
let audioStreamInfo = {
@@ -457,7 +457,7 @@ Enumerates the audio sample formats.
| SAMPLE_FORMAT_S16LE | 1 | Signed 16-bit integer, little endian.|
| SAMPLE_FORMAT_S24LE | 2 | Signed 24-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.|
| SAMPLE_FORMAT_S32LE | 3 | Signed 32-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.|
-| SAMPLE_FORMAT_F32LE9+ | 4 | Signed 32-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.|
+| SAMPLE_FORMAT_F32LE9+ | 4 | Signed 32-bit floating point number, little endian.
Due to system restrictions, only some devices support this sampling format.|
## AudioErrors9+
@@ -529,7 +529,7 @@ Enumerates the audio content types.
| CONTENT_TYPE_SPEECH | 1 | Speech. |
| CONTENT_TYPE_MUSIC | 2 | Music. |
| CONTENT_TYPE_MOVIE | 3 | Movie. |
-| CONTENT_TYPE_SONIFICATION | 4 | Sonification content.|
+| CONTENT_TYPE_SONIFICATION | 4 | Notification tone. |
| CONTENT_TYPE_RINGTONE8+ | 5 | Ringtone. |
## StreamUsage
@@ -1757,7 +1757,7 @@ Sets a device to the active state. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
@@ -1789,7 +1789,7 @@ Sets a device to the active state. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type.|
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
**Return value**
@@ -1823,7 +1823,7 @@ Checks whether a device is active. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the active state of the device.|
**Example**
@@ -1854,7 +1854,7 @@ Checks whether a device is active. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type.|
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
**Return value**
@@ -3950,6 +3950,7 @@ Describes the audio renderer change event.
**Example**
```js
+
import audio from '@ohos.multimedia.audio';
const audioManager = audio.getAudioManager();
@@ -4054,7 +4055,7 @@ Describes an audio device.
| ----------------------------- | ------------------------- | -------- | -------- | ------------------------------------------------------------ |
| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role. |
| deviceType | [DeviceType](#devicetype) | Yes | No | Device type. |
-| id9+ | number | Yes | No | Device ID. |
+| id9+ | number | Yes | No | Device ID, which is unique. |
| name9+ | string | Yes | No | Device name. |
| address9+ | string | Yes | No | Device address. |
| sampleRates9+ | Array<number> | Yes | No | Supported sampling rates. |
@@ -4234,7 +4235,6 @@ audioRenderer.getStreamInfo().then((streamInfo) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -4257,7 +4257,6 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses an async
audioRenderer.getAudioStreamId((err, streamid) => {
console.info(`Renderer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -4282,7 +4281,6 @@ audioRenderer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -4309,7 +4307,6 @@ audioRenderer.start((err) => {
console.info('Renderer start success.');
}
});
-
```
### start8+
@@ -4334,7 +4331,6 @@ audioRenderer.start().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### pause8+
@@ -4361,7 +4357,6 @@ audioRenderer.pause((err) => {
console.info('Renderer paused.');
}
});
-
```
### pause8+
@@ -4386,7 +4381,6 @@ audioRenderer.pause().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### drain8+
@@ -4413,7 +4407,6 @@ audioRenderer.drain((err) => {
console.info('Renderer drained.');
}
});
-
```
### drain8+
@@ -4438,7 +4431,6 @@ audioRenderer.drain().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### stop8+
@@ -4465,7 +4457,6 @@ audioRenderer.stop((err) => {
console.info('Renderer stopped.');
}
});
-
```
### stop8+
@@ -4490,7 +4481,6 @@ audioRenderer.stop().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### release8+
@@ -4517,7 +4507,6 @@ audioRenderer.release((err) => {
console.info('Renderer released.');
}
});
-
```
### release8+
@@ -4542,7 +4531,6 @@ audioRenderer.release().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### write8+
@@ -4577,17 +4565,26 @@ async function getCacheDir(){
path = await context.getCacheDir();
}
let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
-let ss = fileio.createStreamSync(filePath, 'r');
+let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
+let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize);
-ss.readSync(buf);
-audioRenderer.write(buf, (err, writtenbytes) => {
- if (writtenbytes < 0) {
- console.error('write failed.');
- } else {
- console.info(`Actual written bytes: ${writtenbytes}`);
- }
-});
-
+let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
+ }
+ let readsize = await fs.read(file.fd, buf, options)
+ let writeSize = await new Promise((resolve,reject)=>{
+ this.audioRenderer.write(buf,(err,writeSize)=>{
+ if(err){
+ reject(err)
+ }else{
+ resolve(writeSize)
+ }
+ })
+ })
+}
```
### write8+
@@ -4621,19 +4618,22 @@ async function getCacheDir(){
path = await context.getCacheDir();
}
let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
-let ss = fileio.createStreamSync(filePath, 'r');
+let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
+let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize);
-ss.readSync(buf);
-audioRenderer.write(buf).then((writtenbytes) => {
- if (writtenbytes < 0) {
- console.error('write failed.');
- } else {
- console.info(`Actual written bytes: ${writtenbytes}`);
- }
-}).catch((err) => {
- console.error(`ERROR: ${err}`);
-});
-
+let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
+ }
+ let readsize = await fs.read(file.fd, buf, options)
+ try{
+ let writeSize = await this.audioRenderer.write(buf);
+ } catch(err) {
+ console.error(`audioRenderer.write err: ${err}`);
+ }
+}
```
### getAudioTime8+
@@ -4656,7 +4656,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioRenderer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -4681,7 +4680,6 @@ audioRenderer.getAudioTime().then((timestamp) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getBufferSize8+
@@ -4706,7 +4704,6 @@ let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
console.error('getBufferSize error');
}
});
-
```
### getBufferSize8+
@@ -4733,7 +4730,6 @@ audioRenderer.getBufferSize().then((data) => {
}).catch((err) => {
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
});
-
```
### setRenderRate8+
@@ -4761,7 +4757,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) =>
console.info('Callback invoked to indicate a successful render rate setting.');
}
});
-
```
### setRenderRate8+
@@ -4792,7 +4787,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(()
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getRenderRate8+
@@ -4815,7 +4809,6 @@ Obtains the current render rate. This API uses an asynchronous callback to retur
audioRenderer.getRenderRate((err, renderrate) => {
console.info(`getRenderRate: ${renderrate}`);
});
-
```
### getRenderRate8+
@@ -4840,9 +4833,7 @@ audioRenderer.getRenderRate().then((renderRate) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode): Promise<void>
@@ -4872,9 +4863,7 @@ audioRenderer.setInterruptMode(mode).then(data=>{
}).catch((err) => {
console.error(`setInterruptMode Fail: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode, callback: AsyncCallback\): void
@@ -4900,7 +4889,6 @@ audioRenderer.setInterruptMode(mode, (err, data)=>{
}
console.info('setInterruptMode Success!');
});
-
```
### setVolume9+
@@ -4931,9 +4919,7 @@ audioRenderer.setVolume(0.5).then(data=>{
}).catch((err) => {
console.error(`setVolume Fail: ${err}`);
});
-
```
-
### setVolume9+
setVolume(volume: number, callback: AsyncCallback\): void
@@ -4958,7 +4944,6 @@ audioRenderer.setVolume(0.5, (err, data)=>{
}
console.info('setVolume Success!');
});
-
```
### on('audioInterrupt')9+
@@ -5038,7 +5023,6 @@ async function onAudioInterrupt(){
}
});
}
-
```
### on('markReach')8+
@@ -5065,7 +5049,6 @@ audioRenderer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
@@ -5087,7 +5070,6 @@ Unsubscribes from mark reached events.
```js
audioRenderer.off('markReach');
-
```
### on('periodReach') 8+
@@ -5114,7 +5096,6 @@ audioRenderer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach') 8+
@@ -5135,10 +5116,9 @@ Unsubscribes from period reached events.
```js
audioRenderer.off('periodReach')
-
```
-### on('stateChange')8+
+### on('stateChange') 8+
on(type: 'stateChange', callback: Callback): void
@@ -5164,7 +5144,6 @@ audioRenderer.on('stateChange', (state) => {
console.info('audio renderer state is: STATE_RUNNING');
}
});
-
```
## AudioCapturer8+
@@ -5183,7 +5162,6 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
```js
let state = audioCapturer.state;
-
```
### getCapturerInfo8+
@@ -5212,7 +5190,6 @@ audioCapturer.getCapturerInfo((err, capturerInfo) => {
console.info(`Capturer flags: ${capturerInfo.capturerFlags}`);
}
});
-
```
@@ -5245,7 +5222,6 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`);
});
-
```
### getStreamInfo8+
@@ -5276,7 +5252,6 @@ audioCapturer.getStreamInfo((err, streamInfo) => {
console.info(`Capturer encoding type: ${streamInfo.encodingType}`);
}
});
-
```
### getStreamInfo8+
@@ -5305,7 +5280,6 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`getStreamInfo :ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -5328,7 +5302,6 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses an async
audioCapturer.getAudioStreamId((err, streamid) => {
console.info(`audioCapturer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -5353,7 +5326,6 @@ audioCapturer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -5380,7 +5352,6 @@ audioCapturer.start((err) => {
console.info('Capturer start success.');
}
});
-
```
@@ -5412,7 +5383,6 @@ audioCapturer.start().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`);
});
-
```
### stop8+
@@ -5439,7 +5409,6 @@ audioCapturer.stop((err) => {
console.info('Capturer stopped.');
}
});
-
```
@@ -5469,7 +5438,6 @@ audioCapturer.stop().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### release8+
@@ -5496,7 +5464,6 @@ audioCapturer.release((err) => {
console.info('capturer released.');
}
});
-
```
@@ -5526,7 +5493,6 @@ audioCapturer.release().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### read8+
@@ -5560,7 +5526,6 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => {
console.info('Success in reading the buffer data');
}
});
-
```
### read8+
@@ -5600,7 +5565,6 @@ audioCapturer.read(bufferSize, true).then((buffer) => {
}).catch((err) => {
console.info(`ERROR : ${err}`);
});
-
```
### getAudioTime8+
@@ -5623,7 +5587,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioCapturer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -5648,7 +5611,6 @@ audioCapturer.getAudioTime().then((audioTime) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
});
-
```
### getBufferSize8+
@@ -5678,7 +5640,6 @@ audioCapturer.getBufferSize((err, bufferSize) => {
});
}
});
-
```
### getBufferSize8+
@@ -5705,7 +5666,6 @@ audioCapturer.getBufferSize().then((data) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`);
});
-
```
### on('markReach')8+
@@ -5732,7 +5692,6 @@ audioCapturer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('markReach')8+
@@ -5753,7 +5712,6 @@ Unsubscribes from mark reached events.
```js
audioCapturer.off('markReach');
-
```
### on('periodReach')8+
@@ -5780,7 +5738,6 @@ audioCapturer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach')8+
@@ -5801,10 +5758,9 @@ Unsubscribes from period reached events.
```js
audioCapturer.off('periodReach')
-
```
-### on('stateChange')8+
+### on('stateChange') 8+
on(type: 'stateChange', callback: Callback): void
@@ -5830,7 +5786,6 @@ audioCapturer.on('stateChange', (state) => {
console.info('audio capturer state is: STATE_RUNNING');
}
});
-
```
## ToneType9+
@@ -5905,7 +5860,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => {
console.info('callback call load success');
}
});
-
```
### load9+
@@ -5938,7 +5892,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => {
}).catch(() => {
console.error('promise call load fail');
});
-
```
### start9+
@@ -5968,7 +5921,6 @@ tonePlayer.start((err) => {
console.info('callback call start success');
}
});
-
```
### start9+
@@ -5995,7 +5947,6 @@ tonePlayer.start().then(() => {
}).catch(() => {
console.error('promise call start fail');
});
-
```
### stop9+
@@ -6025,7 +5976,6 @@ tonePlayer.stop((err) => {
console.error('callback call stop success ');
}
});
-
```
### stop9+
@@ -6052,7 +6002,6 @@ tonePlayer.stop().then(() => {
}).catch(() => {
console.error('promise call stop fail');
});
-
```
### release9+
@@ -6082,7 +6031,6 @@ tonePlayer.release((err) => {
console.info('callback call release success ');
}
});
-
```
### release9+
@@ -6109,7 +6057,6 @@ tonePlayer.release().then(() => {
}).catch(() => {
console.error('promise call release fail');
});
-
```
## ActiveDeviceType(deprecated)