Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c092b686
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看板
未验证
提交
c092b686
编写于
9月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!9828 示例代码错误修改
Merge pull request !9828 from 一杯丞丞汁儿/master
上级
4c980232
2e126be0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
344 deletion
+63
-344
zh-cn/application-dev/reference/apis/js-apis-audio.md
zh-cn/application-dev/reference/apis/js-apis-audio.md
+63
-344
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-audio.md
浏览文件 @
c092b686
...
...
@@ -161,6 +161,8 @@ createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<Audio
**系统能力:**
SystemCapability.Multimedia.Audio.Capturer
**需要权限:**
ohos.permission.MICROPHONE
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -207,6 +209,8 @@ createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer\>
**系统能力:**
SystemCapability.Multimedia.Audio.Capturer
**需要权限:**
ohos.permission.MICROPHONE
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -2149,12 +2153,13 @@ getStreamManager(callback: AsyncCallback\<AudioStreamManager>): void
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
let
audioStreamManager
=
data
;
audioStreamManager
=
data
;
}
});
```
...
...
@@ -2343,23 +2348,6 @@ 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
}
`
);
...
...
@@ -2399,24 +2387,6 @@ 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.
'
);
});
...
...
@@ -2442,23 +2412,6 @@ 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
}
`
);
...
...
@@ -2493,23 +2446,6 @@ 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
}
.`
);
});
...
...
@@ -2535,23 +2471,6 @@ 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
}
`
);
...
...
@@ -2586,23 +2505,6 @@ 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
}
.`
);
});
...
...
@@ -2628,23 +2530,6 @@ 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
}
`
);
...
...
@@ -2679,23 +2564,6 @@ 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.
'
);
});
...
...
@@ -2726,23 +2594,6 @@ 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
}
`
);
...
...
@@ -2782,23 +2633,6 @@ 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.
'
);
});
...
...
@@ -2824,23 +2658,6 @@ 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
}
`
);
...
...
@@ -2875,23 +2692,6 @@ 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
}
.`
);
});
...
...
@@ -2918,17 +2718,6 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeI
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
audioStreamManager
.
getCurrentAudioRendererInfoArray
(
async
(
err
,
AudioRendererChangeInfoArray
)
=>
{
console
.
info
(
'
getCurrentAudioRendererInfoArray **** Get Callback Called ****
'
);
if
(
err
)
{
...
...
@@ -2976,43 +2765,34 @@ getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
await
audioStreamManager
.
getCurrentAudioRendererInfoArray
().
then
(
function
(
AudioRendererChangeInfoArray
)
{
console
.
info
(
`getCurrentAudioRendererInfoArray ######### Get Promise is called ##########`
);
if
(
AudioRendererChangeInfoArray
!=
null
)
{
for
(
let
i
=
0
;
i
<
AudioRendererChangeInfoArray
.
length
;
i
++
)
{
let
AudioRendererChangeInfo
=
AudioRendererChangeInfoArray
[
i
];
console
.
info
(
`StreamId for
${
i
}
is:
${
AudioRendererChangeInfo
.
streamId
}
`
);
console
.
info
(
`ClientUid for
${
i
}
is:
${
AudioRendererChangeInfo
.
clientUid
}
`
);
console
.
info
(
`Content
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererInfo
.
content
}
`
);
console
.
info
(
`Stream
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererInfo
.
usage
}
`
);
console
.
info
(
`Flag
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererInfo
.
rendererFlags
}
`
);
console
.
info
(
`State for
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererState
}
`
);
for
(
let
j
=
0
;
j
<
AudioRendererChangeInfo
.
deviceDescriptors
.
length
;
j
++
)
{
console
.
info
(
`Id:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
id
}
`
);
console
.
info
(
`Type:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
deviceType
}
`
);
console
.
info
(
`Role:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
deviceRole
}
`
);
console
.
info
(
`Name:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
name
}
`
);
console
.
info
(
`Address:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
address
}
`
);
console
.
info
(
`SampleRates:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
sampleRates
[
0
]}
`
);
console
.
info
(
`ChannelCount
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
channelCounts
[
0
]}
`
);
console
.
info
(
`ChannelMask:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
channelMasks
}
`
);
async
function
getCurrentAudioRendererInfoArray
(){
await
audioStreamManager
.
getCurrentAudioRendererInfoArray
().
then
(
function
(
AudioRendererChangeInfoArray
)
{
console
.
info
(
`getCurrentAudioRendererInfoArray ######### Get Promise is called ##########`
);
if
(
AudioRendererChangeInfoArray
!=
null
)
{
for
(
let
i
=
0
;
i
<
AudioRendererChangeInfoArray
.
length
;
i
++
)
{
let
AudioRendererChangeInfo
=
AudioRendererChangeInfoArray
[
i
];
console
.
info
(
`StreamId for
${
i
}
is:
${
AudioRendererChangeInfo
.
streamId
}
`
);
console
.
info
(
`ClientUid for
${
i
}
is:
${
AudioRendererChangeInfo
.
clientUid
}
`
);
console
.
info
(
`Content
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererInfo
.
content
}
`
);
console
.
info
(
`Stream
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererInfo
.
usage
}
`
);
console
.
info
(
`Flag
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererInfo
.
rendererFlags
}
`
);
console
.
info
(
`State for
${
i
}
is:
${
AudioRendererChangeInfo
.
rendererState
}
`
);
for
(
let
j
=
0
;
j
<
AudioRendererChangeInfo
.
deviceDescriptors
.
length
;
j
++
)
{
console
.
info
(
`Id:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
id
}
`
);
console
.
info
(
`Type:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
deviceType
}
`
);
console
.
info
(
`Role:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
deviceRole
}
`
);
console
.
info
(
`Name:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
name
}
`
);
console
.
info
(
`Address:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
address
}
`
);
console
.
info
(
`SampleRates:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
sampleRates
[
0
]}
`
);
console
.
info
(
`ChannelCount
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
channelCounts
[
0
]}
`
);
console
.
info
(
`ChannelMask:
${
i
}
:
${
AudioRendererChangeInfo
.
deviceDescriptors
[
j
].
channelMasks
}
`
);
}
}
}
}
}).
catch
((
err
)
=>
{
console
.
error
(
`getCurrentAudioRendererInfoArray :ERROR:
${
err
}
`
);
}
);
}
).
catch
((
err
)
=>
{
console
.
error
(
`getCurrentAudioRendererInfoArray :ERROR:
${
err
}
`
);
}
);
}
```
### getCurrentAudioCapturerInfoArray<sup>9+</sup>
...
...
@@ -3032,17 +2812,6 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeI
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
audioStreamManager
.
getCurrentAudioCapturerInfoArray
(
async
(
err
,
AudioCapturerChangeInfoArray
)
=>
{
console
.
info
(
'
getCurrentAudioCapturerInfoArray **** Get Callback Called ****
'
);
if
(
err
)
{
...
...
@@ -3088,41 +2857,32 @@ getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray>
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
await
audioStreamManager
.
getCurrentAudioCapturerInfoArray
().
then
(
function
(
AudioCapturerChangeInfoArray
)
{
console
.
info
(
'
getCurrentAudioCapturerInfoArray **** Get Promise Called ****
'
);
if
(
AudioCapturerChangeInfoArray
!=
null
)
{
for
(
let
i
=
0
;
i
<
AudioCapturerChangeInfoArray
.
length
;
i
++
)
{
console
.
info
(
`StreamId for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
streamId
}
`
);
console
.
info
(
`ClientUid for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
clientUid
}
`
);
console
.
info
(
`Source for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
capturerInfo
.
source
}
`
);
console
.
info
(
`Flag
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
capturerInfo
.
capturerFlags
}
`
);
console
.
info
(
`State for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
capturerState
}
`
);
for
(
let
j
=
0
;
j
<
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
.
length
;
j
++
)
{
console
.
info
(
`Id:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
id
}
`
);
console
.
info
(
`Type:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
deviceType
}
`
);
console
.
info
(
`Role:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
deviceRole
}
`
);
console
.
info
(
`Name:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
name
}
`
);
console
.
info
(
`Address:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
address
}
`
);
console
.
info
(
`SampleRates:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
sampleRates
[
0
]}
`
);
console
.
info
(
`ChannelCounts
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
channelCounts
[
0
]}
`
);
console
.
info
(
`ChannelMask:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
channelMasks
}
`
);
async
function
getCurrentAudioCapturerInfoArray
(){
await
audioStreamManager
.
getCurrentAudioCapturerInfoArray
().
then
(
function
(
AudioCapturerChangeInfoArray
)
{
console
.
info
(
'
getCurrentAudioCapturerInfoArray **** Get Promise Called ****
'
);
if
(
AudioCapturerChangeInfoArray
!=
null
)
{
for
(
let
i
=
0
;
i
<
AudioCapturerChangeInfoArray
.
length
;
i
++
)
{
console
.
info
(
`StreamId for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
streamId
}
`
);
console
.
info
(
`ClientUid for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
clientUid
}
`
);
console
.
info
(
`Source for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
capturerInfo
.
source
}
`
);
console
.
info
(
`Flag
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
capturerInfo
.
capturerFlags
}
`
);
console
.
info
(
`State for
${
i
}
is:
${
AudioCapturerChangeInfoArray
[
i
].
capturerState
}
`
);
for
(
let
j
=
0
;
j
<
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
.
length
;
j
++
)
{
console
.
info
(
`Id:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
id
}
`
);
console
.
info
(
`Type:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
deviceType
}
`
);
console
.
info
(
`Role:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
deviceRole
}
`
);
console
.
info
(
`Name:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
name
}
`
);
console
.
info
(
`Address:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
address
}
`
);
console
.
info
(
`SampleRates:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
sampleRates
[
0
]}
`
);
console
.
info
(
`ChannelCounts
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
channelCounts
[
0
]}
`
);
console
.
info
(
`ChannelMask:
${
i
}
:
${
AudioCapturerChangeInfoArray
[
i
].
deviceDescriptors
[
j
].
channelMasks
}
`
);
}
}
}
}
}).
catch
((
err
)
=>
{
console
.
error
(
`getCurrentAudioCapturerInfoArray :ERROR:
${
err
}
`
);
}
);
}
).
catch
((
err
)
=>
{
console
.
error
(
`getCurrentAudioCapturerInfoArray :ERROR:
${
err
}
`
);
}
);
}
```
### on('audioRendererChange')<sup>9+</sup>
...
...
@@ -3143,17 +2903,6 @@ on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArr
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
audioStreamManager
.
on
(
'
audioRendererChange
'
,
(
AudioRendererChangeInfoArray
)
=>
{
for
(
let
i
=
0
;
i
<
AudioRendererChangeInfoArray
.
length
;
i
++
)
{
let
AudioRendererChangeInfo
=
AudioRendererChangeInfoArray
[
i
];
...
...
@@ -3195,17 +2944,6 @@ off(type: "audioRendererChange");
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
audioStreamManager
.
off
(
'
audioRendererChange
'
);
console
.
info
(
'
######### RendererChange Off is called #########
'
);
```
...
...
@@ -3228,17 +2966,6 @@ on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArr
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
audioStreamManager
.
on
(
'
audioCapturerChange
'
,
(
AudioCapturerChangeInfoArray
)
=>
{
for
(
let
i
=
0
;
i
<
AudioCapturerChangeInfoArray
.
length
;
i
++
)
{
console
.
info
(
`## CapChange on is called for element
${
i
}
##`
);
...
...
@@ -3279,17 +3006,6 @@ off(type: "audioCapturerChange");
**示例:**
```
js
var
audioManager
=
audio
.
getAudioManager
();
let
audioStreamManager
;
audioManager
.
getStreamManager
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getStreamManager : Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getStreamManager : Success : SUCCESS
'
);
audioStreamManager
=
data
;
}
});
audioStreamManager
.
off
(
'
audioCapturerChange
'
);
console
.
info
(
'
######### CapturerChange Off is called #########
'
);
...
...
@@ -3416,7 +3132,6 @@ off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
| type | string | 是 | 订阅的事件的类型。支持事件:'deviceChange' |
| deviceFlag |
[
DeviceFlag
](
#deviceflag
)
| 是 | 设备类型的flag。 |
| callback | Callback
<
[
DeviceChangeAction
](
#devicechangeaction
)
>
| 否 | 获取设备更新详情。 |
**示例:**
...
...
@@ -3426,9 +3141,8 @@ var audioManager = audio.getAudioManager();
audioManager
.
getRoutingManager
((
err
,
AudioRoutingManager
)
=>
{
if
(
err
)
{
console
.
error
(
`AudioFrameworkTest:Callback:failed to get RoutingManager
${
err
}
`
);
}
else
{
AudioRoutingManager
.
off
(
'
deviceChange
'
,
audio
.
DeviceFlag
.
OUTPUT_DEVICES_FLAG
,
(
deviceChanged
)
=>
{
}
else
{
AudioRoutingManager
.
off
(
'
deviceChange
'
,
(
deviceChanged
)
=>
{
console
.
info
(
'
Should be no callback.
'
);
});
}
...
...
@@ -5041,6 +4755,11 @@ var audioCapturerInfo = {
capturerFlags
:
0
}
var
audioCapturerOptions
=
{
streamInfo
:
audioStreamInfo
,
capturerInfo
:
audioCapturerInfo
}
var
audioCapturer
;
audio
.
createAudioCapturer
(
audioCapturerOptions
).
then
((
data
)
=>
{
audioCapturer
=
data
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录