Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6e94a64c
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6e94a64c
编写于
3月 15, 2022
作者:
M
magekkkk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add audio api reference for MR version
Signed-off-by:
N
magekkkk
<
lixin113@huawei.com
>
上级
1733bf33
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
124 addition
and
8 deletion
+124
-8
zh-cn/application-dev/reference/apis/js-apis-audio.md
zh-cn/application-dev/reference/apis/js-apis-audio.md
+124
-8
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-audio.md
浏览文件 @
6e94a64c
...
...
@@ -122,15 +122,17 @@ let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
| 名称 | 默认值 | 描述 |
| 名称 | 默认值 | 描述
|
| -------------- | ------ | --------------------------------------------------------- |
| INVALID | 0 | 无效设备。 |
| EARPIECE | 1 | 听筒。 |
| SPEAKER | 2 | 扬声器。 |
| WIRED_HEADSET | 3 | 有线耳机。 |
| BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 |
| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP(Advanced Audio Distribution Profile)连接。 |
| MIC | 15 | 麦克风。 |
| INVALID | 0 | 无效设备。 |
| EARPIECE | 1 | 听筒。 |
| SPEAKER | 2 | 扬声器。 |
| WIRED_HEADSET | 3 | 有线耳机,带麦克风。 |
| WIRED_HEADPHONE| 4 | 有线耳机,无麦克风。 |
| BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 |
| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP(Advanced Audio Distribution Profile)连接。 |
| MIC | 15 | 麦克风。 |
| USB_HEADSET | 22 | USB耳机,带麦克风。 |
## ActiveDeviceType
...
...
@@ -304,6 +306,19 @@ let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
| INTERRUPT_HINT_DUCK | 4 | 提示音频躲避。(躲避:音量减弱,而不会停止) |
| INTERRUPT_HINT_UNDUCK | 5 | 提示音量恢复。 |
## InterruptActionType
枚举,中断事件返回类型。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
| 名称 | 默认值 | 描述 |
| --------------------- | ------ | -------------------------------------------- |
| TYPE_ACTIVATED | 0 | 表示触发焦点事件。 |
| TYPE_INTERRUPT | 1 | 表示音频打断事件。 |
## AudioStreamInfo<sup>8+</sup>
音频流信息。
...
...
@@ -352,6 +367,35 @@ let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
| forceType |
[
InterruptForceType
](
#interruptforcetype8
)
| 是 | 操作是由系统执行或是由应用程序执行。 |
| hintType |
[
InterruptHint
](
#interrupthint8
)
| 是 | 中断提示。 |
## AudioInterrupt
音频监听事件传入的参数。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
| 名称 | 类型 | 必填 | 说明 |
| --------- | ------------------------------------------ | ---- | ------------------------------------ |
| streamUsage |
[
StreamUsage
](
#streamusage8
)
| 是 | 音频流使用类型。 |
| contentType |
[
ContentType
](
#contenttype8
)
| 是 | 音频打断媒体类型。 |
| pauseWhenDucked | boolean | 是 | 音频打断时是否可以暂停音频播放(true表示音频播放可以在音频打断期间暂停,false表示相反)。 |
## InterruptAction
音频打断/获取焦点事件的回调方法。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer
| 名称 | 类型 | 必填 | 说明 |
| --------- | ------------------------------------------ | ---- | ------------------------------------ |
| actionType |
[
InterruptActionType
](
#interruptactiontype
)
| 是 | 事件返回类型。TYPE_ACTIVATED为焦点触发事件,TYPE_INTERRUPT为音频打断事件。 |
| type |
[
InterruptType
](
#interrupttype8
)
| 否 | 打断事件类型。 |
| hint |
[
InterruptHint
](
interrupthint8
)
| 否 | 打断事件提示。 |
| activated | boolean | 否 | 获得/释放焦点。true表示焦点获取/释放成功,false表示焦点获得/释放失败。 |
## VolumeEvent<sup>8+</sup>
音量改变时,应用接收的事件。
...
...
@@ -1321,6 +1365,78 @@ on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void
| type | string | 是 | 事件回调类型,支持的事件为:'ringerModeChange'(铃声模式变化事件,检测到铃声模式改变时,触发该事件)。 |
| callback | Callback
<
[
AudioRingMode
](
#audioringmode
)
>
| 是 | 回调方法。 |
### on('interrupt')
on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback
\<
InterruptAction>): void
请求焦点并开始监听音频打断事件(当应用程序的音频被另一个播放事件中断,回调通知此应用程序)
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**
SystemCapability.Multimedia.Audio.Renderer
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 音频打断事件回调类型,支持的事件为:'interrupt'(多应用之间第二个应用会打断第一个应用,触发该事件)。 |
| interrupt | AudioInterrupt | 是 | 音频打断事件类型的参数。 |
| callback | Callback
<
[
InterruptAction
](
#interruptaction
)
>
| 是 | 音频打断事件回调方法。 |
**示例:**
```
var interAudioInterrupt = {
streamUsage:2,
contentType:0,
pauseWhenDucked:true
};
this.audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log("An event to gain the audio focus starts.");
console.log("Focus gain event:" + JSON.stringify(InterruptAction));
}
if (InterruptAction.actionType === 1) {
console.log("An audio interruption event starts.");
console.log("Audio interruption event:" + JSON.stringify(InterruptAction));
}
});
```
### off('interrupt')
off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback
\<
InterruptAction>): void
取消监听音频打断事件(删除监听事件,取消打断)
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**
SystemCapability.Multimedia.Audio.Renderer
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 音频打断事件回调类型,支持的事件为:'interrupt'(多应用之间第二个应用会打断第一个应用,触发该事件)。 |
| interrupt | AudioInterrupt | 是 | 音频打断事件类型的参数。 |
| callback | Callback
<
[
InterruptAction
](
#interruptaction
)
>
| 否 | 音频打断事件回调方法。 |
**示例:**
```
var interAudioInterrupt = {
streamUsage:2,
contentType:0,
pauseWhenDucked:true
};
this.audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log("An event to release the audio focus starts.");
console.log("Focus release event:" + JSON.stringify(InterruptAction));
}
});
```
## AudioDeviceDescriptor
描述音频设备。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录