Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
912321fa
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看板
提交
912321fa
编写于
5月 23, 2022
作者:
W
wusongqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updated docs
Signed-off-by:
N
wusongqing
<
wusongqing@huawei.com
>
上级
e122fa58
变更
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
浏览文件 @
912321fa
# 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,29 +720,29 @@ Provides APIs for encapsulating file asset attributes.
...
@@ -720,29 +720,29 @@ 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.
|
| mimeType | string | Yes
| No | Extended file attributes.
|
| mimeType | string | Yes
| No | Extended file attributes.
|
| mediaType
<sup>
8+
</sup>
|
[
MediaType
](
#mediatype8
)
| Yes
| No | Media type.
|
| mediaType
<sup>
8+
</sup>
|
[
MediaType
](
#mediatype8
)
| Yes
| No | Media type.
|
| displayName | string | Yes
| Yes | Display file name, including the file name extension.
|
| displayName | string | Yes
| Yes | Display file name, including the file name extension.
|
| title | string | Yes
| Yes | Title in the file.
|
| title | string | Yes
| Yes | Title in the file.
|
| relativePath
<sup>
8+
</sup>
| string | Yes
| Yes | Relative public directory of the file.
|
| relativePath
<sup>
8+
</sup>
| string | Yes
| Yes | Relative public directory of the file.
|
| parent
<sup>
8+
</sup>
| number | Yes
| No | Parent directory ID.
|
| parent
<sup>
8+
</sup>
| number | Yes
| No | Parent directory ID.
|
| size | number | Yes
| No | File size, in bytes.
|
| size | number | Yes
| No | File size, in bytes.
|
| dateAdded | number | Yes
| No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.)
|
| dateAdded | number | Yes
| No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.)
|
| dateModified | number | Yes
| No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.)
|
| dateModified | number | Yes
| No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.)
|
| dateTaken | number | Yes
| No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.)
|
| dateTaken | number | Yes
| No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.)
|
| artist
<sup>
8+
</sup>
| string | Yes
| No | Artist of the file.
|
| artist
<sup>
8+
</sup>
| string | Yes
| No | Artist of the file.
|
| 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.
|
| albumName | string | Yes
| No | Name of the album to which the file belongs.
|
| albumName | string | Yes
| No | Name of the album to which the file belongs.
|
### isDirectory<sup>8+</sup>
### isDirectory<sup>8+</sup>
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录