未验证 提交 9dca56c2 编写于 作者: O openharmony_ci 提交者: Gitee

!15516 翻译完成:14847+14624 update js_apis_audio.md (cherry-pick)

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