未验证 提交 0771b00d 编写于 作者: O openharmony_ci 提交者: Gitee

!11590 示例代码以及接口一致性问题检查

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