You need to sign in or sign up before continuing.
提交 1f2823b2 编写于 作者: P panqiangbiao

fix code issue

Signed-off-by: Npanqiangbiao <panqiangbiao@huawei.com>
上级 c7430029
...@@ -35,7 +35,7 @@ function getMediaLibrary(context: Context): MediaLibrary; ...@@ -35,7 +35,7 @@ function getMediaLibrary(context: Context): MediaLibrary;
``` ```
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import mediaLibrary from ohos.multimedia.mediaLibrary'; import mediaLibrary from '@ohos.multimedia.mediaLibrary';
var context = featureAbility.getContext() var context = featureAbility.getContext()
var mediaLibrary = mediaLibrary.getMediaLibrary(context); var mediaLibrary = mediaLibrary.getMediaLibrary(context);
...@@ -76,6 +76,7 @@ medialibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { ...@@ -76,6 +76,7 @@ medialibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => {
fileAssetList.forEach(getAllObjectInfo); fileAssetList.forEach(getAllObjectInfo);
} }
}); });
}
}); });
``` ```
## medialibrary.getFileAssets ## medialibrary.getFileAssets
...@@ -294,12 +295,14 @@ getPublicDirectory(type: DirectoryType): Promise&lt;string&gt;; ...@@ -294,12 +295,14 @@ getPublicDirectory(type: DirectoryType): Promise&lt;string&gt;;
**示例:** **示例:**
``` ```
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; async function (done) {
const dicResult = await media.getPublicDirectory(DIR_CAMERA); let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
if (dicResult == 'camera/') { const dicResult = await media.getPublicDirectory(DIR_CAMERA);
if (dicResult == 'camera/') {
console.info('MediaLibraryTest : getPublicDirectory'); console.info('MediaLibraryTest : getPublicDirectory');
} else { } else {
console.info('MediaLibraryTest : getPublicDirectory failed'); console.info('MediaLibraryTest : getPublicDirectory failed');
}
} }
``` ```
...@@ -393,7 +396,8 @@ release(callback: AsyncCallback&lt;void&gt;): void; ...@@ -393,7 +396,8 @@ release(callback: AsyncCallback&lt;void&gt;): void;
**示例:** **示例:**
``` ```
medialibrary.release((err, data) => { var mediaLibrary = mediaLibrary.getMediaLibrary(context);
mediaLibrary.release((err, data) => {
// do something // do something
}); });
``` ```
...@@ -417,7 +421,8 @@ release(): Promise&lt;void&gt;; ...@@ -417,7 +421,8 @@ release(): Promise&lt;void&gt;;
**示例:** **示例:**
``` ```
medialibrary.release() var mediaLibrary = mediaLibrary.getMediaLibrary(context);
mediaLibrary.release()
``` ```
## FileAsset.isDirectory ## FileAsset.isDirectory
...@@ -439,18 +444,20 @@ isDirectory(callback: AsyncCallback&lt;boolean&gt;): void; ...@@ -439,18 +444,20 @@ isDirectory(callback: AsyncCallback&lt;boolean&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.isDirectory((err, isDirectory) => { asset.isDirectory((err, isDirectory) => {
// do something // do something
}); });
}
``` ```
## FileAsset.isDirectory ## FileAsset.isDirectory
...@@ -472,20 +479,22 @@ isDirectory():Promise&lt;boolean&gt;; ...@@ -472,20 +479,22 @@ isDirectory():Promise&lt;boolean&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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){
console.info("isDirectory failed with error:"+ err); console.info("isDirectory failed with error:"+ err);
}); });
}
``` ```
## FileAsset.commitModify ## FileAsset.commitModify
...@@ -507,18 +516,20 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void; ...@@ -507,18 +516,20 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.title = ‘newtitle'; asset.title = ‘newtitle';
asset.commitModify(() => { asset.commitModify(() => {
console.info('commitModify success'); console.info('commitModify success');
}
} }
``` ```
...@@ -541,17 +552,19 @@ commitModify(): Promise&lt;void&gt;; ...@@ -541,17 +552,19 @@ commitModify(): Promise&lt;void&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.title = ‘newtitle'; asset.title = ‘newtitle';
asset.commitModify(); asset.commitModify();
}
``` ```
## FileAsset.open ## FileAsset.open
...@@ -574,16 +587,18 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void; ...@@ -574,16 +587,18 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void;
**示例:** **示例:**
``` ```
let mediaType = mediaLibrary.MediaType.IMAGE; async function (done) {
let path = "Pictures/"; let mediaType = mediaLibrary.MediaType.IMAGE;
asset = await media.createAsset(mediaType, "image00003.jpg", path); let path = "Pictures/";
asset.open('rw', (openError, fd) => { asset = await media.createAsset(mediaType, "image00003.jpg", path);
asset.open('rw', (openError, fd) => {
if(fd > 0){ if(fd > 0){
asset.close(fd); asset.close(fd);
}else{ }else{
console.info('File Open Failed!' + openError); console.info('File Open Failed!' + openError);
} }
}); });
}
``` ```
## FileAsset.open ## FileAsset.open
...@@ -611,16 +626,18 @@ open(mode: string): Promise&lt;number&gt;; ...@@ -611,16 +626,18 @@ open(mode: string): Promise&lt;number&gt;;
**示例:** **示例:**
``` ```
let mediaType = mediaLibrary.MediaType.IMAGE; async function (done) {
let path = "Pictures/"; let mediaType = mediaLibrary.MediaType.IMAGE;
asset = await media.createAsset(mediaType, "image00003.jpg", path); let path = "Pictures/";
asset.open('rw').then((openError, fd) => { asset = await media.createAsset(mediaType, "image00003.jpg", path);
asset.open('rw').then((openError, fd) => {
if(fd > 0){ if(fd > 0){
asset.close(fd); asset.close(fd);
}else{ }else{
console.info('File Open Failed!' + openError); console.info('File Open Failed!' + openError);
} }
}); });
}
``` ```
## FileAsset.close ## FileAsset.close
...@@ -643,23 +660,25 @@ close(fd: number, callback: AsyncCallback&lt;void&gt;): void; ...@@ -643,23 +660,25 @@ close(fd: number, callback: AsyncCallback&lt;void&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.close(fd, (closeErr) => { 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');
} else { } else {
console.info("=======asset.close success====>"); console.info("=======asset.close success====>");
} }
}); });
}
``` ```
## FileAsset.close ## FileAsset.close
...@@ -687,16 +706,17 @@ close(fd: number): Promise&lt;void&gt;; ...@@ -687,16 +706,17 @@ close(fd: number): Promise&lt;void&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.close(fd).then((closeErr) => { 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');
...@@ -704,7 +724,8 @@ asset.close(fd).then((closeErr) => { ...@@ -704,7 +724,8 @@ asset.close(fd).then((closeErr) => {
} else { } else {
console.info("=======asset.close success====>"); console.info("=======asset.close success====>");
} }
}); });
}
``` ```
## FileAsset.getThumbnail ## FileAsset.getThumbnail
...@@ -726,18 +747,20 @@ getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void; ...@@ -726,18 +747,20 @@ getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail((err, pixelmap) => { asset.getThumbnail((err, pixelmap) => {
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap); console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
}); });
}
``` ```
## FileAsset.getThumbnail ## FileAsset.getThumbnail
...@@ -760,18 +783,20 @@ getThumbnail(size: Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void; ...@@ -760,18 +783,20 @@ getThumbnail(size: Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail(size, (err, pixelmap) => { asset.getThumbnail(size, (err, pixelmap) => {
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap); console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
}); });
}
``` ```
## FileAsset.getThumbnail ## FileAsset.getThumbnail
...@@ -799,18 +824,20 @@ getThumbnail(size?: Size): Promise&lt;image.PixelMap&gt;; ...@@ -799,18 +824,20 @@ getThumbnail(size?: Size): Promise&lt;image.PixelMap&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail(size, (err, pixelmap) => { asset.getThumbnail(size, (err, pixelmap) => {
console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap); console.info('MediaLibraryTest : getThumbnail Successfull '+ pixelmap);
}); });
}
``` ```
## FileAsset.favorite ## FileAsset.favorite
...@@ -833,18 +860,20 @@ favorite(isFavorite: boolean, callback: AsyncCallback&lt;void&gt;): void; ...@@ -833,18 +860,20 @@ favorite(isFavorite: boolean, callback: AsyncCallback&lt;void&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.favorite(true,function(err){ asset.favorite(true,function(err){
// do something // do something
}); });
}
``` ```
## FileAsset.favorite ## FileAsset.favorite
...@@ -872,20 +901,22 @@ favorite(isFavorite: boolean): Promise&lt;void&gt;; ...@@ -872,20 +901,22 @@ favorite(isFavorite: boolean): Promise&lt;void&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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){
console.info("favorite failed with error:"+ err); console.info("favorite failed with error:"+ err);
}); });
}
``` ```
## FileAsset.isFavorite ## FileAsset.isFavorite
...@@ -907,22 +938,24 @@ isFavorite(callback: AsyncCallback&lt;boolean&gt;): void; ...@@ -907,22 +938,24 @@ isFavorite(callback: AsyncCallback&lt;boolean&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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');
}else{ }else{
console.info('FileAsset is not favorite'); console.info('FileAsset is not favorite');
} }
}); });
}
``` ```
## FileAsset.isFavorite ## FileAsset.isFavorite
...@@ -944,20 +977,22 @@ isFavorite():Promise&lt;boolean&gt;; ...@@ -944,20 +977,22 @@ isFavorite():Promise&lt;boolean&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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){
console.info("isFavorite failed with error:"+ err); console.info("isFavorite failed with error:"+ err);
}); });
}
``` ```
## FileAsset.trash ## FileAsset.trash
...@@ -982,18 +1017,20 @@ trash(isTrash: boolean, callback: AsyncCallback&lt;void&g;): void; ...@@ -982,18 +1017,20 @@ trash(isTrash: boolean, callback: AsyncCallback&lt;void&g;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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');
}
} }
``` ```
...@@ -1024,20 +1061,22 @@ trash(isTrash: boolean,): Promise&lt;void&gt;; ...@@ -1024,20 +1061,22 @@ trash(isTrash: boolean,): Promise&lt;void&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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){
console.info("trash failed with error:"+ err); console.info("trash failed with error:"+ err);
}); });
}
``` ```
## FileAsset.isTrash ## FileAsset.isTrash
...@@ -1059,23 +1098,27 @@ isTrash(callback: AsyncCallback&lt;boolean&gt;): void; ...@@ -1059,23 +1098,27 @@ isTrash(callback: AsyncCallback&lt;boolean&gt;): void;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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) {
console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash); console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash);
asset.trash(true, trashCallBack); asset.trash(true, trashCallBack);
} else { } else {
console.info('MediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err); console.info('MediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err);
console.info('MediaLibraryTest : ASSET_CALLBACK isTrash : FAIL'); console.info('MediaLibraryTest : ASSET_CALLBACK isTrash : FAIL');
}
} }
} }
``` ```
...@@ -1099,20 +1142,22 @@ isTrash():Promise&lt;boolean&gt;; ...@@ -1099,20 +1142,22 @@ isTrash():Promise&lt;boolean&gt;;
**示例:** **示例:**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); 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){
console.info("isTrash failed with error:"+ err); console.info("isTrash failed with error:"+ err);
}); });
}
``` ```
**FetchFileResult** **FetchFileResult**
...@@ -1138,14 +1183,16 @@ getCount(): number; ...@@ -1138,14 +1183,16 @@ getCount(): number;
**示例** **示例**
``` ```
let getFileCountOneOp = { async function (done) {
let getFileCountOneOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [fileType.toString()], selectionArgs: [fileType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,1", extendArgs: "LIMIT 0,1",
}; };
let fetchFileResult = await media.getFileAssets(getFileCountOneOp); let fetchFileResult = await media.getFileAssets(getFileCountOneOp);
const fetchCount = fetchFileResult.getCount(); const fetchCount = fetchFileResult.getCount();
}
``` ```
## FetchFileResult.isAfterLast ## FetchFileResult.isAfterLast
...@@ -1167,18 +1214,19 @@ isAfterLast(): boolean; ...@@ -1167,18 +1214,19 @@ isAfterLast(): boolean;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); 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();
for (var i = 1; i < fetchCount; i++) { for (var i = 1; i < fetchCount; i++) {
fileAsset = await fetchFileResult.getNextObject(); fileAsset = await fetchFileResult.getNextObject();
if(i == fetchCount - 1) { if(i == fetchCount - 1) {
console.info('MediaLibraryTest : isLast'); console.info('MediaLibraryTest : isLast');
...@@ -1188,6 +1236,7 @@ for (var i = 1; i < fetchCount; i++) { ...@@ -1188,6 +1236,7 @@ for (var i = 1; i < fetchCount; i++) {
fetchFileResult.close(); fetchFileResult.close();
} }
}
} }
``` ```
...@@ -1204,15 +1253,17 @@ close(): void; ...@@ -1204,15 +1253,17 @@ close(): void;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.close(); fetchFileResult.close();
}
``` ```
## FetchFileResult.getFirstObject ## FetchFileResult.getFirstObject
...@@ -1234,21 +1285,23 @@ getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void; ...@@ -1234,21 +1285,23 @@ getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getFirstObject((err, value) => { fetchFileResult.getFirstObject((err, value) => {
if (err) { if (err) {
console.error('Failed '); console.error('Failed ');
return; return;
} }
console.log(value); console.log(value);
}) })
}
``` ```
## FetchFileResult.getFirstObject ## FetchFileResult.getFirstObject
...@@ -1271,19 +1324,21 @@ getFirstObject(): Promise&lt;FileAsset&gt;; ...@@ -1271,19 +1324,21 @@ getFirstObject(): Promise&lt;FileAsset&gt;;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getFirstObject().then(function(fileAsset){ 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);
}); });
}
``` ```
## FetchFileResult.getNextObject ## FetchFileResult.getNextObject
...@@ -1305,21 +1360,23 @@ fetchFileResult.getFirstObject().then(function(fileAsset){ ...@@ -1305,21 +1360,23 @@ fetchFileResult.getFirstObject().then(function(fileAsset){
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getNextObject((err, value) => { fetchFileResult.getNextObject((err, value) => {
if (err) { if (err) {
console.error('Failed '); console.error('Failed ');
return; return;
} }
console.log(value); console.log(value);
}) })
}
``` ```
## FetchFileResult.getNextObject ## FetchFileResult.getNextObject
...@@ -1341,17 +1398,19 @@ fetchFileResult.getNextObject((err, value) => { ...@@ -1341,17 +1398,19 @@ fetchFileResult.getNextObject((err, value) => {
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); 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();
}
``` ```
## FetchFileResult.getLastObject ## FetchFileResult.getLastObject
...@@ -1373,21 +1432,23 @@ getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void; ...@@ -1373,21 +1432,23 @@ getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getLastObject((err, value) => { fetchFileResult.getLastObject((err, value) => {
if (err) { if (err) {
console.error('Failed '); console.error('Failed ');
return; return;
} }
console.log(value); console.log(value);
}) })
}
``` ```
## FetchFileResult.getLastObject ## FetchFileResult.getLastObject
...@@ -1409,15 +1470,17 @@ getLastObject(): Promise&lt;FileAsset&gt;; ...@@ -1409,15 +1470,17 @@ getLastObject(): Promise&lt;FileAsset&gt;;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
let lastObject = await fetchFileResult.getLastObject(); let lastObject = await fetchFileResult.getLastObject();
}
``` ```
## FetchFileResult.getPositionObject ## FetchFileResult.getPositionObject
...@@ -1440,21 +1503,23 @@ getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void ...@@ -1440,21 +1503,23 @@ getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getPositionObject(1,(err, value) => { fetchFileResult.getPositionObject(1,(err, value) => {
if (err) { if (err) {
console.error('Failed '); console.error('Failed ');
return; return;
} }
console.log(value); console.log(value);
}) })
}
``` ```
## FetchFileResult.getPositionObject ## FetchFileResult.getPositionObject
...@@ -1482,21 +1547,23 @@ getPositionObject(index: number): Promise&lt;FileAsset&gt;; ...@@ -1482,21 +1547,23 @@ getPositionObject(index: number): Promise&lt;FileAsset&gt;;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getPositionObject(1,(err, value) => { fetchFileResult.getPositionObject(1,(err, value) => {
if (err) { if (err) {
console.error('Failed '); console.error('Failed ');
return; return;
} }
console.log(value); console.log(value);
}) })
}
``` ```
## FetchFileResult.getAllObject ## FetchFileResult.getAllObject
...@@ -1518,21 +1585,23 @@ getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void; ...@@ -1518,21 +1585,23 @@ getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getAllObject((err, value) => { fetchFileResult.getAllObject((err, value) => {
if (err) { if (err) {
console.error('Failed '); console.error('Failed ');
return; return;
} }
console.log(value); console.log(value);
}) })
}
``` ```
## FetchFileResult.getAllObject ## FetchFileResult.getAllObject
...@@ -1554,15 +1623,17 @@ getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt;; ...@@ -1554,15 +1623,17 @@ getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt;;
**示例** **示例**
``` ```
let imageType = mediaLibrary.MediaType.IMAGE; async function (done) {
let getImageOp = { let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?', selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
order: fileKeyObj.DATE_ADDED, order: fileKeyObj.DATE_ADDED,
extendArgs: "LIMIT 0,10", extendArgs: "LIMIT 0,10",
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
var data = fetchFileResult.getAllObject(); var data = fetchFileResult.getAllObject();
}
``` ```
## Album.commitModify ## Album.commitModify
...@@ -1584,20 +1655,22 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void; ...@@ -1584,20 +1655,22 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void;
**示例** **示例**
``` ```
let AlbumNoArgsfetchOp = { async function (done) {
let AlbumNoArgsfetchOp = {
selections: '', selections: '',
selectionArgs: [], selectionArgs: [],
}; };
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0]; const album = albumList[0];
album.albumName = 'hello'; album.albumName = 'hello';
album.commitModify((err) => { album.commitModify((err) => {
if (err) { if (err) {
console.error('Failed '); console.error('Failed ');
return; return;
} }
console.log('Modify successful.'); console.log('Modify successful.');
}) })
}
``` ```
## Album.commitModify ## Album.commitModify
...@@ -1619,18 +1692,20 @@ commitModify(): Promise&lt;void&gt;; ...@@ -1619,18 +1692,20 @@ commitModify(): Promise&lt;void&gt;;
**示例** **示例**
``` ```
let AlbumNoArgsfetchOp = { async function (done) {
let AlbumNoArgsfetchOp = {
selections: '', selections: '',
selectionArgs: [], selectionArgs: [],
}; };
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0]; 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");
}).catch(function(err){ }).catch(function(err){
console.info("commitModify failed with error:"+ err); console.info("commitModify failed with error:"+ err);
}); });
}
``` ```
## Album.getFileAssets ## Album.getFileAssets
...@@ -1653,16 +1728,18 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileRe ...@@ -1653,16 +1728,18 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileRe
**示例** **示例**
``` ```
let AlbumNoArgsfetchOp = { async function (done) {
let AlbumNoArgsfetchOp = {
selections: '', selections: '',
selectionArgs: [], selectionArgs: [],
}; };
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0]; const album = albumList[0];
album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack); album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack);
}) })
function getFileAssetsCallBack(err, fetchFileResult) { function getFileAssetsCallBack(err, fetchFileResult) {
// do something // do something
}
} }
``` ```
...@@ -1691,17 +1768,19 @@ function getFileAssetsCallBack(err, fetchFileResult) { ...@@ -1691,17 +1768,19 @@ function getFileAssetsCallBack(err, fetchFileResult) {
**示例** **示例**
``` ```
let AlbumNoArgsfetchOp = { async function (done) {
let AlbumNoArgsfetchOp = {
selections: '', selections: '',
selectionArgs: [], selectionArgs: [],
}; };
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0]; 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){
console.info("getFileAssets failed with error:"+ err); console.info("getFileAssets failed with error:"+ err);
}); });
}
``` ```
## PeerInfo ## PeerInfo
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册