diff --git "a/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\346\222\255\346\224\276.md" "b/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\346\222\255\346\224\276.md" index a2d57bc60fd28c07d9d681e8cf6010365f2889a2..cdfdbb07237b22c4f5b5b800ce15d89ae7ba584e 100644 --- "a/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\346\222\255\346\224\276.md" +++ "b/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\346\222\255\346\224\276.md" @@ -1,60 +1,59 @@ -# 音频播放 - -- [导入模块](#zh-cn_topic_0000001103383404_s56d19203690d4782bfc74069abb6bd71) -- [权限](#zh-cn_topic_0000001103383404_section11257113618419) -- [方法](#zh-cn_topic_0000001103383404_section125675489541) -- [createAudioPlayer\(\)](#zh-cn_topic_0000001103383404_section582314017253) -- [附录](#zh-cn_topic_0000001103383404_section1933416317165) -- [AudioPlayer](#zh-cn_topic_0000001103383404_section5174142818365) - - [属性](#zh-cn_topic_0000001103383404_section4947115405) - - [play\(\)](#zh-cn_topic_0000001103383404_section964512672913) - - [pause\(\)](#zh-cn_topic_0000001103383404_section78173258296) - - [stop\(\)](#zh-cn_topic_0000001103383404_section122114334296) - - [seek\(number\)](#zh-cn_topic_0000001103383404_section1387113816298) - - [setVolume\(number\)](#zh-cn_topic_0000001103383404_section164235176552) - - [release\(\)](#zh-cn_topic_0000001103383404_section9224621145512) - - [事件](#zh-cn_topic_0000001103383404_section5453721192911) - - [play](#zh-cn_topic_0000001103383404_section87307411494) - - [pause](#zh-cn_topic_0000001103383404_section198217471590) - - [stop](#zh-cn_topic_0000001103383404_section437616531910) - - [dataLoad](#zh-cn_topic_0000001103383404_section982114219106) - - [timeUpdate](#zh-cn_topic_0000001103383404_section13687114181014) - - [volumeChange](#zh-cn_topic_0000001103383404_section139227715717) - - [finish](#zh-cn_topic_0000001103383404_section15181321181018) - - [error](#zh-cn_topic_0000001103383404_section5593132921016) -- [AudioState](#zh-cn_topic_0000001103383404_section5181155710523) - ->![](public_sys-resources/icon-note.gif) **说明:** ->由于权限问题,此部分功能在标准系统暂不可用,待更新。 - -## 导入模块 +# 音频播放 + +- [导入模块](#s56d19203690d4782bfc74069abb6bd71) +- [权限](#section11257113618419) +- [方法](#section125675489541) +- [createAudioPlayer\(\)](#section582314017253) +- [附录](#section1933416317165) +- [AudioPlayer](#section5174142818365) + - [属性](#section4947115405) + - [play\(\)](#section964512672913) + - [pause\(\)](#section78173258296) + - [stop\(\)](#section122114334296) + - [seek\(number\)](#section1387113816298) + - [setVolume\(number\)](#section164235176552) + - [reset\(\)7+](#section1473283011356) + - [release\(\)](#section9224621145512) + - [事件](#section5453721192911) + - [play](#section87307411494) + - [pause](#section198217471590) + - [stop](#section437616531910) + - [dataLoad](#section982114219106) + - [timeUpdate](#section13687114181014) + - [volumeChange](#section139227715717) + - [finish](#section15181321181018) + - [error](#section5593132921016) + +- [AudioState](#section5181155710523) + +## 导入模块 ``` import audio from '@ohos.multimedia.media'; ``` -## 权限 +## 权限 无 -## 方法 +## 方法 -## createAudioPlayer\(\) +## createAudioPlayer\(\) 创建音频播放的实例来控制音频的播放。 **返回值:** - -

类型

