Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6a8844f2
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6a8844f2
编写于
3月 10, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 10, 2023
浏览文件
操作
浏览文件
下载
差异文件
!15843 挑单monthly,资料示例代码增加fdSrc方式初始化资源文件示例
Merge pull request !15843 from zengyawen/cherry-pick-1678430430
上级
709adc0a
9ca1a1f4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
33 deletion
+46
-33
zh-cn/application-dev/media/avplayer-playback.md
zh-cn/application-dev/media/avplayer-playback.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-media.md
zh-cn/application-dev/reference/apis/js-apis-media.md
+39
-26
未找到文件。
zh-cn/application-dev/media/avplayer-playback.md
浏览文件 @
6a8844f2
...
...
@@ -299,13 +299,13 @@ export class AVPlayerDemo {
async
avPlayerDemo
()
{
// 创建avPlayer实例对象
this
.
avPlayer
=
await
media
.
createAVPlayer
()
let
f
dPath
=
'
fd://
'
let
pathDir
=
"
/data/storage/el2/base/haps/entry/files
"
// pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
//
path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上
let
path
=
pathDir
+
'
/H264_AAC.mp4
'
let
file
=
await
fs
.
open
(
path
)
fdPath
=
fdPath
+
''
+
file
.
fd
this
.
avPlayer
.
url
=
fdPath
let
f
ileDescriptor
=
undefined
// 使用资源管理模块的getRawFileDescriptor获取集成在应用中的媒体资源,并使用AVPlayer的fdSrc属性完成媒体资源初始化
//
其中的参数fd/offset/length定义请查看媒体API文档,globalThis.abilityContext参数为系统环境变量,在系统启动时在主界面保存为全局变量
await
globalThis
.
abilityContext
.
resourceManager
.
getRawFileDescriptor
(
'
H264_AAC.mp4
'
).
then
((
value
)
=>
{
fileDescriptor
=
{
fd
:
value
.
fd
,
offset
:
value
.
offset
,
length
:
value
.
length
}
})
this
.
avPlayer
.
fdSrc
=
fileDescriptor
}
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-media.md
浏览文件 @
6a8844f2
...
...
@@ -925,6 +925,14 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void
**示例:**
```
js
printfDescription
(
obj
)
{
for
(
let
item
in
obj
)
{
let
property
=
obj
[
item
];
console
.
info
(
'
audio key is
'
+
item
);
console
.
info
(
'
audio value is
'
+
property
);
}
}
avPlayer
.
getTrackDescription
((
error
,
arrList
)
=>
{
if
((
arrList
)
!=
null
)
{
for
(
let
i
=
0
;
i
<
arrList
.
length
;
i
++
)
{
...
...
@@ -962,6 +970,14 @@ getTrackDescription(): Promise\<Array\<MediaDescription>>
```
js
let
arrayDescription
;
printfDescription
(
obj
)
{
for
(
let
item
in
obj
)
{
let
property
=
obj
[
item
];
console
.
info
(
'
audio key is
'
+
item
);
console
.
info
(
'
audio value is
'
+
property
);
}
}
avPlayer
.
getTrackDescription
().
then
((
arrList
)
=>
{
if
(
arrList
!=
null
)
{
arrayDescription
=
arrList
;
...
...
@@ -1058,7 +1074,7 @@ setSpeed(speed: PlaybackSpeed): void
**示例:**
```
js
avPlayer
.
setSpeed
(
media
.
AVPlayer
Speed
.
SPEED_FORWARD_2_00_X
)
avPlayer
.
setSpeed
(
media
.
Playback
Speed
.
SPEED_FORWARD_2_00_X
)
```
### on('speedDone')<sup>9+</sup><a name = speedDone_on></a>
...
...
@@ -1551,6 +1567,8 @@ on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void
**示例:**
```
js
import
audio
from
'
@ohos.multimedia.audio
'
;
avPlayer
.
on
(
'
audioInterrupt
'
,
(
info
:
audio
.
InterruptEvent
)
=>
{
console
.
info
(
'
audioInterrupt success,and InterruptEvent info is:
'
+
info
)
})
...
...
@@ -1740,7 +1758,7 @@ let AVRecorderConfig = {
location
:
{
latitude
:
30
,
longitude
:
130
}
}
AV
Recorder
.
prepare
(
AVRecorderConfig
,
(
err
)
=>
{
av
Recorder
.
prepare
(
AVRecorderConfig
,
(
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
prepare success
'
);
}
else
{
...
...
@@ -1811,7 +1829,7 @@ let AVRecorderConfig = {
location
:
{
latitude
:
30
,
longitude
:
130
}
}
AV
Recorder
.
prepare
(
AVRecorderConfig
).
then
(()
=>
{
av
Recorder
.
prepare
(
AVRecorderConfig
).
then
(()
=>
{
console
.
info
(
'
prepare success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
prepare failed and catch error is
'
+
err
.
message
);
...
...
@@ -1852,7 +1870,7 @@ getInputSurface(callback: AsyncCallback\<string>): void
```
js
let
surfaceID
=
null
;
// 该surfaceID用于传递给相机接口创造videoOutput
AV
Recorder
.
getInputSurface
((
err
,
surfaceId
)
=>
{
av
Recorder
.
getInputSurface
((
err
,
surfaceId
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
...
...
@@ -1861,8 +1879,6 @@ AVRecorder.getInputSurface((err, surfaceId) => {
}
});
// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID);
```
### getInputSurface<sup>9+</sup>
...
...
@@ -1898,14 +1914,12 @@ getInputSurface(): Promise\<string>
```
js
let
surfaceID
=
null
;
// 该surfaceID用于传递给相机接口创造videoOutput
AV
Recorder
.
getInputSurface
().
then
((
surfaceId
)
=>
{
av
Recorder
.
getInputSurface
().
then
((
surfaceId
)
=>
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
}).
catch
((
err
)
=>
{
console
.
info
(
'
getInputSurface failed and catch error is
'
+
err
.
message
);
});
// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID);
```
### start<sup>9+</sup><a name=avrecorder_start></a>
...
...
@@ -1937,7 +1951,7 @@ start(callback: AsyncCallback\<void>): void
**示例:**
```
js
AV
Recorder
.
start
((
err
)
=>
{
av
Recorder
.
start
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
start AVRecorder success
'
);
}
else
{
...
...
@@ -1975,7 +1989,7 @@ start(): Promise\<void>
**示例:**
```
js
AV
Recorder
.
start
().
then
(()
=>
{
av
Recorder
.
start
().
then
(()
=>
{
console
.
info
(
'
start AVRecorder success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
start AVRecorder failed and catch error is
'
+
err
.
message
);
...
...
@@ -2011,7 +2025,7 @@ pause(callback: AsyncCallback\<void>): void
**示例:**
```
js
AV
Recorder
.
pause
((
err
)
=>
{
av
Recorder
.
pause
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
pause AVRecorder success
'
);
}
else
{
...
...
@@ -2049,7 +2063,7 @@ pause(): Promise\<void>
**示例:**
```
js
AV
Recorder
.
pause
().
then
(()
=>
{
av
Recorder
.
pause
().
then
(()
=>
{
console
.
info
(
'
pause AVRecorder success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
pause AVRecorder failed and catch error is
'
+
err
.
message
);
...
...
@@ -2085,7 +2099,7 @@ resume(callback: AsyncCallback\<void>): void
**示例:**
```
js
AV
Recorder
.
resume
((
err
)
=>
{
av
Recorder
.
resume
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
resume AVRecorder success
'
);
}
else
{
...
...
@@ -2123,7 +2137,7 @@ resume(): Promise\<void>
**示例:**
```
js
AV
Recorder
.
resume
().
then
(()
=>
{
av
Recorder
.
resume
().
then
(()
=>
{
console
.
info
(
'
resume AVRecorder success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
resume AVRecorder failed and catch error is
'
+
err
.
message
);
...
...
@@ -2161,7 +2175,7 @@ stop(callback: AsyncCallback\<void>): void
**示例:**
```
js
AV
Recorder
.
stop
((
err
)
=>
{
av
Recorder
.
stop
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
stop AVRecorder success
'
);
}
else
{
...
...
@@ -2201,7 +2215,7 @@ stop(): Promise\<void>
**示例:**
```
js
AV
Recorder
.
stop
().
then
(()
=>
{
av
Recorder
.
stop
().
then
(()
=>
{
console
.
info
(
'
stop AVRecorder success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
stop AVRecorder failed and catch error is
'
+
err
.
message
);
...
...
@@ -2236,7 +2250,7 @@ reset(callback: AsyncCallback\<void>): void
**示例:**
```
js
AV
Recorder
.
reset
((
err
)
=>
{
av
Recorder
.
reset
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
reset AVRecorder success
'
);
}
else
{
...
...
@@ -2273,7 +2287,7 @@ reset(): Promise\<void>
**示例:**
```
js
AV
Recorder
.
reset
().
then
(()
=>
{
av
Recorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
reset AVRecorder success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
reset AVRecorder failed and catch error is
'
+
err
.
message
);
...
...
@@ -2307,7 +2321,7 @@ release(callback: AsyncCallback\<void>): void
**示例:**
```
js
AV
Recorder
.
release
((
err
)
=>
{
av
Recorder
.
release
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
release AVRecorder success
'
);
}
else
{
...
...
@@ -2343,7 +2357,7 @@ release(): Promise\<void>
**示例:**
```
js
AV
Recorder
.
release
().
then
(()
=>
{
av
Recorder
.
release
().
then
(()
=>
{
console
.
info
(
'
release AVRecorder success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
release AVRecorder failed and catch error is
'
+
err
.
message
);
...
...
@@ -2368,9 +2382,8 @@ on(type: 'stateChange', callback: (state: AVRecorderState, reason: StateChangeRe
**示例:**
```
js
AV
Recorder
.
on
(
'
stateChange
'
,
async
(
state
,
reason
)
=>
{
av
Recorder
.
on
(
'
stateChange
'
,
async
(
state
,
reason
)
=>
{
console
.
info
(
'
case state has changed, new state is :
'
+
state
+
'
,and new reason is :
'
+
reason
);
}
});
```
...
...
@@ -2391,7 +2404,7 @@ off(type: 'stateChange'): void
**示例:**
```
js
AV
Recorder
.
off
(
'
stateChange
'
);
av
Recorder
.
off
(
'
stateChange
'
);
```
### on('error')<sup>9+</sup><a name=avrecorder_onerror></a>
...
...
@@ -2423,7 +2436,7 @@ on(type: 'error', callback: ErrorCallback): void
**示例:**
```
js
AV
Recorder
.
on
(
'
error
'
,
(
err
)
=>
{
av
Recorder
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
info
(
'
case avRecorder.on(error) called, errMessage is
'
+
err
.
message
);
});
```
...
...
@@ -2454,7 +2467,7 @@ off(type: 'error'): void
**示例:**
```
js
AV
Recorder
.
off
(
'
error
'
);
av
Recorder
.
off
(
'
error
'
);
```
## AVRecorderState<sup>9+</sup>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录