Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
5f2b7556
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看板
提交
5f2b7556
编写于
3月 03, 2022
作者:
P
panqiangbiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code issue
Signed-off-by:
N
panqiangbiao
<
panqiangbiao@huawei.com
>
上级
6edecc8c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
31 deletion
+27
-31
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
+27
-31
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
浏览文件 @
5f2b7556
...
...
@@ -137,7 +137,7 @@ on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|
```
medialibrary.on('imageChange', () => {
this.sendNotify('image');
// image file had changed, do something
})
```
## medialibrary.off
...
...
@@ -163,7 +163,7 @@ off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'
```
medialibrary.off('imageChange', () => {
this.sendNotify('image');
// stop listening success
})
```
...
...
@@ -183,7 +183,7 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string, cal
| ------------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| mediaType |
[
MediaType
](
#MediaType
)
| 是 | 媒体类型 |
| displayName | string | 是 | 展示文件名 |
| relativePath | string | 是 | 相对路径,可以通过getPublicDirectory获取不同类型媒体文件的一层目录的relative path |
| relativePath | string | 是 | 相对
公共目录
路径,可以通过getPublicDirectory获取不同类型媒体文件的一层目录的relative path |
| callback | AsyncCallback
<
[
FileAsset
](
#FileAsset
)
>
| 是 | 异步获取媒体数据FileAsset之后的回调 |
**示例:**
...
...
@@ -262,7 +262,7 @@ getPublicDirectory(type: DirectoryType, callback: AsyncCallback<string>): void;
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
media.getPublicDirectory(DIR_CAMERA,(err, dicResult) => {
if (dicResult == 'camera/') {
console.info('MediaLibraryTest : getPublicDirectory
passed
');
console.info('MediaLibraryTest : getPublicDirectory');
} else {
console.info('MediaLibraryTest : getPublicDirectory failed');
}
...
...
@@ -297,7 +297,7 @@ getPublicDirectory(type: DirectoryType): Promise<string>;
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
const dicResult = await media.getPublicDirectory(DIR_CAMERA);
if (dicResult == 'camera/') {
console.info('MediaLibraryTest : getPublicDirectory
passed
');
console.info('MediaLibraryTest : getPublicDirectory');
} else {
console.info('MediaLibraryTest : getPublicDirectory failed');
}
...
...
@@ -327,17 +327,15 @@ let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
medialibrary.AlbumNoArgsfetchOp, (err, albumList) => {
medialibrary.
getAlbums(
AlbumNoArgsfetchOp, (err, albumList) => {
if (albumList != undefined) {
const album = albumList[0];
console.info('album.albumName = ' + album.albumName);
console.info('album.count = ' + album.count);
done();
} else {
console.info('getAlbum fail, message = ' + err);
done();
}
})
;
})
```
## medialibrary.getAlbums
...
...
@@ -580,11 +578,11 @@ let mediaType = mediaLibrary.MediaType.IMAGE;
let path = "Pictures/";
asset = await media.createAsset(mediaType, "image00003.jpg", path);
asset.open('rw', (openError, fd) => {
if(fd > 0){
asset.close(fd);
}else{
console.info('File Open Failed!' + openError);
}
if(fd > 0){
asset.close(fd);
}else{
console.info('File Open Failed!' + openError);
}
});
```
...
...
@@ -617,11 +615,11 @@ let mediaType = mediaLibrary.MediaType.IMAGE;
let path = "Pictures/";
asset = await media.createAsset(mediaType, "image00003.jpg", path);
asset.open('rw').then((openError, fd) => {
if(fd > 0){
asset.close(fd);
}else{
console.info('File Open Failed!' + openError);
}
if(fd > 0){
asset.close(fd);
}else{
console.info('File Open Failed!' + openError);
}
});
```
...
...
@@ -1072,15 +1070,13 @@ const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.isTrash(isTrashCallBack);
function isTrashCallBack(err, isTrash) {
if (isTrash == true) {
console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash);
asset.trash(true, trashCallBack);
} else {
console.info('MediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err);
console.info('MediaLibraryTest : ASSET_CALLBACK isTrash : FAIL');
}
if (isTrash == true) {
console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash);
asset.trash(true, trashCallBack);
} else {
console.info('MediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err);
console.info('MediaLibraryTest : ASSET_CALLBACK isTrash : FAIL');
}
}
```
...
...
@@ -1732,7 +1728,7 @@ FileAsset
| mediaType | MediaType | 是 | 否 | 媒体类型 |
| displayName | string | 是 | 是 | 显示文件名 |
| title | string | 是 | 是 | 文件标题 |
| relativePath | string | 是 | 是 | 相对路径 |
| relativePath | string | 是 | 是 | 相对
公共目录
路径 |
| parent | number | 是 | 否 | 父目录id |
| size | number | 是 | 否 | 文件大小(单位:字节) |
| dateAdded | number | 是 | 否 | 添加日期(添加文件时间到1970年1月1日的秒数值) |
...
...
@@ -1785,7 +1781,7 @@ FileKey
| 名称 | 默认值 | 描述 |
| ------------- | ------------------- | ------------------------------------------------------ |
| ID | file_id | 文件编号 |
| RELATIVE_PATH | relative_path | 相对路径 |
| RELATIVE_PATH | relative_path | 相对
公共目录
路径 |
| DISPLAY_NAME | display_name | 显示名字 |
| PARENT | parent | 父目录id |
| MIME_TYPE | mime_type | 文件扩展属性 |
...
...
@@ -1840,7 +1836,7 @@ DeviceType
| 名称 | 类型 | 可读 | 可写 | 必填 |说明 |
| ------------- | ------------- | ---- | ---- | ---- |---------------- |
| selections | string | 是 | 是 |是 | 检索条件 |
| selectionArgs | Array
<string>
| 是 | 是 |是 | 检索条件的值 |
| selectionArgs | Array
<
string
>
| 是 | 是 |是 | 检索条件的值 |
| order | string | 是 | 是 | 否 |检索结果排序方式 |
| uri | string | 是 | 是 | 否 |文件URI |
| networkId | string | 是 | 是 | 否 |注册设备网络ID |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录