Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c0c4b527
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看板
未验证
提交
c0c4b527
编写于
6月 18, 2022
作者:
Mr-YX
提交者:
Gitee
6月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Signed-off-by: mr-yx <496043997@qq.com>
上级
afdc4a0f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
101 addition
and
106 deletion
+101
-106
zh-cn/application-dev/media/audio-overview.md
zh-cn/application-dev/media/audio-overview.md
+0
-1
zh-cn/application-dev/media/audio-renderer.md
zh-cn/application-dev/media/audio-renderer.md
+91
-95
zh-cn/application-dev/media/camera.md
zh-cn/application-dev/media/camera.md
+10
-10
未找到文件。
zh-cn/application-dev/media/audio-overview.md
浏览文件 @
c0c4b527
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
音频模块支持音频业务的开发,提供音频相关的功能,主要包括音频播放、音量管理等。
音频模块支持音频业务的开发,提供音频相关的功能,主要包括音频播放、音量管理等。
## 基本概念
## 基本概念
-
**采样**
<br/>
-
**采样**
<br/>
...
...
zh-cn/application-dev/media/audio-renderer.md
浏览文件 @
c0c4b527
...
@@ -22,8 +22,6 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
...
@@ -22,8 +22,6 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考
[
音频管理API文档AudioRenderer
](
../reference/apis/js-apis-audio.md#audiorenderer8
)
。
为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考
[
音频管理API文档AudioRenderer
](
../reference/apis/js-apis-audio.md#audiorenderer8
)
。
## 开发步骤
## 开发步骤
1.
使用createAudioRenderer()创建一个AudioRenderer实例。
1.
使用createAudioRenderer()创建一个AudioRenderer实例。
...
@@ -33,7 +31,7 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
...
@@ -33,7 +31,7 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
var
audioStreamInfo
=
{
var
audioStreamInfo
=
{
samplingRate
:
audio
.
AudioSamplingRate
.
SAMPLE_RATE_44100
,
samplingRate
:
audio
.
AudioSamplingRate
.
SAMPLE_RATE_44100
,
channels
:
audio
.
AudioChannel
.
CHANNEL_1
,
channels
:
audio
.
AudioChannel
.
CHANNEL_1
,
sampleFormat
:
audio
.
AudioSampleFormat
.
SAMPLE_FORMAT_S16LE
,
sampleFormat
:
audio
.
AudioSampleFormat
.
SAMPLE_FORMAT_S16LE
,
encodingType
:
audio
.
AudioEncodingType
.
ENCODING_TYPE_RAW
encodingType
:
audio
.
AudioEncodingType
.
ENCODING_TYPE_RAW
}
}
...
@@ -60,49 +58,49 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
...
@@ -60,49 +58,49 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
在音频中断的情况下,应用可能会碰到音频数据写入失败的问题。所以建议不感知、不处理中断的应用在写入音频数据前,使用audioRenderer.state检查播放器状态。而订阅音频中断事件,可以获取到更多详细信息,具体可参考
[
InterruptEvent
](
../reference/apis/js-apis-audio.md#interruptevent9
)
。
在音频中断的情况下,应用可能会碰到音频数据写入失败的问题。所以建议不感知、不处理中断的应用在写入音频数据前,使用audioRenderer.state检查播放器状态。而订阅音频中断事件,可以获取到更多详细信息,具体可参考
[
InterruptEvent
](
../reference/apis/js-apis-audio.md#interruptevent9
)
。
```
js
```
js
audioRenderer
.
on
(
'
interrupt
'
,
(
interruptEvent
)
=>
{
audioRenderer
.
on
(
'
interrupt
'
,
(
interruptEvent
)
=>
{
console
.
info
(
'
InterruptEvent Received
'
);
console
.
info
(
'
InterruptEvent Received
'
);
console
.
info
(
'
InterruptType:
'
+
interruptEvent
.
eventType
);
console
.
info
(
'
InterruptType:
'
+
interruptEvent
.
eventType
);
console
.
info
(
'
InterruptForceType:
'
+
interruptEvent
.
forceType
);
console
.
info
(
'
InterruptForceType:
'
+
interruptEvent
.
forceType
);
console
.
info
(
'
AInterruptHint:
'
+
interruptEvent
.
hintType
);
console
.
info
(
'
AInterruptHint:
'
+
interruptEvent
.
hintType
);
if
(
interruptEvent
.
forceType
==
audio
.
InterruptForceType
.
INTERRUPT_FORCE
)
{
if
(
interruptEvent
.
forceType
==
audio
.
InterruptForceType
.
INTERRUPT_FORCE
)
{
switch
(
interruptEvent
.
hintType
)
{
switch
(
interruptEvent
.
hintType
)
{
// Force Pause: Action was taken by framework.
// Force Pause: Action was taken by framework.
// Halt the write calls to avoid data loss.
// Halt the write calls to avoid data loss.
case
audio
.
InterruptHint
.
INTERRUPT_HINT_PAUSE
:
case
audio
.
InterruptHint
.
INTERRUPT_HINT_PAUSE
:
isPlay
=
false
;
isPlay
=
false
;
break
;
break
;
// Force Stop: Action was taken by framework.
// Force Stop: Action was taken by framework.
// Halt the write calls to avoid data loss.
// Halt the write calls to avoid data loss.
case
audio
.
InterruptHint
.
INTERRUPT_HINT_STOP
:
case
audio
.
InterruptHint
.
INTERRUPT_HINT_STOP
:
isPlay
=
false
;
isPlay
=
false
;
break
;
break
;
// Force Duck: Action was taken by framework,
// Force Duck: Action was taken by framework,
// just notifying the app that volume has been reduced.
// just notifying the app that volume has been reduced.
case
audio
.
InterruptHint
.
INTERRUPT_HINT_DUCK
:
case
audio
.
InterruptHint
.
INTERRUPT_HINT_DUCK
:
break
;
break
;
// Force Unduck: Action was taken by framework,
// Force Unduck: Action was taken by framework,
// just notifying the app that volume has been restored.
// just notifying the app that volume has been restored.
case
audio
.
InterruptHint
.
INTERRUPT_HINT_UNDUCK
:
case
audio
.
InterruptHint
.
INTERRUPT_HINT_UNDUCK
:
break
;
break
;
}
}
}
else
if
(
interruptEvent
.
forceType
==
audio
.
InterruptForceType
.
INTERRUPT_SHARE
)
{
}
else
if
(
interruptEvent
.
forceType
==
audio
.
InterruptForceType
.
INTERRUPT_SHARE
)
{
switch
(
interruptEvent
.
hintType
)
{
switch
(
interruptEvent
.
hintType
)
{
// Share Resume: Action is to be taken by App.
// Share Resume: Action is to be taken by App.
// Resume the force paused stream if required.
// Resume the force paused stream if required.
case
audio
.
InterruptHint
.
INTERRUPT_HINT_RESUME
:
case
audio
.
InterruptHint
.
INTERRUPT_HINT_RESUME
:
startRenderer
();
startRenderer
();
break
;
break
;
// Share Pause: Stream has been interrupted,
// Share Pause: Stream has been interrupted,
// It can choose to pause or play concurrently.
// It can choose to pause or play concurrently.
case
audio
.
InterruptHint
.
INTERRUPT_HINT_PAUSE
:
case
audio
.
InterruptHint
.
INTERRUPT_HINT_PAUSE
:
isPlay
=
false
;
isPlay
=
false
;
pauseRenderer
();
pauseRenderer
();
break
;
break
;
}
}
}
}
});
});
```
```
3.
调用start()方法来启动/恢复播放任务。
3.
调用start()方法来启动/恢复播放任务。
...
@@ -180,38 +178,38 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
...
@@ -180,38 +178,38 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
5.
(可选)调用pause()方法或stop()方法暂停/停止渲染音频数据。
5.
(可选)调用pause()方法或stop()方法暂停/停止渲染音频数据。
```
js
```
js
async
function
pauseRenderer
()
{
async
function
pauseRenderer
()
{
var
state
=
audioRenderer
.
state
;
var
state
=
audioRenderer
.
state
;
if
(
state
!=
audio
.
AudioState
.
STATE_RUNNING
)
{
if
(
state
!=
audio
.
AudioState
.
STATE_RUNNING
)
{
console
.
info
(
'
Renderer is not running
'
);
console
.
info
(
'
Renderer is not running
'
);
return
;
return
;
}
}
await
audioRenderer
.
pause
();
await
audioRenderer
.
pause
();
state
=
audioRenderer
.
state
;
state
=
audioRenderer
.
state
;
if
(
state
==
audio
.
AudioState
.
STATE_PAUSED
)
{
if
(
state
==
audio
.
AudioState
.
STATE_PAUSED
)
{
console
.
info
(
'
Renderer paused
'
);
console
.
info
(
'
Renderer paused
'
);
}
else
{
}
else
{
console
.
error
(
'
Renderer pause failed
'
);
console
.
error
(
'
Renderer pause failed
'
);
}
}
}
}
async
function
stopRenderer
()
{
var
state
=
audioRenderer
.
state
;
if
(
state
!=
audio
.
AudioState
.
STATE_RUNNING
||
state
!=
audio
.
AudioState
.
STATE_PAUSED
)
{
console
.
info
(
'
Renderer is not running or paused
'
);
return
;
}
await
audioRenderer
.
stop
();
state
=
audioRenderer
.
state
;
async
function
stopRenderer
()
{
if
(
state
==
audio
.
AudioState
.
STATE_STOPPED
)
{
var
state
=
audioRenderer
.
state
;
console
.
info
(
'
Renderer stopped
'
);
if
(
state
!=
audio
.
AudioState
.
STATE_RUNNING
||
state
!=
audio
.
AudioState
.
STATE_PAUSED
)
{
}
else
{
console
.
info
(
'
Renderer is not running or paused
'
);
console
.
error
(
'
Renderer stop failed
'
);
return
;
}
}
await
audioRenderer
.
stop
();
state
=
audioRenderer
.
state
;
if
(
state
==
audio
.
AudioState
.
STATE_STOPPED
)
{
console
.
info
(
'
Renderer stopped
'
);
}
else
{
console
.
error
(
'
Renderer stop failed
'
);
}
}
}
```
```
...
@@ -220,22 +218,20 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
...
@@ -220,22 +218,20 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
AudioRenderer会使用大量的系统资源,所以请确保完成相关任务后,进行资源释放。
AudioRenderer会使用大量的系统资源,所以请确保完成相关任务后,进行资源释放。
```
js
```
js
async
function
releaseRenderer
()
{
async
function
releaseRenderer
()
{
if
(
state_
==
RELEASED
||
state_
==
NEW
)
{
if
(
state_
==
RELEASED
||
state_
==
NEW
)
{
console
.
info
(
'
Resourced already released
'
);
console
.
info
(
'
Resourced already released
'
);
return
;
return
;
}
}
await
audioRenderer
.
release
();
await
audioRenderer
.
release
();
state
=
audioRenderer
.
state
;
if
(
state
==
STATE_RELEASED
)
{
console
.
info
(
'
Renderer released
'
);
}
else
{
console
.
info
(
'
Renderer release failed
'
);
}
}
```
state
=
audioRenderer
.
state
;
\ No newline at end of file
if
(
state
==
STATE_RELEASED
)
{
console
.
info
(
'
Renderer released
'
);
}
else
{
console
.
info
(
'
Renderer release failed
'
);
}
}
```
\ No newline at end of file
zh-cn/application-dev/media/camera.md
浏览文件 @
c0c4b527
...
@@ -54,16 +54,16 @@ await cameraManager.getCameras((err, cameras) => {
...
@@ -54,16 +54,16 @@ await cameraManager.getCameras((err, cameras) => {
cameraArray
=
cameras
cameraArray
=
cameras
})
})
for
(
let
cameraIndex
=
0
;
cameraIndex
<
cameraArray
.
length
;
cameraIndex
)
{
for
(
let
cameraIndex
=
0
;
cameraIndex
<
cameraArray
.
length
;
cameraIndex
)
{
console
.
log
(
'
cameraId :
'
+
cameraArray
[
cameraIndex
].
cameraId
)
//获取相机ID
console
.
log
(
'
cameraId :
'
+
cameraArray
[
cameraIndex
].
cameraId
)
//获取相机ID
console
.
log
(
'
cameraPosition :
'
+
cameraArray
[
cameraIndex
].
cameraPosition
)
//获取相机位置
console
.
log
(
'
cameraPosition :
'
+
cameraArray
[
cameraIndex
].
cameraPosition
)
//获取相机位置
console
.
log
(
'
cameraType :
'
+
cameraArray
[
cameraIndex
].
cameraType
)
//获取相机类型
console
.
log
(
'
cameraType :
'
+
cameraArray
[
cameraIndex
].
cameraType
)
//获取相机类型
console
.
log
(
'
connectionType :
'
+
cameraArray
[
cameraIndex
].
connectionType
)
//获取相机连接类型
console
.
log
(
'
connectionType :
'
+
cameraArray
[
cameraIndex
].
connectionType
)
//获取相机连接类型
}
}
//创建相机输入流
//创建相机输入流
let
cameraInput
let
cameraInput
await
cameraManager
.
createCameraInput
(
cameraArray
[
0
].
cameraId
).
then
((
input
)
=>
{
await
cameraManager
.
createCameraInput
(
cameraArray
[
0
].
cameraId
).
then
((
input
)
=>
{
console
.
log
(
'
Promise returned with the CameraInput instance
'
);
console
.
log
(
'
Promise returned with the CameraInput instance
'
);
cameraInput
=
input
cameraInput
=
input
})
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录