Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
9f0a1055
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看板
提交
9f0a1055
编写于
3月 03, 2022
作者:
P
panqiangbiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code issue
Signed-off-by:
N
panqiangbiao
<
panqiangbiao@huawei.com
>
上级
85d98ae3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
309 addition
and
19 deletion
+309
-19
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
+309
-19
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
浏览文件 @
9f0a1055
...
@@ -264,7 +264,16 @@ deleteAsset(uri: string, callback: AsyncCallback<void>): void;
...
@@ -264,7 +264,16 @@ deleteAsset(uri: string, callback: AsyncCallback<void>): void;
**示例:**
**示例:**
```
```
medialibrary.deleteAsset(fileAsset.uri, (deleteAssetErr, deleteRows) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
medialibrary.deleteAsset(asset.uri, (deleteAssetErr, deleteRows) => {
// do something
// do something
});
});
```
```
...
@@ -294,6 +303,15 @@ deleteAsset(uri: string): Promise<void>;
...
@@ -294,6 +303,15 @@ deleteAsset(uri: string): Promise<void>;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
medialibrary.deleteAsset(asset.uri).then(()=>{
medialibrary.deleteAsset(asset.uri).then(()=>{
console.info("deleteAsset successfully");
console.info("deleteAsset successfully");
}).catch(function(err){
}).catch(function(err){
...
@@ -360,7 +378,7 @@ getPublicDirectory(type: DirectoryType): Promise<string>;
...
@@ -360,7 +378,7 @@ getPublicDirectory(type: DirectoryType): Promise<string>;
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
const dicResult = await media.getPublicDirectory(DIR_CAMERA);
const dicResult = await media.getPublicDirectory(DIR_CAMERA);
if (dicResult == 'camera/') {
if (dicResult == 'camera/') {
console.info('MediaLibraryTest : getPublicDirectory passed');
console.info('MediaLibraryTest : getPublicDirectory passed');
} else {
} else {
console.info('MediaLibraryTest : getPublicDirectory failed');
console.info('MediaLibraryTest : getPublicDirectory failed');
}
}
...
@@ -386,7 +404,21 @@ getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array<Album>
...
@@ -386,7 +404,21 @@ getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array<Album>
**示例:**
**示例:**
```
```
medialibrary.getAlbums(AlbumNoArgsfetchOp, getAlbumsCallBack);
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
medialibrary.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
## medialibrary.getAlbums
...
@@ -414,6 +446,10 @@ getAlbums(options: MediaFetchOptions): Promise<Array<Album>>;
...
@@ -414,6 +446,10 @@ getAlbums(options: MediaFetchOptions): Promise<Array<Album>>;
**示例:**
**示例:**
```
```
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
medialibrary.getAlbums(AlbumNoArgsfetchOp).then(function(albumList){
medialibrary.getAlbums(AlbumNoArgsfetchOp).then(function(albumList){
console.info("getAlbums successfully:"+ JSON.stringify(albumList));
console.info("getAlbums successfully:"+ JSON.stringify(albumList));
}).catch(function(err){
}).catch(function(err){
...
@@ -578,6 +614,15 @@ isDirectory(callback: AsyncCallback<boolean>): void;
...
@@ -578,6 +614,15 @@ isDirectory(callback: AsyncCallback<boolean>): void;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.isDirectory((err, isDirectory) => {
asset.isDirectory((err, isDirectory) => {
// do something
// do something
});
});
...
@@ -602,6 +647,15 @@ isDirectory():Promise<boolean>;
...
@@ -602,6 +647,15 @@ isDirectory():Promise<boolean>;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.isDirectory().then(function(isDirectory){
asset.isDirectory().then(function(isDirectory){
console.info("isDirectory result:"+ isDirectory);
console.info("isDirectory result:"+ isDirectory);
}).catch(function(err){
}).catch(function(err){
...
@@ -628,9 +682,18 @@ commitModify(callback: AsyncCallback<void>): void;
...
@@ -628,9 +682,18 @@ commitModify(callback: AsyncCallback<void>): void;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = ‘newtitle';
asset.title = ‘newtitle';
asset.commitModify(() => {
asset.commitModify(() => {
console.info('commitModify success');
console.info('commitModify success');
}
}
```
```
...
@@ -653,6 +716,15 @@ commitModify(): Promise<void>;
...
@@ -653,6 +716,15 @@ commitModify(): Promise<void>;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.title = ‘newtitle';
asset.title = ‘newtitle';
asset.commitModify();
asset.commitModify();
```
```
...
@@ -746,7 +818,16 @@ close(fd: number, callback: AsyncCallback<void>): void;
...
@@ -746,7 +818,16 @@ close(fd: number, callback: AsyncCallback<void>): void;
**示例:**
**示例:**
```
```
fileAsset.close(fd, (closeErr) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.close(fd, (closeErr) => {
if (closeErr != undefined) {
if (closeErr != undefined) {
console.info('MediaLibraryTest : close : FAIL ' + closeErr.message);
console.info('MediaLibraryTest : close : FAIL ' + closeErr.message);
console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL');
console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL');
...
@@ -781,7 +862,16 @@ close(fd: number): Promise<void>;
...
@@ -781,7 +862,16 @@ close(fd: number): Promise<void>;
**示例:**
**示例:**
```
```
fileAsset.close(fd).then((closeErr) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.close(fd).then((closeErr) => {
if (closeErr != undefined) {
if (closeErr != undefined) {
console.info('MediaLibraryTest : close : FAIL ' + closeErr.message);
console.info('MediaLibraryTest : close : FAIL ' + closeErr.message);
console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL');
console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL');
...
@@ -811,7 +901,16 @@ getThumbnail(callback: AsyncCallback<image.PixelMap>): void;
...
@@ -811,7 +901,16 @@ getThumbnail(callback: AsyncCallback<image.PixelMap>): void;
**示例:**
**示例:**
```
```
fileAsset.getThumbnail((err, pixelmap) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail((err, pixelmap) => {
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
});
});
```
```
...
@@ -836,7 +935,16 @@ getThumbnail(size: Size, callback: AsyncCallback<image.PixelMap>): void;
...
@@ -836,7 +935,16 @@ getThumbnail(size: Size, callback: AsyncCallback<image.PixelMap>): void;
**示例:**
**示例:**
```
```
fileAsset.getThumbnail(size, (err, pixelmap) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail(size, (err, pixelmap) => {
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
});
});
```
```
...
@@ -866,7 +974,16 @@ getThumbnail(size?: Size): Promise<image.PixelMap>;
...
@@ -866,7 +974,16 @@ getThumbnail(size?: Size): Promise<image.PixelMap>;
**示例:**
**示例:**
```
```
fileAsset.getThumbnail(size, (err, pixelmap) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail(size, (err, pixelmap) => {
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
});
});
```
```
...
@@ -891,6 +1008,15 @@ favorite(isFavorite: boolean, callback: AsyncCallback<void>): void;
...
@@ -891,6 +1008,15 @@ favorite(isFavorite: boolean, callback: AsyncCallback<void>): void;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.favorite(true,function(err){
asset.favorite(true,function(err){
// do something
// do something
});
});
...
@@ -921,6 +1047,15 @@ favorite(isFavorite: boolean): Promise<void>;
...
@@ -921,6 +1047,15 @@ favorite(isFavorite: boolean): Promise<void>;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.favorite(true).then(function() {
asset.favorite(true).then(function() {
console.info("favorite successfully");
console.info("favorite successfully");
}).catch(function(err){
}).catch(function(err){
...
@@ -947,6 +1082,15 @@ isFavorite(callback: AsyncCallback<boolean>): void;
...
@@ -947,6 +1082,15 @@ isFavorite(callback: AsyncCallback<boolean>): void;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.isFavorite((err, isFavorite) => {
asset.isFavorite((err, isFavorite) => {
if (isFavorite) {
if (isFavorite) {
console.info('FileAsset is favorite');
console.info('FileAsset is favorite');
...
@@ -975,6 +1119,15 @@ isFavorite():Promise<boolean>;
...
@@ -975,6 +1119,15 @@ isFavorite():Promise<boolean>;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.isFavorite().then(function(isFavorite){
asset.isFavorite().then(function(isFavorite){
console.info("isFavorite result:"+ isFavorite);
console.info("isFavorite result:"+ isFavorite);
}).catch(function(err){
}).catch(function(err){
...
@@ -1004,6 +1157,15 @@ trash(isTrash: boolean, callback: AsyncCallback<void&g;): void;
...
@@ -1004,6 +1157,15 @@ trash(isTrash: boolean, callback: AsyncCallback<void&g;): void;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.trash(true, trashCallBack);
asset.trash(true, trashCallBack);
function trashCallBack(err, trash) {
function trashCallBack(err, trash) {
console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK trash');
console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK trash');
...
@@ -1037,6 +1199,15 @@ trash(isTrash: boolean,): Promise<void>;
...
@@ -1037,6 +1199,15 @@ trash(isTrash: boolean,): Promise<void>;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.trash(true).then(function() {
asset.trash(true).then(function() {
console.info("trash successfully");
console.info("trash successfully");
}).catch(function(err){
}).catch(function(err){
...
@@ -1063,6 +1234,15 @@ isTrash(callback: AsyncCallback<boolean>): void;
...
@@ -1063,6 +1234,15 @@ isTrash(callback: AsyncCallback<boolean>): void;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.isTrash(isTrashCallBack);
asset.isTrash(isTrashCallBack);
function isTrashCallBack(err, isTrash) {
function isTrashCallBack(err, isTrash) {
if (isTrash == true) {
if (isTrash == true) {
...
@@ -1096,6 +1276,15 @@ isTrash():Promise<boolean>;
...
@@ -1096,6 +1276,15 @@ isTrash():Promise<boolean>;
**示例:**
**示例:**
```
```
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject();
asset.isTrash().then(function(isTrash){
asset.isTrash().then(function(isTrash){
console.info("isTrash result:"+ isTrash);
console.info("isTrash result:"+ isTrash);
}).catch(function(err){
}).catch(function(err){
...
@@ -1155,7 +1344,14 @@ isAfterLast(): boolean;
...
@@ -1155,7 +1344,14 @@ isAfterLast(): boolean;
**示例**
:
**示例**
:
```
```
let fetchFileResult = await media.getFileAssets(getFileCountTenOp);
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
const fetchCount = fetchFileResult.getCount();
const fetchCount = fetchFileResult.getCount();
console.info('MediaLibraryTest : count:' + fetchCount);
console.info('MediaLibraryTest : count:' + fetchCount);
let fileAsset = await fetchFileResult.getFirstObject();
let fileAsset = await fetchFileResult.getFirstObject();
...
@@ -1185,7 +1381,14 @@ close(): void;
...
@@ -1185,7 +1381,14 @@ close(): void;
**示例**
:
**示例**
:
```
```
let fetchFileResult = await media.getFileAssets(getFileCountTenOp);
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.close();
fetchFileResult.close();
```
```
...
@@ -1208,7 +1411,15 @@ getFirstObject(callback: AsyncCallback<FileAsset>): void;
...
@@ -1208,7 +1411,15 @@ getFirstObject(callback: AsyncCallback<FileAsset>): void;
**示例**
:
**示例**
:
```
```
data.getFirstObject((err, value) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getFirstObject((err, value) => {
if (err) {
if (err) {
console.error('Failed ');
console.error('Failed ');
return;
return;
...
@@ -1237,7 +1448,15 @@ getFirstObject(): Promise<FileAsset>;
...
@@ -1237,7 +1448,15 @@ getFirstObject(): Promise<FileAsset>;
**示例**
:
**示例**
:
```
```
queryResultSet_.getFirstObject().then(function(fileAsset){
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getFirstObject().then(function(fileAsset){
console.info("getFirstObject successfully:"+ JSON.stringify(fileAsset));
console.info("getFirstObject successfully:"+ JSON.stringify(fileAsset));
}).catch(function(err){
}).catch(function(err){
console.info("getFirstObject failed with error:"+ err);
console.info("getFirstObject failed with error:"+ err);
...
@@ -1263,7 +1482,15 @@ queryResultSet_.getFirstObject().then(function(fileAsset){
...
@@ -1263,7 +1482,15 @@ queryResultSet_.getFirstObject().then(function(fileAsset){
**示例**
:
**示例**
:
```
```
data.getNextObject((err, value) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getNextObject((err, value) => {
if (err) {
if (err) {
console.error('Failed ');
console.error('Failed ');
return;
return;
...
@@ -1291,7 +1518,14 @@ data.getNextObject((err, value) => {
...
@@ -1291,7 +1518,14 @@ data.getNextObject((err, value) => {
**示例**
:
**示例**
:
```
```
let fetchFileResult = await media.getFileAssets(getFileCountTenOp);
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
const fetchCount = fetchFileResult.getCount();
const fetchCount = fetchFileResult.getCount();
console.info('MediaLibraryTest : count:' + fetchCount);
console.info('MediaLibraryTest : count:' + fetchCount);
fileAsset = await fetchFileResult.getNextObject();
fileAsset = await fetchFileResult.getNextObject();
...
@@ -1316,7 +1550,15 @@ getLastObject(callback: AsyncCallback<FileAsset>): void;
...
@@ -1316,7 +1550,15 @@ getLastObject(callback: AsyncCallback<FileAsset>): void;
**示例**
:
**示例**
:
```
```
data.getLastObject((err, value) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getLastObject((err, value) => {
if (err) {
if (err) {
console.error('Failed ');
console.error('Failed ');
return;
return;
...
@@ -1375,7 +1617,15 @@ getPositionObject(index: number, callback: AsyncCallback<FileAsset>): void
...
@@ -1375,7 +1617,15 @@ getPositionObject(index: number, callback: AsyncCallback<FileAsset>): void
**示例**
:
**示例**
:
```
```
data. getPositionObject(1,(err, value) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getPositionObject(1,(err, value) => {
if (err) {
if (err) {
console.error('Failed ');
console.error('Failed ');
return;
return;
...
@@ -1409,7 +1659,15 @@ getPositionObject(index: number): Promise<FileAsset>;
...
@@ -1409,7 +1659,15 @@ getPositionObject(index: number): Promise<FileAsset>;
**示例**
:
**示例**
:
```
```
data.getPositionObject(1,(err, value) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getPositionObject(1,(err, value) => {
if (err) {
if (err) {
console.error('Failed ');
console.error('Failed ');
return;
return;
...
@@ -1437,7 +1695,15 @@ getAllObject(callback: AsyncCallback<Array<FileAsset>>): void;
...
@@ -1437,7 +1695,15 @@ getAllObject(callback: AsyncCallback<Array<FileAsset>>): void;
**示例**
:
**示例**
:
```
```
data.getAllObject((err, value) => {
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10",
};
let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getAllObject((err, value) => {
if (err) {
if (err) {
console.error('Failed ');
console.error('Failed ');
return;
return;
...
@@ -1495,6 +1761,12 @@ commitModify(callback: AsyncCallback<void>): void;
...
@@ -1495,6 +1761,12 @@ commitModify(callback: AsyncCallback<void>): void;
**示例**
:
**示例**
:
```
```
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
album.albumName = 'hello';
album.albumName = 'hello';
album.commitModify((err) => {
album.commitModify((err) => {
if (err) {
if (err) {
...
@@ -1524,6 +1796,12 @@ commitModify(): Promise<void>;
...
@@ -1524,6 +1796,12 @@ commitModify(): Promise<void>;
**示例**
:
**示例**
:
```
```
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
album.albumName = 'hello';
album.albumName = 'hello';
album.commitModify().then(function() {
album.commitModify().then(function() {
console.info("commitModify successfully");
console.info("commitModify successfully");
...
@@ -1552,6 +1830,12 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileRe
...
@@ -1552,6 +1830,12 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileRe
**示例**
:
**示例**
:
```
```
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack);
album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack);
})
})
function getFileAssetsCallBack(err, fetchFileResult) {
function getFileAssetsCallBack(err, fetchFileResult) {
...
@@ -1584,6 +1868,12 @@ function getFileAssetsCallBack(err, fetchFileResult) {
...
@@ -1584,6 +1868,12 @@ function getFileAssetsCallBack(err, fetchFileResult) {
**示例**
:
**示例**
:
```
```
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
album.getFileAssets(fileNoArgsfetchOp).then(function(albumFetchFileResult){
album.getFileAssets(fileNoArgsfetchOp).then(function(albumFetchFileResult){
console.info("getFileAssets successfully:"+ JSON.stringify(albumFetchFileResult));
console.info("getFileAssets successfully:"+ JSON.stringify(albumFetchFileResult));
}).catch(function(err){
}).catch(function(err){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录