+ + - - - @@ -66,164 +65,201 @@ import audio from '@ohos.multimedia.media'; var audioplayer = audio.createAudioPlayer(); ``` -## 附录 +## 附录 -## AudioPlayer +## AudioPlayer 音频播放器。 -### 属性 +### 属性 - -

类型

说明

+

说明

AudioPlayer

+

AudioPlayer

返回AudioPlayer类实例,失败时返回null。

+

返回AudioPlayer类实例,失败时返回null。

名称

+ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

参数类型

+

参数类型

可读

+

可读

可写

+

可写

说明

+

说明

src

+

src

string

+

string

+

+

音频媒体URI。

+

音频媒体URI。

loop

+

loop

boolean

+

boolean

+

+

音频循环播放属性。

+

音频循环播放属性。

currentTime

+

currentTime

number

+

number

+

+

音频的当前播放阶段。

+

音频的当前播放阶段。

duration

+

duration

number

+

number

+

+

音频播放的时长。

+

音频播放的时长。

state

+

state

AudioState

+

AudioState

+

+

音频播放的状态。

+

音频播放的状态。

-### play\(\) +### play\(\) 开始播放音频资源。 **示例:** ``` -audioplayer.src = 'common/mydream.mp3'; +audioplayer.on('dataload', (err, action) => { + if (err) { + console.info('Error returned in the prepare() callback.'); + return; + } + console.info('Start to play the audio.'); + audioplayer.play(); +}; + audioplayer.on('play', (err, action) => { if (err) { - console.log(`err returned in play() callback`); + console.info('Error returned in the play() callback.'); return; } - console.log('start to play'); - audioplayer.pause(); + console.info('Succeeded in playing the audio.'); }; -audioplayer.play(); +audioplayer.src = 'common/mydream.mp3'; ``` -### pause\(\) +### pause\(\) 暂停播放音频资源。 **示例:** ``` -audioplayer.src = 'common/mydream.mp3'; +audioplayer.on('dataload', (err, action) => { + if (err) { + console.info('Error returned in the prepare() callback.'); + return; + } + console.info('Start to play the audio.'); + audioplayer.play(); +} +audioplayer.on('play', (err, action) => { + if (err) { + console.info('Error returned in the play() callback.'); + return; + } + console.info('Start to pause audio playback.'); + audioplayer.pause(); +}; audioplayer.on('pause', (err, action) => { if (err) { - console.log(`err returned in pause() callback`); + console.info('Error returned in the pause() callback.'); return; } - console.log('playback pause'); + console.info('Succeeded in pausing audio playback.'); }; -audioplayer.pause(); +audioplayer.src = 'common/mydream.mp3'; ``` -### stop\(\) +### stop\(\) 停止播放音频资源。 **示例:** ``` -audioplayer.src = 'common/mydream.mp3'; -audioplayer.on('stop',(err, action) => { +audioplayer.on('dataload', (err, action) => { if (err) { - console.log(`err returned in stop() callback`); + console.info('Error returned in the prepare() callback.'); return; } - console.log('playback stop'); + console.info('Start to play the audio.'); + audioplayer.play(); }; -audioplayer.stop(); +audioplayer.on('play', (err, action) => { + if (err) { + console.info('Error returned in the play() callback.'); + return; + } + console.info('Start to pause audio playback.'); + audioplayer.pause(); +}; +audioplayer.on('stop', (err, action) => { + if (err) { + console.info('Error returned in the stop() callback.'); + return; + } + console.info('Succeeded in stopping audio playback.'); +}; +audioplayer.src = 'common/mydream.mp3'; ``` -### seek\(number\) +### seek\(number\) 跳转到指定播放位置。 **参数:** - -

参数名

+ + - - - - - - - @@ -232,46 +268,58 @@ audioplayer.stop(); **示例:** ``` -audioplayer.src = 'common/mydream.mp3'; -audioplayer.on('timeupdate', (err, action) => { +audioplayer.on('dataload', (err, action) => { if (err) { - console.log(`err returned in seek() callback`); + console.info('Error returned in the prepare() callback.'); return; } + console.info('Start to play the audio.'); + audioplayer.play(); +}; +audioplayer.on('play', (err, action) => { + if (err) { + console.info('Error returned in the play() callback.'); + return; + } + console.info('Succeeded in playing the audio.') +}; +audioplayer.on('timeUpdate', (seekTime, action) => { + console.info('Seek time returned in the seek() callback: ' + seekTime); var newTime = audioplayer.currenTime; - if(newTime = 30000) { - console.info('Seek success, new time : ' + newTime); + if(newTime == 30000) { + console.info('Seek succeeded. New time: ' + newTime); } else { - console.info('Seek Failed'); + console.info('Seek failed.'); } }; +audioplayer.src = 'common/mydream.mp3'; audioplayer.seek(30000); ``` -### setVolume\(number\) +### setVolume\(number\) 设置音量。 **参数:** - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

timeMs

+

timeMs

number

+

number

+

想要跳转到的时间点。

+

想要跳转到的时间点。

参数名

+ + - - - - - - - @@ -280,18 +328,58 @@ audioplayer.seek(30000); **示例:** ``` -audioplayer.src = 'common/mydream.mp3'; +audioplayer.on('dataload', (err, action) => { + if (err) { + console.error('Error returned in the prepare() callback.'); + return; + } + console.info('Start to play the audio.'); + audioplayer.play(); +}; +audioplayer.on('play', (err, action) => { + if (err) { + console.error('Error returned in the play() callback.'); + return; + } + console.info('Succeeded in playing the audio.') +}; audioplayer.on('volumeChange', (err, action) => { if (err) { - console.log(`err returned in setVolume() callback`); + console.error('Error returned in the setVolume() callback.'); + return; + } + console.info('Playback volume changed.'); +}; +audioplayer.src = 'common/mydream.mp3'; +audioplayer.setVolume(0.5); +``` + +### reset\(\)7+ + +切换播放音频资源。 + +**示例:** + +``` +audioplayer.on('dataload', (err, action) => { + if (err) { + console.error('Error returned in the prepare() callback.'); return; } - console.log('playback volume change'); + console.info('Start to reset audio playback.'); + audioplayer.reset(); }; -audioplayer.setVolume(30); +audioplayer.on('reset', (err, action) => { + if (err) { + console.error('Error returned in the reset() callback.'); + return; + } + console.info('Reset succeeded.'); +}; +audioplayer.src = 'common/mydream.mp3'; ``` -### release\(\) +### release\(\) 释放音频资源。 @@ -301,83 +389,88 @@ audioplayer.setVolume(30); audioplay.release(); ``` -### 事件 +### 事件 -### play +### play 在调用play方法后的回调事件。 -### pause +### pause 在调用pause方法后的回调事件。 -### stop +### stop 在调用stop方法后的回调事件。 -### dataLoad +### dataLoad 在音频数据加载后的回调事件。 -### timeUpdate +### timeUpdate 在播放时间改变后的回调事件。 -### volumeChange +### volumeChange 在播放音量改变后的回调事件。 -### finish +### finish 在播放完成后的回调事件。 -### error +### error 在播放错误时的回调事件。 - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

vol

+

vol

number

+

number

+

想要设置的音量值。

+

想要设置的音量值(0-1)。

参数名

+ + - - - - -

参数名

类型

+

类型

说明

+

说明

callback

+

callback

ErrorCallback

+

ErrorCallback

错误事件的回调函数。

+

错误事件的回调函数。

-## AudioState +## AudioState 音频播放的状态机。 - -

名称

+ + - - + + + - - - - - diff --git "a/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\347\256\241\347\220\206.md" "b/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\347\256\241\347\220\206.md" index f032c9c90503c18986adfa6d102318579ccf4c40..d84cf90dfaeb99cec36facd83a0005c9cd3f39cf 100644 --- "a/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\347\256\241\347\220\206.md" +++ "b/zh-cn/application-dev/js-reference/\351\237\263\351\242\221\347\256\241\347\220\206.md" @@ -1,61 +1,78 @@ -# 音频管理 - -- [导入模块](#zh-cn_topic_0000001149807881_s56d19203690d4782bfc74069abb6bd71) -- [权限](#zh-cn_topic_0000001149807881_section11257113618419) -- [方法](#zh-cn_topic_0000001149807881_section1580114415416) -- [getAudioManager\(\)](#zh-cn_topic_0000001149807881_section84581011418) -- [枚举](#zh-cn_topic_0000001149807881_section115029181495) -- [AudioVolumeType](#zh-cn_topic_0000001149807881_section92261857172218) -- [DeviceFlag](#zh-cn_topic_0000001149807881_section11285183164210) -- [DeviceRole](#zh-cn_topic_0000001149807881_section380038142619) -- [DeviceType](#zh-cn_topic_0000001149807881_section11727420122710) -- [附录](#zh-cn_topic_0000001149807881_section1933416317165) -- [AudioManager](#zh-cn_topic_0000001149807881_section8265143814015) - - [setVolume\(AudioVolumeType, number, AsyncCallback\)](#zh-cn_topic_0000001149807881_section189141826104616) - - [setVolume\(AudioVolumeType, number\)](#zh-cn_topic_0000001149807881_section102021249114612) - - [getVolume\(AudioVolumeType, AsyncCallback\)](#zh-cn_topic_0000001149807881_section4387320194714) - - [getVolume\(AudioVolumeType\)](#zh-cn_topic_0000001149807881_section04121965119) - - [getMinVolume\(AudioVolumeType, AsyncCallback\)](#zh-cn_topic_0000001149807881_section188714283511) - - [getMinVolume\(AudioVolumeType\)](#zh-cn_topic_0000001149807881_section41556389511) - - [getMaxVolume\(AudioVolumeType, AsyncCallback\)](#zh-cn_topic_0000001149807881_section690395418516) - - [getMaxVolume\(AudioVolumeType\)](#zh-cn_topic_0000001149807881_section155151345217) - - [getDevices\(DeviceFlag, AsyncCallback\)](#zh-cn_topic_0000001149807881_section11536182020523) - - [getDevices\(DeviceFlag\)](#zh-cn_topic_0000001149807881_section181733125210) - -- [AudioDeviceDescriptor](#zh-cn_topic_0000001149807881_section17427121913310) -- [AudioDeviceDescriptors](#zh-cn_topic_0000001149807881_section5181155710523) - ->![](public_sys-resources/icon-note.gif) **说明:** ->由于权限问题,此部分功能在标准系统暂不可用,待更新。 - -## 导入模块 +# 音频管理 + +- [导入模块](#s56d19203690d4782bfc74069abb6bd71) +- [权限](#section11257113618419) +- [getAudioManager\(\): AudioManager](#section84581011418) +- [AudioVolumeType](#section92261857172218) +- [DeviceFlag](#section11285183164210) +- [DeviceRole](#section380038142619) +- [DeviceType](#section11727420122710) +- [AudioRingMode7+](#section14948916131018) +- [AudioManager](#section8265143814015) + - [setVolume\(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback\): void](#section189141826104616) + - [setVolume\(volumeType: AudioVolumeType, volume: number\): Promise](#section102021249114612) + - [getVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void](#section4387320194714) + - [getVolume\(volumeType: AudioVolumeType\): Promise](#section04121965119) + - [getMinVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void](#section188714283511) + - [getMinVolume\(volumeType: AudioVolumeType\): Promise](#section41556389511) + - [getMaxVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void](#section690395418516) + - [getMaxVolume\(volumeType: AudioVolumeType\): Promise](#section155151345217) + - [mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void7+](#section13516136134613) + - [mute\(volumeType: AudioVolumeType, mute: boolean\): Promise7+](#section7519036144616) + - [isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+](#section10684183819585) + - [isMute\(volumeType: AudioVolumeType\): Promise7+](#section6920211145610) + - [isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+](#section380012544121) + - [isActive\(volumeType: AudioVolumeType\): Promise7+](#section1880315481216) + - [setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void7+](#section18572131483613) + - [setRingerMode\(mode: AudioRingMode\): Promise7+](#section55741914143615) + - [getRingerMode\(callback: AsyncCallback\): void7+](#section149044108162) + - [getRingerMode\(\): Promise7+](#section13908210101620) + - [setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void7+](#section1691957174818) + - [setAudioParameter\(key: string, value: string\): Promise7+](#section18121057174820) + - [getAudioParameter\(key: string, callback: AsyncCallback\): void7+](#section1415145714812) + - [getAudioParameter\(key: string\): Promise7+](#section3185577485) + - [getDevices\(deviceFlag: DeviceFlag, callback: AsyncCallback\): void](#section11536182020523) + - [getDevices\(deviceFlag: DeviceFlag\): Promise](#section181733125210) + - [setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void7+](#section103558400222) + - [setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise7+](#section1235914401228) + - [isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void7+](#section12363240122219) + - [isDeviceActive\(deviceType: DeviceType\): Promise7+](#section18366184012213) + - [setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void7+](#section14703163618122) + - [setMicrophoneMute\(mute: boolean\): Promise7+](#section56287111791) + - [isMicrophoneMute\(callback: AsyncCallback\): void7+](#section6632141119912) + - [isMicrophoneMute\(\): Promise7+](#section196363111918) + +- [AudioDeviceDescriptor](#section164657411927) + - [属性](#section4947115405) + +- [AudioDeviceDescriptors](#section5181155710523) + +## 导入模块 ``` import audio from '@ohos.multimedia.audio'; ``` -## 权限 +## 权限 无 -## 方法 - -## getAudioManager\(\) +## getAudioManager\(\): AudioManager 获取音频管理器。 **返回值:** - -

名称

描述

+

描述

playing

+

idle

+

音频播放空闲。

+

playing

音频正在播放。

+

音频正在播放。

paused

+

paused

音频暂停播放

+

音频暂停播放

stopped

+

stopped

音频播放停止。

+

音频播放停止。

类型

+ + - - - @@ -67,261 +84,298 @@ import audio from '@ohos.multimedia.audio'; var audioManager = audio.getAudioManager(); ``` -## 枚举 - -## AudioVolumeType +## AudioVolumeType -音频流类型。 +枚举,音频流类型。 - -

类型

说明

+

说明

AudioManager

+

AudioManager

音频管理类。

+

音频管理类。

名称

+ + - - - - - - - -

名称

默认值

+

默认值

描述

+

描述

MEDIA

+

RINGTONE

1

+

2

表示媒体。

+

表示铃声。

RINGTONE

+

MEDIA

2

+

3

表示铃声。

+

表示媒体。

-## DeviceFlag +## DeviceFlag -可获取的设备种类。 +枚举,可获取的设备种类。 - -

名称

+ + - - - - - - - - - - -

名称

默认值

+

默认值

描述

+

描述

OUTPUT_DEVICES_FLAG

+

OUTPUT_DEVICES_FLAG

1

+

1

表示输出设备种类。

+

表示输出设备种类。

INPUT_DEVICES_FLAG

+

INPUT_DEVICES_FLAG

2

+

2

表示输入设备种类。

+

表示输入设备种类。

ALL_DEVICES_FLAG

+

ALL_DEVICES_FLAG

3

+

3

表示所有设备种类。

+

表示所有设备种类。

-## DeviceRole +## DeviceRole -设备角色。 +枚举,设备角色。 - -

名称

+ + - - - - - - - -

名称

默认值

+

默认值

描述

+

描述

INPUT_DEVICE

+

INPUT_DEVICE

1

+

1

输入设备角色。

+

输入设备角色。

OUTPUT_DEVICE

+

OUTPUT_DEVICE

2

+

2

输出设备角色。

+

输出设备角色。

-## DeviceType +## DeviceType -设备类型。 +枚举,设备类型。 - -

名称

+ + - - - - - - - - - - - - - - - - - - - -

名称

默认值

+

默认值

描述

+

描述

INVALID

+

INVALID

0

+

0

无效设备。

+

无效设备。

SPEAKER

+

SPEAKER

1

+

1

扬声器。

+

扬声器。

WIRED_HEADSET

+

WIRED_HEADSET

2

+

2

有线耳机。

+

有线耳机。

BLUETOOTH_SCO

+

BLUETOOTH_SCO

3

+

3

SCO(Synchronous Connection Oriented Link)蓝牙设备。

+

SCO(Synchronous Connection Oriented Link)蓝牙设备。

BLUETOOTH_A2DP

+

BLUETOOTH_A2DP

4

+

4

A2DP(Advanced Audio Distribution Profile )蓝牙设备。

+

A2DP(Advanced Audio Distribution Profile )蓝牙设备。

MIC

+

MIC

5

+

5

麦克风。

+

麦克风。

-## 附录 +## AudioRingMode7+ + +枚举,铃声模式。 + + + + + + + + + + + + + + + + + + + + +

名称

+

默认值

+

描述

+

RINGER_MODE_SILENT

+

0

+

静音模式

+

RINGER_MODE_VIBRATE

+

1

+

震动模式

+

RINGER_MODE_NORMAL

+

2

+

响铃模式

+
-## AudioManager +## AudioManager -音频管理器。 +管理音频音量和音频设备。 -### setVolume\(AudioVolumeType, number, AsyncCallback\) +### setVolume\(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback\): void -设置某个流的音量,使用callback方式作为异步方法。 +设置指定流的音量,使用callback方式返回异步结果。 **参数:** - -

参数名

+ + - - - - - - - - - - - - - - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

volume

+

volume

number

+

number

+

音量。

+

音量等级,可设置范围通过getMinVolume和getMaxVolume获取。

callback

+

callback

AsyncCallback<void>

+

AsyncCallback<void>

+

回调表示成功还是失败。

+

回调表示成功还是失败。

+**返回值:** + +无 + **示例:** ``` -audioManager.setVolume(audio.AudioVolumeType.MEDIA, 30, (err)=>{ +audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err)=>{ if (err) { - console.error(`failed to set volume ${err.message}`); + console.error('Failed to set the volume. ${err.message}'); return; } - console.log(`Media setVolume successful callback`); + console.log('Callback invoked to indicate a successful volume setting.'); }) ``` -### setVolume\(AudioVolumeType, number\) +### setVolume\(volumeType: AudioVolumeType, volume: number\): Promise -设置某个流的音量,使用promise方式作为异步方法。 +设置指定流的音量,使用promise方式返回异步结果。 **参数:** - -

参数名

+ + - - - - - - - - - - - @@ -329,16 +383,16 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 30, (err)=>{ **返回值:** - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

volume

+

volume

number

+

number

+

音量。

+

音量等级,可设置范围通过getMinVolume和getMaxVolume获取。

类型

+ + - - - @@ -347,85 +401,89 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 30, (err)=>{ **示例:** ``` -audioManager.setVolume(audio.AudioVolumeType.MEDIA, 30).then(()=> - console.log(`Media setVolume successful callback`); +audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(()=> + console.log('Promise returned to indicate a successful volume setting.'); ) ``` -### getVolume\(AudioVolumeType, AsyncCallback\) +### getVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void -获取某个流的音量,使用callback方式作为异步方法。 +获取指定流的音量,使用callback方式返回异步结果。 **参数:** - -

类型

说明

+

说明

Promise<void>

+

Promise<void>

Promise回调表示成功还是失败。

+

Promise回调表示成功还是失败。

参数名

+ + - - - - - - - - - - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

callback

+

callback

AsyncCallback<number>

+

AsyncCallback<number>

+

回调返回音量大小。

+

回调返回音量大小。

+**返回值:** + +无 + **示例:** ``` -audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ +audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error(`failed to get volume ${err.message}`); + console.error('Failed to obtain the volume. ${err.message}'); return; } - console.log(`Media getVolume successful callback`); + console.log('Callback invoked to indicate that the volume is obtained.'); }) ``` -### getVolume\(AudioVolumeType\) +### getVolume\(volumeType: AudioVolumeType\): Promise -获取某个流的音量,使用promise方式作为异步方法。 +获取指定流的音量,使用promise方式返回异步结果。 **参数:** - -

参数名

+ + - - - - - - - @@ -433,16 +491,16 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ **返回值:** - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

类型

+ + - - - @@ -451,85 +509,89 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ **示例:** ``` -audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((data)=> - console.log(`Media getVolume successful callback`); +audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promise returned to indicate that the volume is obtained.' + value); ) ``` -### getMinVolume\(AudioVolumeType, AsyncCallback\) +### getMinVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void -获取某个流的最小音量,使用callback方式作为异步方法。 +获取指定流的最小音量,使用callback方式返回异步结果。 **参数:** - -

类型

说明

+

说明

Promise<number>

+

Promise<number>

Promise回调返回音量大小。

+

Promise回调返回音量大小。

参数名

+ + - - - - - - - - - - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

callback

+

callback

AsyncCallback<number>

+

AsyncCallback<number>

+

回调返回最小音量。

+

回调返回最小音量。

+**返回值:** + +无 + **示例:** ``` -audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ - if (err) { - console.error(`failed to get minvolume ${err.message}`); - return; - } - console.log(`Media getMinVolume successful callback`); +audioManager.getVolume(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); }) ``` -### getMinVolume\(AudioVolumeType\) +### getMinVolume\(volumeType: AudioVolumeType\): Promise -获取某个流的最小音量,使用promise方式作为异步方法。 +获取指定流的最小音量,使用promise方式返回异步结果。 **参数:** - -

参数名

+ + - - - - - - - @@ -537,16 +599,16 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ **返回值:** - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

类型

+ + - - - @@ -555,85 +617,89 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ **示例:** ``` -audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((data)=> - console.log(`Media getMinVolume successful callback`); +audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promised returned to indicate that the minimum volume is obtained.' + value); ) ``` -### getMaxVolume\(AudioVolumeType, AsyncCallback\) +### getMaxVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void -获取某个流的最大音量,使用callback方式作为异步方法。 +获取指定流的最大音量,使用callback方式返回异步结果。 **参数:** - -

类型

说明

+

说明

Promise<number>

+

Promise<number>

Promise回调返回最小音量。

+

Promise回调返回最小音量。

参数名

+ + - - - - - - - - - - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

callback

+

callback

AsyncCallback<number>

+

AsyncCallback<number>

+

回调返回最大音量大小。

+

回调返回最大音量大小。

+**返回值:** + +无 + **示例:** ``` -audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ - if (err) { - console.error(`failed to get maxvolume ${err.message}`); - return; - } - console.log(`Media getMaxVolume successful callback`); +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); }) ``` -### getMaxVolume\(AudioVolumeType\) +### getMaxVolume\(volumeType: AudioVolumeType\): Promise -获取某个流的最大音量,使用promise方式作为异步方法。 +获取指定流的最大音量,使用promise方式返回异步结果。 **参数:** - -

参数名

+ + - - - - - - - @@ -641,16 +707,16 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ **返回值:** - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

audioType

+

volumeType

AudioVolumeType

+

AudioVolumeType

+

流类型。

+

音量流类型。

类型

+ + - - - @@ -660,84 +726,214 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value)=>{ ``` audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> - console.log(`Media getMaxVolume successful callback`); + console.log('Promised returned to indicate that the maximum volume is obtained.'); ) ``` -### getDevices\(DeviceFlag, AsyncCallback\) +### mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void7+ -获取音频设备列表,使用callback方式作为异步方法。 +设置指定音量流静音,使用callback方式返回异步结果。 **参数:** - -

类型

说明

+

说明

Promise<number>

+

Promise<number>

Promise回调返回最大音量大小。

+

Promise回调返回最大音量大小。

参数名

+ + - - - - + + + - + + - - - - - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

deviceFlag

+

volumeType

+

AudioVolumeType

+

+

音量流类型。

DeviceFlag

+

mute

+

boolean

+

设备类型的flag。

+

静音状态,true为静音,false为非静音。

callback

+

callback

AsyncCallback<AudioDeviceDescriptors>

+

AsyncCallback<void>

+

回调,返回设备列表。

+

回调表示成功还是失败。

+**返回值:** + +无 + **示例:** ``` -audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{ +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.'); +}) +``` + +### mute\(volumeType: AudioVolumeType, mute: boolean\): Promise7+ + +设置指定音量流静音,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

volumeType

+

AudioVolumeType

+

+

音量流类型。

+

mute

+

boolean

+

+

静音状态,true为静音,false为非静音。

+
+ +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<void>

+

Promise回调表示成功还是失败。

+
+ +**示例:** + +``` +audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => + console.log('Promise returned to indicate that the stream is muted.'); +) +``` + +### isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ + +获取指定音量流是否被静音,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

volumeType

+

AudioVolumeType

+

+

音量流类型。

+

callback

+

AsyncCallback<boolean>

+

+

回调返回流静音状态,true为静音,false为非静音。

+
+ +**返回值:** + +无 + +**示例:** + +``` +audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error(`failed to get getdevices ${err.message}`); + console.error('Failed to obtain the mute status. ${err.message}'); return; } - console.log(`Media getDevices successful callback`); + console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value); }) ``` -### getDevices\(DeviceFlag\) +### isMute\(volumeType: AudioVolumeType\): Promise7+ -获取音频设备列表,使用promise方式作为异步方法。 +获取指定音量流是否被静音,使用promise方式返回异步结果。 **参数:** - -

参数名

+ + - - - - - - - @@ -745,16 +941,16 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{ **返回值:** - -

参数名

类型

+

类型

必填

+

必填

说明

+

说明

deviceFlag

+

volumeType

DeviceFlag

+

AudioVolumeType

+

设备类型的flag。

+

音量流类型。

类型

+ + - - - @@ -763,59 +959,1119 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{ **示例:** ``` -audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> - console.log(`Media getDevices successful callback`); +audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value); ) ``` -## AudioDeviceDescriptor +### isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ -描述音频设备。 +获取指定音量流是否为活跃状态,使用callback方式返回异步结果。 + +**参数:** + + +

类型

说明

+

说明

Promise<AudioDeviceDescriptors>

+

Promise<boolean>

Promise回调返回设备列表。

+

Promise回调返回流静音状态,true为静音,false为非静音。

+ + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

volumeType

+

AudioVolumeType

+

+

音量流类型。

+

callback

+

AsyncCallback<boolean>

+

+

回调返回流的活跃状态,true为活跃,false为不活跃。

+
+ +**返回值:** + +无 + +**示例:** + +``` +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); +}) +``` + +### isActive\(volumeType: AudioVolumeType\): Promise7+ + +获取指定音量流是否为活跃状态,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

volumeType

+

AudioVolumeType

+

+

音量流类型。

+
+ +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<boolean>

+

Promise回调返回流的活跃状态,true为活跃,false为不活跃。

+
- -

名称

+**示例:** + +``` +audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promise returned to indicate that the active status of the stream is obtained.' + value); +) +``` + +### setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void7+ + +设置铃声模式,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

mode

+

AudioRingMode

+

+

音频铃声模式。

+

callback

+

AsyncCallback<void>

+

+

回调返回设置成功或失败。

+
+ +**返回值:** + +无 + +**示例:** + +``` +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.'); +}) +``` + +### setRingerMode\(mode: AudioRingMode\): Promise7+ + +设置铃声模式,使用promise方式返回异步结果。 + +**参数:** + + + - - - - - - + + + +

参数名

类型

+

类型

必填

+

必填

描述

+

说明

deviceRole

+

mode

DeviceRole

+

AudioRingMode

+

+

音频铃声模式。

+
+ +**返回值:** + + + + + + + - - +

类型

+

说明

+

Promise<void>

设备角色。

+

Promise回调返回设置成功或失败。

deviceType

+
+ +**示例:** + +``` +audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => + console.log('Promise returned to indicate a successful setting of the ringer mode.'); +) +``` + +### getRingerMode\(callback: AsyncCallback\): void7+ + +获取铃声模式,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

callback

+

AsyncCallback<AudioRingMode>

+

+

回调返回系统的铃声模式。

+
+ +**返回值:** + +无 + +**示例:** + +``` +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); +}) +``` + +### getRingerMode\(\): Promise7+ + +获取铃声模式,使用promise方式返回异步结果。 + +**参数:** + +无 + +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<AudioRingerMode>

+

Promise回调返回系统的铃声模式。

+
+ +**示例:** + +``` +audioManager.getRingerMode().then((value) => + console.log('Promise returned to indicate that the ringer mode is obtained.' + value); +) +``` + +### setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void7+ + +音频参数设置,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

key

+

string

+

+

被设置的音频参数的键。

+

value

+

string

+

+

被设置的音频参数的值。

+

callback

+

AsyncCallback<void>

+

+

回调返回设置成功或失败。

+
+ +**返回值:** + +无 + +**示例:** + +``` +audioManager.setAudioParameter('PBits per sample', '8 bit', (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.'); +}) +``` + +### setAudioParameter\(key: string, value: string\): Promise7+ + +音频参数设置,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

key

+

string

+

+

被设置的音频参数的键。

+

value

+

string

+

+

被设置的音频参数的值。

+
+ +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<void>

+

Promise回调返回设置成功或失败。

+
+ +**示例:** + +``` +audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => + console.log('Promise returned to indicate a successful setting of the audio parameter.'); +) +``` + +### getAudioParameter\(key: string, callback: AsyncCallback\): void7+ + +获取指定音频参数值,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

key

+

string

+

+

待获取的音频参数的键。

+

callback

+

AsyncCallback<string>

+

+

回调返回获取的音频参数的值。

+
+ +**返回值:** + +无 + +**示例:** + +``` +audioManager.getAudioParameter('PBits per sample', (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); +}) +``` + +### getAudioParameter\(key: string\): Promise7+ + +获取指定音频参数值,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

key

+

string

+

+

待获取的音频参数的键。

+
+ +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<string>

+

Promise回调返回获取的音频参数的值。

+
+ +**示例:** + +``` +audioManager.getAudioParameter('PBits per sample').then((value) => + console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value); +) +``` + +### getDevices\(deviceFlag: DeviceFlag, callback: AsyncCallback\): void + +获取音频设备列表,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

deviceFlag

+

DeviceFlag

+

+

设备类型的flag。

+

callback

+

AsyncCallback<AudioDeviceDescriptors>

+

+

回调,返回设备列表。

+
+ +**示例:** + +``` +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.'); +}) +``` + +### getDevices\(deviceFlag: DeviceFlag\): Promise + +获取音频设备列表,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

deviceFlag

+

DeviceFlag

+

+

设备类型的flag。

+
+ +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<AudioDeviceDescriptors>

+

Promise回调返回设备列表。

+
+ +**示例:** + +``` +audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> + console.log('Promise returned to indicate that the device list is obtained.'); +) +``` + +### setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void7+ + +设置设备激活状态,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

deviceType

+

DeviceType

+

+

音频设备类型。

+

active

+

boolean

+

+

设备激活状态。

+

callback

+

AsyncCallback<void>

+

+

回调返回设置成功或失败。

+
+ +**返回值:** + +无 + +**示例:** + +``` +audioManager.setDeviceActive(audio.DeviceType.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.'); +}) +``` + +### setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise7+ + +设置设备激活状态,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

deviceType

+

DeviceType

+

+

音频设备类型。

+

active

+

boolean

+

+

设备激活状态。

+
+ +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<void>

+

Promise回调返回设置成功或失败。

+
+ +**示例:** + +``` +audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> + console.log('Promise returned to indicate that the device is set to the active status.'); +) +``` + +### isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void7+ + +获取指定设备激活状态,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

deviceType

+

DeviceType

+

+

音频设备类型。

+

callback

+

AsyncCallback<boolean>

+

+

回调返回设备的激活状态。

+
+ +**返回值:** + +无 + +**示例:** + +``` +audioManager.isDeviceActive(audio.DeviceType.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.'); +}) +``` + +### isDeviceActive\(deviceType: DeviceType\): Promise7+ + +获取指定设备激活状态,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

deviceType

+

DeviceType

+

+

音频设备类型。

+
+ +**返回值:** + + + + + + + + + + +

Type

+

Description

+

Promise<boolean>

+

Promise回调返回设备的激活状态。

+
+ +**示例:** + +``` +audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => + console.log('Promise returned to indicate that the active status of the device is obtained.' + value); +) +``` + +### setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void7+ + +设置麦克风静音状态,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

mute

+

boolean

+

+

待设置的静音状态,true为静音,false为非静音。

+

callback

+

AsyncCallback<void>

+

+

回调返回设置成功或失败。

+
+ +**返回值:** + +无 + +**示例:** + +``` +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.'); +}) +``` + +### setMicrophoneMute\(mute: boolean\): Promise7+ + +设置麦克风静音状态,使用promise方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

mute

+

boolean

+

+

待设置的静音状态,true为静音,false为非静音。

+
+ +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<void>

+

Promise回调返回设置成功或失败。

+
+ +**示例:** + +``` +audioManager.setMicrophoneMute(true).then(() => + console.log('Promise returned to indicate that the microphone is muted.'); +) +``` + +### isMicrophoneMute\(callback: AsyncCallback\): void7+ + +获取麦克风静音状态,使用callback方式返回异步结果。 + +**参数:** + + + + + + + + + + + + + + +

参数名

+

类型

+

必填

+

说明

+

callback

+

AsyncCallback<boolean>

+

+

回调返回系统麦克风静音状态,true为静音,false为非静音。

+
+ +**返回值:** + +无 + +**示例:** + +``` +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); +}) +``` + +### isMicrophoneMute\(\): Promise7+ + +获取麦克风静音状态,使用promise方式返回异步结果。 + +**参数:** + +无 + +**返回值:** + + + + + + + + + + +

类型

+

说明

+

Promise<boolean>

+

Promise回调返回系统麦克风静音状态,true为静音,false为非静音。

+
+ +**示例:** + +``` +audioManager.isMicrophoneMute().then((value) => + console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value); +) +``` + +## AudioDeviceDescriptor + +描述音频设备。 + +### 属性 + + + + + + + + + + + + + + + + + - - -

名称

+

参数型

+

可读

+

可写

+

说明

+

deviceRole

+

DeviceRole

+

+

+

设备角色。

+

deviceType

+

DeviceType

DeviceType

+

+

设备类型。

+

设备类型。

-## AudioDeviceDescriptors +## AudioDeviceDescriptors - -

名称

+ + - - - diff --git "a/zh-cn/application-dev/media/figures/\351\237\263\351\242\221\346\222\255\346\224\276\347\212\266\346\200\201\346\234\272.png" "b/zh-cn/application-dev/media/figures/\351\237\263\351\242\221\346\222\255\346\224\276\347\212\266\346\200\201\346\234\272.png" index 2bd16cf5945b3347a2bebdb8f78e2e5fcab992f8..e0777e28838f6d2455233f2068339f8548f50c67 100755 Binary files "a/zh-cn/application-dev/media/figures/\351\237\263\351\242\221\346\222\255\346\224\276\347\212\266\346\200\201\346\234\272.png" and "b/zh-cn/application-dev/media/figures/\351\237\263\351\242\221\346\222\255\346\224\276\347\212\266\346\200\201\346\234\272.png" differ diff --git "a/zh-cn/application-dev/media/\351\237\263\351\242\221\346\222\255\346\224\276\345\274\200\345\217\221\346\214\207\345\257\274.md" "b/zh-cn/application-dev/media/\351\237\263\351\242\221\346\222\255\346\224\276\345\274\200\345\217\221\346\214\207\345\257\274.md" index 67e223951882bfcdad4219a76577cdf9226ac0c2..4bf8fc7269c5664de3c93c1c390245de98db2d93 100755 --- "a/zh-cn/application-dev/media/\351\237\263\351\242\221\346\222\255\346\224\276\345\274\200\345\217\221\346\214\207\345\257\274.md" +++ "b/zh-cn/application-dev/media/\351\237\263\351\242\221\346\222\255\346\224\276\345\274\200\345\217\221\346\214\207\345\257\274.md" @@ -63,6 +63,11 @@ + + + - - - - - @@ -103,11 +103,6 @@ - - - - + + + @@ -133,7 +133,7 @@ - @@ -143,7 +143,7 @@ - @@ -162,73 +162,70 @@ ``` player.on('play', (err, action) => { if (err) { - console.log(`err returned in play() callback`); + console.error('Error returned in the play() callback.'); return; } - console.info('Current Song duration: '+duration); - console.log(`In play callback current time: ${player.currentTime}`); - console.info('Current Player Status: '+player.state); - console.info('Pause Mp3'); + console.info('Current player duration: '+ player.duration); + console.info('Current player time: ' + player.currentTime); + console.info('Current player status: '+player.state); + console.info('Pause MP3'); player.pause(); }); player.on('pause', (err, action) => { if (err) { - console.log(`err returned in pause() callback`); + console.error('Error returned in the pause() callback.'); return; } - console.log(`pause callback, state: ${player.state}`); - console.info('Current Player Status: '+player.state); - var currentTime = player.currenTime; - console.info('Current Player Time: '+currentTime); - player.seek(30000); //seek for 30 seconds + console.info('Current player status: ' + player.state); + console.info('Current player time: ' + player.currentTime); + player.seek(30000); // Seek for 30 seconds. }); player.on('stop', (err, action) => { if (err) { - console.log(`err returned in stop() callback`); + console.error('Error returned in the stop() callback.'); return; } - console.log(`stop callback, state: ${player.state}`); + console.info('stop callback invoked. State:' + player.state); + player.reset(); }); player.on('dataLoad', (err, action) => { if (err) { - console.log(`err returned in dataLoad() callback`); + console.error('Error returned in the dataLoad() callback.'); return; } - console.log(`dataLoad callback is called, cuurent time: ${player.currentTime}`); - console.log(`Duration of the source: ${player.duration}`); + console.info('dataLoad callback invoked. Current time: ' + player.currentTime); + console.info('Duration of the source:' + player.duration); + player.play(); + }); + player.on('reset', (err, action) => { + if (err) { + console.error('Error returned in the reset() callback.'); + return; + } + console.info('reset callback invoked.'); + player.release(); }); player.on('finish', (err, action) => { if (err) { - console.log(`err returned in finish() callback`); + console.error('Error returned in the finish() callback.'); return; } - console.log(`Player finish callback is called`); + console.info('finish callback invoked.'); }); - player.on('timeUpdate', (err, action) => { - if (err) { - console.log(`err returned in timeUpdate() callback`); - return; - } - console.log(`In timeupdate callback current time: ${player.currentTime}`); - var newTime = player.currenTime; - if(newTime = 30000) { - console.info('Seek success, new time : '+newTime); + player.on('timeUpdate', (seekTime, action) => { + console.info('Seek time: ' + seekTime); + console.info('Current player time: ' + player.currentTime); + var newTime = player.currentTime; + if(newTime == 30000) { + console.info('Seek succeeded. New time: ' + newTime); } else { - console.info('Seek Failed'); + console.error('Seek failed: ', + newTime); } player.stop(); }); - player.on('durationchange', (err, action) => { - if (err) { - console.log(`err returned in durationchange callback`); - return; - } - console.log(`Durationchange callback is called`); - }); player.on('error', (err) => { - console.error(`player error: ${err.message}`); + console.error('Player error: ${err.message}'); }); - ``` 3. 启动播放。 @@ -237,7 +234,6 @@ var audioSourceMp3 = 'file://test.mp3'; player.src = audioSourceMp3; player.loop = true; - player.play(); ```

名称

描述

+

描述

设备属性队列

+

设备属性数组

AudioDeviceDescriptor的队列,只读。

+

AudioDeviceDescriptor的数组,只读。

停止播放。

reset()7+

+

重置播放音频源。

+

setVolume(vol: number)

改变音频播放音量

@@ -78,17 +83,12 @@

音频播放的媒体URI。

state:string

+

state:AudioState

播放的状态属性。

autoplay:boolean

-

音频的自动播放属性。

-

currenttime:number

+

currentTime:number

音频的当前播放位置。

音频的循环播放属性。

muted:boolean

-

音频的静音属性。

-

on('play', function callback)

监听音频播放开始事件。

@@ -123,7 +118,12 @@

监听音频播放停止事件。

on('ended',function callback)

+

on('reset', function callback)

+

监听音频播放重置事件。

+

on('finish',function callback)

监听音频播放结束事件。

监听音频播放错误事件。

on('loaderdata', function callback)

+

on('dataload', function callback)

监听音频播放加载数据事件。

监听音频播放音量变化事件。

on('timeupdate', function callback)

+

on('timeUpdate', function callback)

监听音频播放进度改变事件。