Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
549349b2
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看板
未验证
提交
549349b2
编写于
5月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!4231 翻译完成:4094 【轻量级 PR】:fix issue
Merge pull request !4231 from wusongqing/TR4094
上级
54e8c77f
912321fa
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
27 addition
and
27 deletion
+27
-27
en/application-dev/reference/apis/js-apis-medialibrary.md
en/application-dev/reference/apis/js-apis-medialibrary.md
+27
-27
未找到文件。
en/application-dev/reference/apis/js-apis-medialibrary.md
浏览文件 @
549349b2
# Media Library Management
# Media Library Management
>
![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
**NOTE**<br>
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
...
@@ -208,7 +208,7 @@ async function example() {
...
@@ -208,7 +208,7 @@ async function example() {
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
const
path
=
await
media
.
getPublicDirectory
(
DIR_IMAGE
);
const
path
=
await
media
.
getPublicDirectory
(
DIR_IMAGE
);
media
Library
.
createAsset
(
mediaType
,
'imageCallBack.jpg'
,
path
+
'myPicture/'
,
(
err
,
fileAsset
)
=>
{
media
.
createAsset
(
mediaType
,
'imageCallBack.jpg'
,
path
+
'myPicture/'
,
(
err
,
fileAsset
)
=>
{
if
(
fileAsset
!=
undefined
)
{
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'createAsset successfully, message = '
+
err
);
console
.
info
(
'createAsset successfully, message = '
+
err
);
}
else
{
}
else
{
...
@@ -250,7 +250,7 @@ async function example() {
...
@@ -250,7 +250,7 @@ async function example() {
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
const
path
=
await
media
.
getPublicDirectory
(
DIR_IMAGE
);
const
path
=
await
media
.
getPublicDirectory
(
DIR_IMAGE
);
media
Library
.
createAsset
(
mediaType
,
"image01.jpg"
,
path
+
'myPicture/'
)
.
then
(
function
(
asset
)
{
media
.
createAsset
(
mediaType
,
"image01.jpg"
,
path
+
'myPicture/'
)
.
then
(
function
(
asset
)
{
console
.
info
(
"createAsset successfully:"
+
JSON
.
stringify
(
asset
));
console
.
info
(
"createAsset successfully:"
+
JSON
.
stringify
(
asset
));
})
.
catch
(
function
(
err
){
})
.
catch
(
function
(
err
){
console
.
info
(
"createAsset failed with error:"
+
err
);
console
.
info
(
"createAsset failed with error:"
+
err
);
...
@@ -720,7 +720,7 @@ Provides APIs for encapsulating file asset attributes.
...
@@ -720,7 +720,7 @@ Provides APIs for encapsulating file asset attributes.
**System capability**
: SystemCapability.Multimedia.MediaLibrary.Core
**System capability**
: SystemCapability.Multimedia.MediaLibrary.Core
| Name
| Type | Readable | Writable | Description
|
| Name
| Type | Readable| Writable| Description
|
| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | Yes | No | File asset ID. |
| id | number | Yes | No | File asset ID. |
| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. |
| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. |
...
@@ -738,7 +738,7 @@ Provides APIs for encapsulating file asset attributes.
...
@@ -738,7 +738,7 @@ Provides APIs for encapsulating file asset attributes.
| audioAlbum
<sup>
8+
</sup>
| string | Yes | No | Audio album. |
| audioAlbum
<sup>
8+
</sup>
| string | Yes | No | Audio album. |
| width | number | Yes | No | Image width, in pixels. |
| width | number | Yes | No | Image width, in pixels. |
| height | number | Yes | No | Image height, in pixels. |
| height | number | Yes | No | Image height, in pixels. |
| orientation | number | Yes
| Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).
|
| orientation | number | Yes
| Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).
|
| duration
<sup>
8+
</sup>
| number | Yes | No | Duration, in seconds. |
| duration
<sup>
8+
</sup>
| number | Yes | No | Duration, in seconds. |
| albumId | number | Yes | No | ID of the album to which the file belongs. |
| albumId | number | Yes | No | ID of the album to which the file belongs. |
| albumUri
<sup>
8+
</sup>
| string | Yes | No | URI of the album to which the file belongs. |
| albumUri
<sup>
8+
</sup>
| string | Yes | No | URI of the album to which the file belongs. |
...
@@ -757,9 +757,9 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal
...
@@ -757,9 +757,9 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal
**Parameters**
**Parameters**
|
Parameter | Type | Mandatory | Description
|
|
Name | Type | Mandatory | Description
|
| -------- | ---------------------------- | ---- | ------------------- |
| -------- | ---------------------------- | ---- | ------------------- |
| callback | AsyncCallback
<
boolean
>
| Yes
| Callback used to return whether the file asset is a directory.
|
| callback | AsyncCallback
<
boolean
>
| Yes
| Callback used to return whether the file asset is a directory.
|
**Example**
**Example**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录