diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md
index 024f89dd62face1472b5cc5dd6cc0f95e5177cc1..a64150a7611463ead1a36d0feab09f064a826a21 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-audio.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md
@@ -24,7 +24,7 @@ import audio from '@ohos.multimedia.audio';
| --------------------------------------- | ----------| ---- | ---- | ------------------ |
| LOCAL_NETWORK_ID9+ | string | 是 | 否 | 本地设备网络id。
此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Audio.Device |
| DEFAULT_VOLUME_GROUP_ID9+ | number | 是 | 否 | 默认音量组id。
**系统能力:** SystemCapability.Multimedia.Audio.Volume |
-| DEFAULT_INTERRUPT_GROUP_ID9+ | number | 是 | 否 | 默认音频中断组id。
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt |
+| DEFAULT_INTERRUPT_GROUP_ID9+ | number | 是 | 否 | 默认音频中断组id。
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt |
**示例:**
@@ -73,7 +73,10 @@ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\
**示例:**
```js
+import featureAbility from '@ohos.ability.featureAbility';
+import fileio from '@ohos.fileio';
import audio from '@ohos.multimedia.audio';
let audioStreamInfo = {
@@ -321,14 +326,19 @@ createTonePlayer(options: AudioRendererInfo): Promise<TonePlayer>
```js
import audio from '@ohos.multimedia.audio';
-async function createTonePlayer(){
+let tonePlayer;
+async function createTonePlayerBefore(){
let audioRendererInfo = {
- "contentType": audio.ContentType.CONTENT_TYPE_MUSIC,
- "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA,
- "rendererFlags": 0
+ contentType : audio.ContentType.CONTENT_TYPE_MUSIC,
+ streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA,
+ rendererFlags : 0
}
- let tonePlayer = await audio.createTonePlayer(audioRendererInfo);
+ createTonePlayer();
+}
+async function createTonePlayer(){
+ tonePlayer = await audio.createTonePlayer(audioRendererInfo);
}
+
```
## AudioVolumeType
@@ -337,7 +347,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------------- | ------ | ---------- |
| VOICE_CALL8+ | 0 | 语音电话。 |
| RINGTONE | 2 | 铃声。 |
@@ -353,7 +363,7 @@ async function createTonePlayer(){
**系统接口:** 该接口为系统接口
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------------- | ------ | ---------- |
| INTERRUPT_REQUEST_GRANT | 0 | 请求音频中断成功。 |
| INTERRUPT_REQUEST_REJECT | 1 | 请求音频中断失败,可能具有较高优先级类型。 |
@@ -364,7 +374,7 @@ async function createTonePlayer(){
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------------- | ------ | ---------- |
| SHARE_MODE | 0 | 共享焦点模式。 |
| INDEPENDENT_MODE | 1 | 独立焦点模式。 |
@@ -375,7 +385,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ------------------------------- | ------ | ------------------------------------------------- |
| NONE_DEVICES_FLAG9+ | 0 | 无
此接口为系统接口。 |
| OUTPUT_DEVICES_FLAG | 1 | 输出设备。 |
@@ -391,7 +401,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ------------- | ------ | -------------- |
| INPUT_DEVICE | 1 | 输入设备角色。 |
| OUTPUT_DEVICE | 2 | 输出设备角色。 |
@@ -402,7 +412,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------| ------ | --------------------------------------------------------- |
| INVALID | 0 | 无效设备。 |
| EARPIECE | 1 | 听筒。 |
@@ -421,7 +431,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ------------- | ------ | -------------|
| SPEAKER | 2 | 扬声器。 |
@@ -431,7 +441,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ------------------- | ------ | ---------- |
| RINGER_MODE_SILENT | 0 | 静音模式。 |
| RINGER_MODE_VIBRATE | 1 | 震动模式。 |
@@ -443,7 +453,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------------------- | ------ | -------------------------- |
| SAMPLE_FORMAT_INVALID | -1 | 无效格式。 |
| SAMPLE_FORMAT_U8 | 0 | 无符号8位整数。 |
@@ -474,7 +484,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| --------- | -------- | -------- |
| CHANNEL_1 | 0x1 << 0 | 单声道。 |
| CHANNEL_2 | 0x1 << 1 | 双声道。 |
@@ -485,7 +495,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ----------------- | ------ | --------------- |
| SAMPLE_RATE_8000 | 8000 | 采样率为8000。 |
| SAMPLE_RATE_11025 | 11025 | 采样率为11025。 |
@@ -505,7 +515,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| --------------------- | ------ | --------- |
| ENCODING_TYPE_INVALID | -1 | 无效。 |
| ENCODING_TYPE_RAW | 0 | PCM编码。 |
@@ -516,7 +526,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------------------- | ------ | ---------- |
| CONTENT_TYPE_UNKNOWN | 0 | 未知类型。 |
| CONTENT_TYPE_SPEECH | 1 | 语音。 |
@@ -531,7 +541,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ------------------------------------------| ------ | ---------- |
| STREAM_USAGE_UNKNOWN | 0 | 未知类型。 |
| STREAM_USAGE_MEDIA | 1 | 音频。 |
@@ -547,7 +557,7 @@ async function createTonePlayer(){
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------------------- | ------ | ------------------------- |
| INTERRUPT_REQUEST_TYPE_DEFAULT | 0 | 默认类型,可中断音频请求。 |
@@ -557,7 +567,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| -------------- | ------ | ---------------- |
| STATE_INVALID | -1 | 无效状态。 |
| STATE_NEW | 0 | 创建新实例状态。 |
@@ -573,7 +583,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ------------------ | ------ | ---------- |
| RENDER_RATE_NORMAL | 0 | 正常速度。 |
| RENDER_RATE_DOUBLE | 1 | 2倍速。 |
@@ -585,7 +595,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| -------------------- | ------ | ---------------------- |
| INTERRUPT_TYPE_BEGIN | 1 | 音频播放中断事件开始。 |
| INTERRUPT_TYPE_END | 2 | 音频播放中断事件结束。 |
@@ -596,7 +606,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| --------------- | ------ | ------------------------------------ |
| INTERRUPT_FORCE | 0 | 由系统进行操作,强制打断音频播放。 |
| INTERRUPT_SHARE | 1 | 由应用进行操作,可以选择打断或忽略。 |
@@ -607,7 +617,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ---------------------------------- | ------ | -------------------------------------------- |
| INTERRUPT_HINT_NONE8+ | 0 | 无提示。 |
| INTERRUPT_HINT_RESUME | 1 | 提示音频恢复。 |
@@ -635,7 +645,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 类型 | 必填 | 说明 |
+| 名称 | 类型 | 必填 | 说明 |
| ------------- | --------------------------- | ---- | ---------------- |
| content | [ContentType](#contenttype) | 是 | 媒体类型。 |
| usage | [StreamUsage](#streamusage) | 是 | 音频流使用类型。 |
@@ -660,7 +670,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
-| 名称 | 类型 | 必填 | 说明 |
+| 名称 | 类型 | 必填 | 说明 |
| ------------ | ---------------------------------------- | ---- | ---------------- |
| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | 表示音频流信息。 |
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示渲染器信息。 |
@@ -671,7 +681,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
-| 名称 | 类型 | 必填 | 说明 |
+| 名称 | 类型 |必填 | 说明 |
| --------- | ------------------------------------------ | ---- | ------------------------------------ |
| eventType | [InterruptType](#interrupttype) | 是 | 中断事件类型,开始或是结束。 |
| forceType | [InterruptForceType](#interruptforcetype9) | 是 | 操作是由系统执行或是由应用程序执行。 |
@@ -685,7 +695,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume
-| 名称 | 类型 | 必填 | 说明 |
+| 名称 | 类型 | 必填 | 说明 |
| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 |
| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 |
@@ -700,7 +710,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
| 名称 | 类型 | 必填 | 说明 |
-| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
+| ---------- | ----------------------------------- | ---- | ---- | -------------------------------------------------------- |
| mute | boolean | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 |
## ConnectType9+
@@ -711,7 +721,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| :------------------------------ | :----- | :--------------------- |
| CONNECT_TYPE_LOCAL | 1 | 本地设备。 |
| CONNECT_TYPE_DISTRIBUTED | 2 | 分布式设备。 |
@@ -737,7 +747,7 @@ async function createTonePlayer(){
| networkId9+ | string | 是 | 否 | 组网络id。 |
| groupId9+ | number | 是 | 否 | 组设备组id。 |
| mappingId9+ | number | 是 | 否 | 组映射id。 |
-| groupName9+ | number | 是 | 否 | 组名。 |
+| groupName9+ | string | 是 | 否 | 组名。 |
| type9+ | [ConnectType](#connecttype9)| 是 | 否 | 连接设备类型。 |
## DeviceChangeAction
@@ -757,7 +767,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| :--------- | :----- | :------------- |
| CONNECT | 0 | 设备连接。 |
| DISCONNECT | 1 | 断开设备连接。 |
@@ -790,7 +800,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| :------------------------------------------- | :----- | :--------------------- |
| SOURCE_TYPE_INVALID | -1 | 无效的音频源。 |
| SOURCE_TYPE_MIC | 0 | Mic音频源。 |
@@ -803,7 +813,7 @@ async function createTonePlayer(){
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| :--------------------- | :----- | :-------------------------------------------- |
| AUDIO_SCENE_DEFAULT | 0 | 默认音频场景。 |
| AUDIO_SCENE_RINGING | 1 | 响铃模式。
此接口为系统接口。 |
@@ -958,7 +968,6 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback\): void
**示例:**
```js
-let audioManager = audio.getAudioManager();
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
if (err) {
console.error(`Failed to set the audio scene mode. ${err}`);
@@ -993,7 +1002,6 @@ setAudioScene\(scene: AudioScene\): Promise
**示例:**
```js
-let audioManager = audio.getAudioManager();
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
console.info('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => {
@@ -1018,7 +1026,6 @@ getAudioScene\(callback: AsyncCallback\): void
**示例:**
```js
-let audioManager = audio.getAudioManager();
audioManager.getAudioScene((err, value) => {
if (err) {
console.error(`Failed to obtain the audio scene mode. ${err}`);
@@ -1045,7 +1052,6 @@ getAudioScene\(\): Promise
**示例:**
```js
-let audioManager = audio.getAudioManager();
audioManager.getAudioScene().then((value) => {
console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`);
}).catch ((err) => {
@@ -1171,7 +1177,7 @@ getVolumeGroupManager(groupId: number, callback: AsyncCallback
```js
let groupid = audio.DEFAULT_VOLUME_GROUP_ID;
-let audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupid);
-console.info('Callback invoked to indicate that the volume group infos list is obtained.');
+let audioVolumeGroupManager;
+getVolumeGroupManager();
+async function getVolumeGroupManager(){
+ audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupid);
+ console.info('Callback invoked to indicate that the volume group infos list is obtained.');
+}
+
```
### on('volumeChange')9+
@@ -1236,7 +1247,7 @@ on(type: 'volumeChange', callback: Callback\): void
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
-| 6800101 | if input parameter value error. |
+| 6800101 | if input parameter value error |
**示例:**
@@ -1750,7 +1761,7 @@ on(type: 'ringerModeChange', callback: Callback\): void
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
-| 6800101 | if input parameter value error. |
+| 6800101 | if input parameter value error |
**示例:**
@@ -1889,7 +1900,7 @@ on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
-| 6800101 | if input parameter value error. |
+| 6800101 | if input parameter value error |
**示例:**
@@ -2108,7 +2119,7 @@ on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArr
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
-| 6800101 | if input parameter value error. |
+| 6800101 | if input parameter value error |
**示例:**
@@ -2157,7 +2168,7 @@ off(type: "audioRendererChange"): void
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
-| 6800101 | if input parameter value error. |
+| 6800101 | if input parameter value error |
**示例:**
@@ -2181,6 +2192,14 @@ on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArr
| type | string | 是 | 事件类型,支持的事件`'audioCapturerChange'`:当音频采集器发生更改时触发。 |
| callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | 是 | 回调函数。 |
+**错误码:**
+
+以下错误码的详细介绍请参见[音频错误码](../errorcodes/errorcode-audio.md)。
+
+| 错误码ID | 错误信息 |
+| ------- | --------------------------------------------|
+| 6800101 | if input parameter value error |
+
**示例:**
```js
@@ -2221,6 +2240,14 @@ off(type: "audioCapturerChange"): void;
| -------- | -------- | --- | ------------------------------------------------------------- |
| type | string |是 | 事件类型,支持的事件`'audioCapturerChange'`:音频采集器更改事件。 |
+**错误码:**
+
+以下错误码的详细介绍请参见[音频错误码](../errorcodes/errorcode-audio.md)。
+
+| 错误码ID | 错误信息 |
+| ------- | --------------------------------------------|
+| 6800101 | if input parameter value error |
+
**示例:**
```js
@@ -2365,7 +2392,7 @@ on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
-| 6800101 | if input parameter value error. |
+| 6800101 | if input parameter value error |
**示例:**
@@ -2429,10 +2456,10 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCall
**示例:**
```js
let inputAudioDeviceDescriptor = [{
- "deviceRole":audio.DeviceRole.INPUT_DEVICE,
- "networkId":audio.LOCAL_NETWORK_ID,
- "interruptGroupId":1,
- "volumeGroupId":1 }];
+ deviceRole : audio.DeviceRole.INPUT_DEVICE,
+ networkId : audio.LOCAL_NETWORK_ID,
+ interruptGroupId : 1,
+ volumeGroupId : 1 }];
async function selectInputDevice(){
audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => {
@@ -2470,10 +2497,10 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void>
```js
let inputAudioDeviceDescriptor =[{
- "deviceRole":audio.DeviceRole.INPUT_DEVICE,
- "networkId":audio.LOCAL_NETWORK_ID,
- "interruptGroupId":1,
- "volumeGroupId":1 }];
+ deviceRole : audio.DeviceRole.INPUT_DEVICE,
+ networkId : audio.LOCAL_NETWORK_ID,
+ interruptGroupId : 1,
+ volumeGroupId : 1 }];
async function getRoutingManager(){
audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => {
@@ -2616,10 +2643,10 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCa
**示例:**
```js
let outputAudioDeviceDescriptor = [{
- "deviceRole":audio.DeviceRole.OUTPUT_DEVICE,
- "networkId":audio.LOCAL_NETWORK_ID,
- "interruptGroupId":1,
- "volumeGroupId":1 }];
+ deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
+ networkId : audio.LOCAL_NETWORK_ID,
+ interruptGroupId : 1,
+ volumeGroupId : 1 }];
async function selectOutputDevice(){
audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => {
if (err) {
@@ -2656,10 +2683,10 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void&
```js
let outputAudioDeviceDescriptor =[{
- "deviceRole":audio.DeviceRole.OUTPUT_DEVICE,
- "networkId":audio.LOCAL_NETWORK_ID,
- "interruptGroupId":1,
- "volumeGroupId":1 }];
+ deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
+ networkId : audio.LOCAL_NETWORK_ID,
+ interruptGroupId : 1,
+ volumeGroupId : 1 }];
async function selectOutputDevice(){
audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => {
@@ -2691,17 +2718,17 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi
**示例:**
```js
let outputAudioRendererFilter = {
- "uid":20010041,
- "rendererInfo": {
- "contentType":audio.ContentType.CONTENT_TYPE_MUSIC,
- "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA,
- "rendererFlags":0 },
- "rendererId":0 };
+ uid : 20010041,
+ rendererInfo : {
+ contentType : audio.ContentType.CONTENT_TYPE_MUSIC,
+ streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA,
+ rendererFlags : 0 },
+ rendererId : 0 };
let outputAudioDeviceDescriptor = [{
- "deviceRole":audio.DeviceRole.OUTPUT_DEVICE,
- "networkId":audio.LOCAL_NETWORK_ID,
- "interruptGroupId":1,
- "volumeGroupId":1 }];
+ deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
+ networkId : audio.LOCAL_NETWORK_ID,
+ interruptGroupId : 1,
+ volumeGroupId : 1 }];
async function selectOutputDeviceByFilter(){
audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => {
@@ -2740,17 +2767,17 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi
```js
let outputAudioRendererFilter = {
- "uid":20010041,
- "rendererInfo": {
- "contentType":audio.ContentType.CONTENT_TYPE_MUSIC,
- "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA,
- "rendererFlags":0 },
- "rendererId":0 };
+ uid : 20010041,
+ rendererInfo : {
+ contentType : audio.ContentType.CONTENT_TYPE_MUSIC,
+ streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA,
+ rendererFlags : 0 },
+ rendererId : 0 };
let outputAudioDeviceDescriptor = [{
- "deviceRole":audio.DeviceRole.OUTPUT_DEVICE,
- "networkId":audio.LOCAL_NETWORK_ID,
- "interruptGroupId":1,
- "volumeGroupId":1 }];
+ deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
+ networkId : audio.LOCAL_NETWORK_ID,
+ interruptGroupId : 1,
+ volumeGroupId : 1 }];
async function selectOutputDeviceByFilter(){
audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => {
@@ -2783,11 +2810,8 @@ async function selectOutputDeviceByFilter(){
**示例:**
```js
-import audio from '@ohos.multimedia.audio';
-
let audioStreamManager;
let resultFlag = false;
-let audioManager = audio.getAudioManager();
audioManager.getStreamManager((err, data) => {
if (err) {
@@ -2843,7 +2867,7 @@ audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) =>
| -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- |
| streamId | number | 是 | 否 | 音频流唯一id。 |
| clientUid | number | 是 | 否 | 音频采集器客户端应用程序的Uid。
此接口为系统接口。 |
-| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | 是 | 否 | 音频采集器信息。 |
+| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | 是 | 否 | 音频采集器信息。 |
| capturerState | [AudioState](#audiostate) | 是 | 否 | 音频状态。
此接口为系统接口。|
**示例:**
@@ -2944,7 +2968,7 @@ promise.then(function (value) {
**系统接口:** 该接口为系统接口
-| 名称 | 类型 | 必填 | 说明 |
+| 名称 | 类型 | 必填 | 说明 |
| -------------| ---------------------------------------- | ---- | -------------- |
| uid | number | 是 | 表示应用ID。
**系统能力:** SystemCapability.Multimedia.Audio.Core|
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 否 | 表示渲染器信息。
**系统能力:** SystemCapability.Multimedia.Audio.Renderer|
@@ -3804,56 +3828,60 @@ on(type: 'audioInterrupt', callback: Callback\): void
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
-| 6800101 | if input parameter value error. |
+| 6800101 | if input parameter value error |
**示例:**
```js
let isPlay;
let started;
-audioRenderer.on('audioInterrupt', async(interruptEvent) => {
- if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
- switch (interruptEvent.hintType) {
- case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
- console.info('Force paused. Stop writing');
- isPlay = false;
- break;
- case audio.InterruptHint.INTERRUPT_HINT_STOP:
- 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.info('Resume force paused renderer or ignore');
- await audioRenderer.start().then(async function () {
- console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
- started = true;
- }).catch((err) => {
- console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`);
- started = false;
- });
- if (started) {
- isPlay = true;
- console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`);
- } else {
- console.error('AudioInterruptMusic Renderer start failed');
- }
- break;
- case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
- console.info('Choose to pause or ignore');
- if (isPlay == true) {
- isPlay == false;
- console.info('AudioInterruptMusic: Media PAUSE : TRUE');
- } else {
- isPlay = true;
- console.info('AudioInterruptMusic: Media PLAY : TRUE');
- }
- break;
- }
- }
-});
+onAudioInterrupt();
+
+async function onAudioInterrupt(){
+ audioRenderer.on('audioInterrupt', async(interruptEvent) => {
+ if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
+ switch (interruptEvent.hintType) {
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ console.info('Force paused. Stop writing');
+ isPlay = false;
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_STOP:
+ 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.info('Resume force paused renderer or ignore');
+ await audioRenderer.start().then(async function () {
+ console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
+ started = true;
+ }).catch((err) => {
+ console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`);
+ started = false;
+ });
+ if (started) {
+ isPlay = true;
+ console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`);
+ } else {
+ console.error('AudioInterruptMusic Renderer start failed');
+ }
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ console.info('Choose to pause or ignore');
+ if (isPlay == true) {
+ isPlay == false;
+ console.info('AudioInterruptMusic: Media PAUSE : TRUE');
+ } else {
+ isPlay = true;
+ console.info('AudioInterruptMusic: Media PLAY : TRUE');
+ }
+ break;
+ }
+ }
+ });
+}
```
### on('markReach')8+
@@ -4627,7 +4655,7 @@ audioCapturer.on('stateChange', (state) => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Tone
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| :------------------------------------------------ | :----- | :----------------------------|
| TONE_TYPE_DIAL_0 | 0 | 键0的DTMF音。 |
| TONE_TYPE_DIAL_1 | 1 | 键1的DTMF音。 |
@@ -4669,6 +4697,8 @@ load(type: ToneType, callback: AsyncCallback<void>): void
加载DTMF音调配置。使用callback方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**参数:**
@@ -4697,6 +4727,8 @@ load(type: ToneType): Promise<void>
加载DTMF音调配置。使用Promise方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**参数:**
@@ -4727,6 +4759,8 @@ start(callback: AsyncCallback<void>): void
启动DTMF音调播放。使用callback方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**参数:**
@@ -4754,6 +4788,8 @@ start(): Promise<void>
启动DTMF音调播放。使用Promise方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**返回值:**
@@ -4778,6 +4814,8 @@ stop(callback: AsyncCallback<void>): void
停止当前正在播放的音调。使用callback方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**参数:**
@@ -4805,6 +4843,8 @@ stop(): Promise<void>
停止当前正在播放的音调。使用Promise方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**返回值:**
@@ -4829,6 +4869,8 @@ release(callback: AsyncCallback<void>): void
释放与此TonePlayer对象关联的资源。使用callback方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**参数:**
@@ -4856,6 +4898,8 @@ release(): Promise<void>
释放与此TonePlayer对象关联的资源。使用Promise方式异步返回结果。
+**系统接口:** 该接口为系统接口
+
**系统能力:** SystemCapability.Multimedia.Audio.Tone
**返回值:**
@@ -4883,7 +4927,7 @@ tonePlayer.release().then(() => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| ------------- | ------ | ---------------------------------------------------- |
| SPEAKER | 2 | 扬声器。 |
| BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 |
@@ -4897,7 +4941,7 @@ tonePlayer.release().then(() => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
-| 名称 | 默认值 | 描述 |
+| 名称 | 值 | 说明 |
| -------------- | ------ | ------------------ |
| TYPE_ACTIVATED | 0 | 表示触发焦点事件。 |
| TYPE_INTERRUPT | 1 | 表示音频打断事件。 |
@@ -4912,10 +4956,10 @@ tonePlayer.release().then(() => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
| 名称 | 类型 | 必填 | 说明 |
-| --------------- | --------------------------- | ---- | ------------------------------------------------------------ |
-| streamUsage | [StreamUsage](#streamusage) | 是 | 音频流使用类型。 |
-| contentType | [ContentType](#contenttype) | 是 | 音频打断媒体类型。 |
-| pauseWhenDucked | boolean | 是 | 音频打断时是否可以暂停音频播放(true表示音频播放可以在音频打断期间暂停,false表示相反)。 |
+| --------------- | --------------------------- | ----| ------------------------------------------------------------ |
+| streamUsage | [StreamUsage](#streamusage) | 是 | 音频流使用类型。 |
+| contentType | [ContentType](#contenttype) | 是 | 音频打断媒体类型。 |
+| pauseWhenDucked | boolean | 是 | 音频打断时是否可以暂停音频播放(true表示音频播放可以在音频打断期间暂停,false表示相反)。 |
## InterruptAction(deprecated)
@@ -4930,7 +4974,7 @@ tonePlayer.release().then(() => {
| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| actionType | [InterruptActionType](#interruptactiontype) | 是 | 事件返回类型。TYPE_ACTIVATED为焦点触发事件,TYPE_INTERRUPT为音频打断事件。 |
| type | [InterruptType](#interrupttype) | 否 | 打断事件类型。 |
-| hint | [InterruptHint](#interrupthint) | 否 | 打断事件提示。 |
+| hint | [InterruptHint](#interrupthint) | 否 | 打断事件提示。 |
| activated | boolean | 否 | 获得/释放焦点。true表示焦点获取/释放成功,false表示焦点获得/释放失败。 |
### setVolume(deprecated)
diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md b/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md
index 96e986813706ea59bcb629891e821f561fe2a72a..0746dc22f236b5c62a392bbde82dc0db4c318203 100644
--- a/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md
+++ b/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md
@@ -4,7 +4,7 @@
**错误信息**
-invalid parameter.
+Invalid parameter.
**错误描述**
@@ -22,7 +22,7 @@ invalid parameter.
**错误信息**
-allocate memory failed.
+Memory allocation failure.
**错误描述**
@@ -42,7 +42,7 @@ allocate memory failed.
**错误信息**
-Operation not permit at current state.
+Unsupported state.
**错误描述**
@@ -61,7 +61,7 @@ Operation not permit at current state.
**错误信息**
-unsupported operation.
+Unsupported parameter value.
**错误描述**
@@ -80,7 +80,7 @@ unsupported operation.
**错误信息**
-time out.
+Processing timeout.
**错误描述**
@@ -98,7 +98,7 @@ time out.
**错误信息**
-stream number limited.
+Too many audio streams.
**错误描述**
@@ -116,7 +116,7 @@ stream number limited.
**错误信息**
-system error.
+System error.
**错误描述**