Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ca3707b1
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看板
提交
ca3707b1
编写于
9月 19, 2022
作者:
J
jiao_yanlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sample code error modification
Signed-off-by:
N
jiao_yanlin
<
jiaoyanlin@huawei.com
>
上级
7563a68f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
231 addition
and
10 deletion
+231
-10
zh-cn/application-dev/reference/apis/js-apis-audio.md
zh-cn/application-dev/reference/apis/js-apis-audio.md
+231
-10
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-audio.md
浏览文件 @
ca3707b1
...
...
@@ -2075,6 +2075,7 @@ getGroupManager(groupId: number, callback: AsyncCallback<AudioGroupManager\>\):
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
...
...
@@ -2339,6 +2340,23 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
setVolume
(
audio
.
AudioVolumeType
.
MEDIA
,
10
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set the volume.
${
err
}
`
);
...
...
@@ -2378,6 +2396,24 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
setVolume
(
audio
.
AudioVolumeType
.
MEDIA
,
10
).
then
(()
=>
{
console
.
info
(
'
Promise returned to indicate a successful volume setting.
'
);
});
...
...
@@ -2403,6 +2439,23 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): v
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
getVolume
(
audio
.
AudioVolumeType
.
MEDIA
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume.
${
err
}
`
);
...
...
@@ -2437,6 +2490,23 @@ getVolume(volumeType: AudioVolumeType): Promise<number>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
getVolume
(
audio
.
AudioVolumeType
.
MEDIA
).
then
((
value
)
=>
{
console
.
info
(
`Promise returned to indicate that the volume is obtained
${
value
}
.`
);
});
...
...
@@ -2462,6 +2532,23 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>)
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
getMinVolume
(
audio
.
AudioVolumeType
.
MEDIA
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the minimum volume.
${
err
}
`
);
...
...
@@ -2496,6 +2583,23 @@ getMinVolume(volumeType: AudioVolumeType): Promise<number>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
getMinVolume
(
audio
.
AudioVolumeType
.
MEDIA
).
then
((
value
)
=>
{
console
.
info
(
`Promised returned to indicate that the minimum volume is obtained
${
value
}
.`
);
});
...
...
@@ -2521,6 +2625,23 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>)
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
getMaxVolume
(
audio
.
AudioVolumeType
.
MEDIA
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the maximum volume.
${
err
}
`
);
...
...
@@ -2555,6 +2676,23 @@ getMaxVolume(volumeType: AudioVolumeType): Promise<number>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
getMaxVolume
(
audio
.
AudioVolumeType
.
MEDIA
).
then
((
data
)
=>
{
console
.
info
(
'
Promised returned to indicate that the maximum volume is obtained.
'
);
});
...
...
@@ -2585,6 +2723,23 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
mute
(
audio
.
AudioVolumeType
.
MEDIA
,
true
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to mute the stream.
${
err
}
`
);
...
...
@@ -2624,6 +2779,23 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
mute
(
audio
.
AudioVolumeType
.
MEDIA
,
true
).
then
(()
=>
{
console
.
info
(
'
Promise returned to indicate that the stream is muted.
'
);
});
...
...
@@ -2649,6 +2821,23 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): voi
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
isMute
(
audio
.
AudioVolumeType
.
MEDIA
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the mute status.
${
err
}
`
);
...
...
@@ -2683,6 +2872,23 @@ isMute(volumeType: AudioVolumeType): Promise<boolean>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
var
audioGroupManager
;
async
function
getGroupManager
(){
let
value
=
await
audioManager
.
getVolumeGroups
(
audio
.
LOCAL_NETWORK_ID
);
if
(
value
.
length
>
0
)
{
let
groupid
=
value
[
0
].
groupId
;
audioManager
.
getGroupManager
(
groupid
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the volume group infos list.
${
err
}
`
);
return
;
}
audioGroupManager
=
value
console
.
info
(
'
Callback invoked to indicate that the volume group infos list is obtained.
'
);
});
}
}
audioGroupManager
.
isMute
(
audio
.
AudioVolumeType
.
MEDIA
).
then
((
value
)
=>
{
console
.
info
(
`Promise returned to indicate that the mute status of the stream is obtained
${
value
}
.`
);
});
...
...
@@ -2709,8 +2915,9 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeI
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -2766,8 +2973,9 @@ getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -2821,8 +3029,9 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeI
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -2876,8 +3085,9 @@ getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -2930,8 +3140,9 @@ on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArr
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -2981,8 +3192,9 @@ off(type: "audioRendererChange");
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -3013,8 +3225,9 @@ on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArr
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -3063,8 +3276,9 @@ off(type: "audioCapturerChange");
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audio
.
getStreamManager
((
err
,
data
)
=>
{
audio
Manager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
...
...
@@ -3099,11 +3313,11 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescrip
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
audioManager
.
getRoutingManager
((
err
,
AudioRoutingManager
)
=>
{
if
(
err
)
{
console
.
error
(
`AudioFrameworkTest:Callback:failed to get RoutingManager
${
err
}
`
);
}
else
{
}
else
{
AudioRoutingManager
.
getDevices
(
audio
.
DeviceFlag
.
OUTPUT_DEVICES_FLAG
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to obtain the device list.
${
err
}
`
);
...
...
@@ -3138,6 +3352,7 @@ getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
audioManager
.
getRoutingManager
((
err
,
AudioRoutingManager
)
=>
{
if
(
err
)
{
console
.
error
(
`AudioFrameworkTest:Callback:failed to get RoutingManager
${
err
}
`
);
...
...
@@ -3169,6 +3384,7 @@ on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback<DeviceChange
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
audioManager
.
getRoutingManager
((
err
,
AudioRoutingManager
)
=>
{
if
(
err
)
{
console
.
error
(
`AudioFrameworkTest:Callback:failed to get RoutingManager
${
err
}
`
);
...
...
@@ -3203,6 +3419,7 @@ off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
audioManager
.
getRoutingManager
((
err
,
AudioRoutingManager
)
=>
{
if
(
err
)
{
console
.
error
(
`AudioFrameworkTest:Callback:failed to get RoutingManager
${
err
}
`
);
...
...
@@ -3234,6 +3451,7 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCa
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
outputAudioDeviceDescriptor
=
[{
"
deviceRole
"
:
audio
.
DeviceRole
.
OUTPUT_DEVICE
,
"
networkId
"
:
audio
.
LOCAL_NETWORK_ID
,
...
...
@@ -3276,6 +3494,7 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void&
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
outputAudioDeviceDescriptor
=
[{
"
deviceRole
"
:
audio
.
DeviceRole
.
OUTPUT_DEVICE
,
"
networkId
"
:
audio
.
LOCAL_NETWORK_ID
,
...
...
@@ -3312,6 +3531,7 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
outputAudioRendererFilter
=
{
"
uid
"
:
20010041
,
"
rendererInfo
"
:
{
...
...
@@ -3362,6 +3582,7 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
outputAudioRendererFilter
=
{
"
uid
"
:
20010041
,
"
rendererInfo
"
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录