Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
4d029b0c
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看板
提交
4d029b0c
编写于
7月 12, 2023
作者:
W
wangzx0705
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify docs format
Signed-off-by:
N
wangzx0705
<
wangzx0705@thundersoft.com
>
上级
0afa6437
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
35 deletion
+42
-35
zh-cn/application-dev/reference/apis/js-apis-audio.md
zh-cn/application-dev/reference/apis/js-apis-audio.md
+42
-35
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-audio.md
浏览文件 @
4d029b0c
...
...
@@ -2995,20 +2995,20 @@ isVolumeUnadjustable(): boolean
| 类型 | 说明 |
| ---------------------- | ------------------------------------------------------ |
| boolean | 同步
回调
返回固定音量模式开关状态,true为固定音量模式,false为非固定音量模式。 |
| boolean | 同步
接口,
返回固定音量模式开关状态,true为固定音量模式,false为非固定音量模式。 |
**示例:**
```
js
bool
switch
=
audioVolumeGroupManager
.
isVolumeUnadjustable
();
console
.
info
(
`Whether it is volume unadjustable:
${
switch
}
`
);
console
.
info
(
`Whether it is volume unadjustable:
${
switch
}
.
`
);
```
### adjustVolumeByStep<sup>10+</sup>
adjustVolumeByStep(adjustType: VolumeAdjustType, callback: AsyncCallback
<
void
>
): void
调节当前最高优先级的流的音量,使音量值
加一或减一
,使用callback方式异步返回结果。
调节当前最高优先级的流的音量,使音量值
按步长加或减
,使用callback方式异步返回结果。
**需要权限:**
ohos.permission.ACCESS_NOTIFICATION_POLICY
...
...
@@ -3032,8 +3032,9 @@ audioVolumeGroupManager.adjustVolumeByStep(audio.VolumeAdjustType.VOLUME_UP, (er
if
(
err
)
{
console
.
error
(
`Failed to adjust the volume by step.
${
err
}
`
);
return
;
}
else
{
console
.
info
(
'
Success to adjust the volume by step.
'
);
}
console
.
info
(
'
Success to adjust the volume by step.
'
);
});
```
### adjustVolumeByStep<sup>10+</sup>
...
...
@@ -3067,7 +3068,7 @@ adjustVolumeByStep(adjustType: VolumeAdjustType): Promise<void>
```
js
audioVolumeGroupManager
.
adjustVolumeByStep
(
audio
.
VolumeAdjustType
.
VOLUME_UP
).
then
(()
=>
{
console
.
info
(
'
Success to adjust the volume by step.
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
'
Fail to adjust the volume by step.
'
);
});
```
...
...
@@ -3099,10 +3100,10 @@ adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustTy
```
js
audioVolumeGroupManager
.
adjustSystemVolumeByStep
(
audio
.
AudioVolumeType
.
MEDIA
,
audio
.
VolumeAdjustType
.
VOLUME_UP
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to adjust the system volume by step.
${
err
}
`
);
return
;
console
.
error
(
`Failed to adjust the system volume by step
${
err
}
`
);
}
else
{
console
.
info
(
'
Success to adjust the system volume by step.
'
);
}
console
.
info
(
'
Success to adjust the system volume by step.
'
);
});
```
### adjustSystemVolumeByStep<sup>10+</sup>
...
...
@@ -3137,7 +3138,7 @@ adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustTy
```
js
audioVolumeGroupManager
.
adjustSystemVolumeByStep
(
audio
.
AudioVolumeType
.
MEDIA
,
audio
.
VolumeAdjustType
.
VOLUME_UP
).
then
(()
=>
{
console
.
info
(
'
Success to adjust the system volume by step.
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
'
Fail to adjust the system volume by step.
'
);
});
```
...
...
@@ -3167,9 +3168,9 @@ getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: De
audioVolumeGroupManager
.
getSystemVolumeInDb
(
audio
.
AudioVolumeType
.
MEDIA
,
3
,
audio
.
DeviceType
.
SPEAKER
,
(
err
,
dB
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get the volume DB.
${
err
}
`
);
return
;
}
else
{
console
.
info
(
`Success to get the volume DB.
${
dB
}
`
);
}
console
.
info
(
`Success to get the volume DB.
${
dB
}
`
);
});
```
### getSystemVolumeInDb<sup>10+</sup>
...
...
@@ -3201,7 +3202,7 @@ getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: De
```
js
audioVolumeGroupManager
.
getSystemVolumeInDb
(
audio
.
AudioVolumeType
.
MEDIA
,
3
,
audio
.
DeviceType
.
SPEAKER
).
then
((
dB
)
=>
{
console
.
info
(
`Success to get the volume DB.
${
dB
}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
`Fail to adjust the system volume by step.
${
error
}
`
);
});
```
...
...
@@ -5495,10 +5496,11 @@ getMinStreamVolume(callback: AsyncCallback<number>): void
```
js
audioRenderer
.
getMinStreamVolume
((
err
,
minVolume
)
=>
{
if
(
err
){
console
.
error
(
`Get min stream volume Fail:
${
err
}
`
);
if
(
err
)
{
console
.
error
(
`getMinStreamVolume error:
${
err
}
`
);
}
else
{
console
.
info
(
`getMinStreamVolume Success!
${
minVolume
}
`
);
}
console
.
info
(
`Get min stream volume Success!
${
minVolume
}
`
);
});
```
### getMinStreamVolume<sup>10+</sup>
...
...
@@ -5543,10 +5545,11 @@ getMaxStreamVolume(callback: AsyncCallback<number>): void
```
js
audioRenderer
.
getMaxStreamVolume
((
err
,
maxVolume
)
=>
{
if
(
err
){
console
.
error
(
`Get max stream volume Fail:
${
err
}
`
);
if
(
err
)
{
console
.
error
(
`getMaxStreamVolume Fail:
${
err
}
`
);
}
else
{
console
.
info
(
`getMaxStreamVolume Success!
${
maxVolume
}
`
);
}
console
.
info
(
`Get max stream volume Success!
${
maxVolume
}
`
);
});
```
### getMaxStreamVolume<sup>10+</sup>
...
...
@@ -5591,10 +5594,11 @@ getUnderflowCount(callback: AsyncCallback<number>): void
```
js
audioRenderer
.
getUnderflowCount
((
err
,
underflowCount
)
=>
{
if
(
err
){
console
.
error
(
`Get underflow count Fail:
${
err
}
`
);
if
(
err
)
{
console
.
error
(
`getUnderflowCount Fail:
${
err
}
`
);
}
else
{
console
.
info
(
`getUnderflowCount Success!
${
underflowCount
}
`
);
}
console
.
info
(
`Get underflow count Success!
${
underflowCount
}
`
);
});
```
### getUnderflowCount<sup>10+</sup>
...
...
@@ -5639,17 +5643,18 @@ getCurrentOutputDevices(callback: AsyncCallback<AudioDeviceDescriptors>):
```
js
audioRenderer
.
getCurrentOutputDevices
((
err
,
deviceInfo
)
=>
{
if
(
err
){
console
.
error
(
`Get underflow count Fail:
${
err
}
`
);
if
(
err
)
{
console
.
error
(
`getCurrentOutputDevices Fail:
${
err
}
`
);
}
else
{
console
.
info
(
`DeviceInfo id:
${
deviceInfo
.
id
}
`
);
console
.
info
(
`DeviceInfo type:
${
descriptor
.
deviceType
}
`
);
console
.
info
(
`DeviceInfo role:
${
descriptor
.
deviceRole
}
`
);
console
.
info
(
`DeviceInfo name:
${
descriptor
.
name
}
`
);
console
.
info
(
`DeviceInfo address:
${
descriptor
.
address
}
`
);
console
.
info
(
`DeviceInfo samplerates:
${
descriptor
.
sampleRates
[
0
]}
`
);
console
.
info
(
`DeviceInfo channelcounts:
${
descriptor
.
channelCounts
[
0
]}
`
);
console
.
info
(
`DeviceInfo channelmask:
${
descriptor
.
channelMasks
}
`
);
}
console
.
info
(
`DeviceInfo id:
${
deviceInfo
.
id
}
`
);
console
.
info
(
`DeviceInfo type:
${
descriptor
.
deviceType
}
`
);
console
.
info
(
`DeviceInfo role:
${
descriptor
.
deviceRole
}
`
);
console
.
info
(
`DeviceInfo name:
${
descriptor
.
name
}
`
);
console
.
info
(
`DeviceInfo address:
${
descriptor
.
address
}
`
);
console
.
info
(
`DeviceInfo samplerates:
${
descriptor
.
sampleRates
[
0
]}
`
);
console
.
info
(
`DeviceInfo channelcounts:
${
descriptor
.
channelCounts
[
0
]}
`
);
console
.
info
(
`DeviceInfo channelmask:
${
descriptor
.
channelMasks
}
`
);
});
```
### getCurrentOutputDevices<sup>10+</sup>
...
...
@@ -5927,10 +5932,11 @@ on(type: 'outputDeviceChange', callback: Callback<AudioDeviceDescriptors\>): voi
```
js
audioRenderer
.
on
(
'
outputDeviceChange
'
,
(
deviceChangeInfo
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Subscribes output device change event callback Fail:
${
err
}
`
);
}
else
{
console
.
info
(
`Subscribes output device change event callback Success!`
);
}
console
.
info
(
`Subscribes output device change event callback Success!`
);
});
```
### off('outputDeviceChange') <sup>10+</sup>
...
...
@@ -5959,10 +5965,11 @@ off(type: 'outputDeviceChange', callback?: Callback<AudioDeviceDescriptors\>): v
```
js
audioRenderer
.
off
(
'
outputDeviceChange
'
,
(
deviceChangeInfo
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Unsubscribes output device change event callback Fail:
${
err
}
`
);
}
else
{
console
.
info
(
`Unsubscribes output device change event callback Success!`
);
}
console
.
info
(
`Unsubscribes output device change event callback Success!`
);
});
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录