diff --git a/zh-cn/application-dev/media/audio-effect-management.md b/zh-cn/application-dev/media/audio-effect-management.md index 50660daabcdfa14832bcf79eb9c32ce0120d3124..22bda3a9e406d7c46318575f2eb14b44b4d266ed 100644 --- a/zh-cn/application-dev/media/audio-effect-management.md +++ b/zh-cn/application-dev/media/audio-effect-management.md @@ -89,12 +89,33 @@ }); ``` -## 静态音效管理 +## 音频场景全局音效查询 -主要包括XXX。 +主要包括全局音效查询相应ContentType和StreamUsage对应场景的音效模式。 +对于播放音频类的应用,开发者需要关注该应用的音频流使用什么音效模式并做出相应的操作,比如音乐App播放时,应选择音乐场景下的模式。在使用查询接口前,开发者需要使用getStreamManager()创建一个AudioStreamManager实例。 -### 获取XXX接口 +### 获取全局音效查询接口 -管理播放实例音效的接口XXX。 +1.创建AudioStreamManager实例。 +在使用AudioStreamManager的API前,需要使用getStreamManager()创建一个AudioStreamManager实例。 -### 查询当前XXX音效模式 + ```ts + import audio from '@ohos.multimedia.audio'; + let audioManager = audio.getAudioManager(); + let audioStreamManager = audioManager.getStreamManager(); + ``` + +2.管理播放实例音效的接口getAudioEffectInfoArray()查询音效模式。 + +### 查询当前ContentType和StreamUsage对应场景的音效模式 + + ```ts + audioStreamManager.getAudioEffectInfoArray(audio.ContentType.CONTENT_TYPE_MUSIC, audio.StreamUsage.STREAM_USAGE_MEDIA, async (err, AudioEffectInfoArray) => { + if (err) { + console.error(`Failed to get effect info array`); + return; + } else { + console.info(`getAudioEffectInfoArray: ${getAudioEffectInfoArray}`); + } + }); + ``` diff --git a/zh-cn/application-dev/media/audio-playback-stream-management.md b/zh-cn/application-dev/media/audio-playback-stream-management.md index f9e1707c8b4277a33d6d03a0389e4dac05cd453c..3932a7c4508d3965abee72bf7020cb1d378780d7 100644 --- a/zh-cn/application-dev/media/audio-playback-stream-management.md +++ b/zh-cn/application-dev/media/audio-playback-stream-management.md @@ -117,7 +117,3 @@ } ``` -# 音频场景音效查询 - -对于播放音频类的应用,开发者需要关注该应用的音频流使用什么音效模式并做出相应的操作,比如音乐App播放时,应选择音乐场景下的模式。参考[使用AudioStreamManager开发音效查询功能](../reference/apis/js-apis-audio.md#getaudioeffectinfoarray10) - 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 6d35c580c1728599e843c5f731c8f203c969ec04..41a48ba0e24039fd8f415c1a9b7741f1c6634b95 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -3400,18 +3400,7 @@ audioStreamManager.getAudioEffectInfoArray(audio.ContentType.CONTENT_TYPE_MUSIC, console.error(`getAudioEffectInfoArray :ERROR: ${err}`); return; } else { - if (AudioEffectInfoArray == null) { - console.error(`getAudioEffectInfoArray is null ptr.`); - return; - } - console.info(`The contentType of ${CONTENT_TYPE_MUSIC} and the streamUsage of ${STREAM_USAGE_MEDIA} 's effect mode are: `); - for (let i = 0; i < AudioEffectInfoArray.length; i++) { - for (const key in audio.AudioEffectMode) { - if (audio.AudioEffectMode[key] === AudioEffectInfoArray[i]) { - console.info(`${key}, `); - } - } - } + console.info(`The contentType of ${CONTENT_TYPE_MUSIC} and the streamUsage of ${STREAM_USAGE_MEDIA} 's effect mode are: ${AudioEffectInfoArray}`); } }); ``` @@ -3443,18 +3432,7 @@ getAudioEffectInfoArray(content: ContentType, usage: StreamUsage): Promise<Au async function getAudioEffectInfoArray(){ await audioStreamManager.getAudioEffectInfoArray().then( function (AudioEffectInfoArray) { console.info(`getAudioEffectInfoArray ######### Get Promise is called ##########`); - if (AudioEffectInfoArray == null) { - console.error(`getAudioEffectInfoArray is null ptr.`); - return; - } - console.info(`The contentType of ${CONTENT_TYPE_MUSIC} and the streamUsage of ${STREAM_USAGE_MEDIA} 's effect mode are: `); - for (let i = 0; i < AudioEffectInfoArray.length; i++) { - for (const key in audio.AudioEffectMode) { - if (audio.AudioEffectMode[key] === AudioEffectInfoArray[i]) { - console.info(`${key}, `); - } - } - } + console.info(`The contentType of ${CONTENT_TYPE_MUSIC} and the streamUsage of ${STREAM_USAGE_MEDIA} 's effect mode are: ${AudioEffectInfoArray}`); }).catch((err) => { console.error(`getAudioEffectInfoArray :ERROR: ${err}`); });