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

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

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