Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
bc85ba06
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
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看板
未验证
提交
bc85ba06
编写于
8月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!8745 modified js-apis-medialibrary.md describe the error
Merge pull request !8745 from 胡伟奇/modify_medialibrary_md
上级
0834d4a9
11388efe
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
307 addition
and
70 deletion
+307
-70
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
+307
-70
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md
浏览文件 @
bc85ba06
...
...
@@ -4,7 +4,7 @@
> 该组件从API Version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 导入模块
```
```
js
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
;
```
...
...
@@ -32,13 +32,13 @@ getMediaLibrary(context: Context): MediaLibrary
**示例:(从API Version 9开始)**
```
```
ts
var
media
=
mediaLibrary
.
getMediaLibrary
(
this
.
context
);
```
**示例:(API Version 8)**
```
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
()
...
...
@@ -90,7 +90,7 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileRe
**示例:**
```
```
js
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
let
imagesfetchOp
=
{
...
...
@@ -134,7 +134,7 @@ getFileAssets(options: MediaFetchOptions): Promise<FetchFileResult>
**示例:**
```
```
js
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
let
imagesfetchOp
=
{
...
...
@@ -165,7 +165,7 @@ on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|
**示例:**
```
```
js
media
.
on
(
'
imageChange
'
,
()
=>
{
// image file had changed, do something
})
...
...
@@ -187,7 +187,7 @@ off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'
**示例:**
```
```
js
media
.
off
(
'
imageChange
'
,
()
=>
{
// stop listening success
})
...
...
@@ -214,7 +214,7 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string, cal
**示例:**
```
```
js
async
function
example
()
{
// 使用Callback方式创建Image类型文件
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -256,7 +256,7 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string): Pr
**示例:**
```
```
js
let
DIR_CAMERA
=
mediaLibrary
.
DirectoryType
.
DIR_CAMERA
;
media
.
getPublicDirectory
(
DIR_CAMERA
).
then
(
function
(
dicResult
){
console
.
info
(
"
getPublicDirectory successfully:
"
+
JSON
.
stringify
(
dicResult
));
...
...
@@ -282,7 +282,7 @@ getPublicDirectory(type: DirectoryType, callback: AsyncCallback<string>):
**示例:**
```
```
js
let
DIR_CAMERA
=
mediaLibrary
.
DirectoryType
.
DIR_CAMERA
;
media
.
getPublicDirectory
(
DIR_CAMERA
,
(
err
,
dicResult
)
=>
{
if
(
dicResult
==
'
Camera/
'
)
{
...
...
@@ -315,7 +315,7 @@ getPublicDirectory(type: DirectoryType): Promise<string>
**示例:**
```
```
js
async
function
example
()
{
let
DIR_CAMERA
=
mediaLibrary
.
DirectoryType
.
DIR_CAMERA
;
const
dicResult
=
await
media
.
getPublicDirectory
(
DIR_CAMERA
);
...
...
@@ -346,7 +346,7 @@ getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array<Album>
**示例:**
```
```
js
let
AlbumNoArgsfetchOp
=
{
selections
:
''
,
selectionArgs
:
[],
...
...
@@ -386,7 +386,7 @@ getAlbums(options: MediaFetchOptions): Promise<Array<Album>>
**示例:**
```
```
js
let
AlbumNoArgsfetchOp
=
{
selections
:
''
,
selectionArgs
:
[],
...
...
@@ -415,7 +415,7 @@ release(callback: AsyncCallback<void>): void
**示例:**
```
```
js
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
media
.
release
((
err
)
=>
{
// do something
...
...
@@ -439,7 +439,7 @@ release(): Promise<void>
**示例:**
```
```
js
media
.
release
()
```
...
...
@@ -462,7 +462,7 @@ storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback<string>)
**示例:**
```
```
js
let
option
=
{
src
:
"
/data/storage/el2/base/haps/entry/image.png
"
,
mimeType
:
"
image/*
"
,
...
...
@@ -476,7 +476,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option, (err, value) => {
console
.
log
(
"
Media resources stored.
"
);
// Obtain the URI that stores media resources.
});
```
```
### storeMediaAsset<sup>(deprecated)</sup>
...
...
@@ -503,7 +503,7 @@ storeMediaAsset(option: MediaAssetOption): Promise<string>
**示例:**
```
```
js
let
option
=
{
src
:
"
/data/storage/el2/base/haps/entry/image.png
"
,
mimeType
:
"
image/*
"
,
...
...
@@ -515,7 +515,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => {
}).
catch
((
err
)
=>
{
console
.
log
(
"
An error occurred when storing media resources.
"
);
});
```
```
### startImagePreview<sup>(deprecated)</sup>
...
...
@@ -538,7 +538,7 @@ startImagePreview(images: Array<string>, index: number, callback: AsyncCal
**示例:**
```
```
js
let
images
=
[
"
dataability:///media/xxxx/2
"
,
"
dataability:///media/xxxx/3
"
...
...
@@ -557,7 +557,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (err) => {
}
console
.
log
(
"
Succeeded in previewing the images.
"
);
});
```
```
### startImagePreview<sup>(deprecated)</sup>
...
...
@@ -579,7 +579,7 @@ startImagePreview(images: Array<string>, callback: AsyncCallback<void&g
**示例:**
```
```
js
let
images
=
[
"
dataability:///media/xxxx/2
"
,
"
dataability:///media/xxxx/3
"
...
...
@@ -597,7 +597,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (err) => {
}
console
.
log
(
"
Succeeded in previewing the images.
"
);
});
```
```
### startImagePreview<sup>(deprecated)</sup>
...
...
@@ -625,7 +625,7 @@ startImagePreview(images: Array<string>, index?: number): Promise<void&
**示例:**
```
```
js
let
images
=
[
"
dataability:///media/xxxx/2
"
,
"
dataability:///media/xxxx/3
"
...
...
@@ -642,7 +642,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => {
}).
catch
((
err
)
=>
{
console
.
log
(
"
An error occurred when previewing the images.
"
);
});
```
```
### startMediaSelect<sup>(deprecated)</sup>
...
...
@@ -664,7 +664,7 @@ startMediaSelect(option: MediaSelectOption, callback: AsyncCallback<Array<
**示例:**
```
```
js
let
option
=
{
type
:
"
media
"
,
count
:
2
...
...
@@ -677,7 +677,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => {
console
.
log
(
"
Media resources selected.
"
);
// Obtain the media selection value.
});
```
```
### startMediaSelect<sup>(deprecated)</sup>
...
...
@@ -704,7 +704,7 @@ startMediaSelect(option: MediaSelectOption): Promise<Array<string>>
**示例:**
```
```
js
let
option
=
{
type
:
"
media
"
,
count
:
2
...
...
@@ -716,7 +716,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => {
console
.
log
(
"
An error occurred when selecting media resources.
"
);
});
```
```
## FileAsset<sup>7+</sup>
...
...
@@ -769,7 +769,7 @@ isDirectory(callback: AsyncCallback<boolean>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -805,7 +805,7 @@ isDirectory():Promise<boolean>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -843,7 +843,7 @@ commitModify(callback: AsyncCallback<void>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -880,7 +880,7 @@ commitModify(): Promise<void>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -918,7 +918,7 @@ open(mode: string, callback: AsyncCallback<number>): void
**示例:**
```
```
js
async
function
example
()
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
...
...
@@ -960,7 +960,7 @@ open(mode: string): Promise<number>
**示例:**
```
```
js
async
function
example
()
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
...
...
@@ -995,7 +995,7 @@ close(fd: number, callback: AsyncCallback<void>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1048,7 +1048,7 @@ close(fd: number): Promise<void>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1096,7 +1096,7 @@ getThumbnail(callback: AsyncCallback<image.PixelMap>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1133,7 +1133,7 @@ getThumbnail(size: Size, callback: AsyncCallback<image.PixelMap>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1176,7 +1176,7 @@ getThumbnail(size?: Size): Promise<image.PixelMap>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1218,7 +1218,7 @@ favorite(isFavorite: boolean, callback: AsyncCallback<void>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1260,7 +1260,7 @@ favorite(isFavorite: boolean): Promise<void>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1298,7 +1298,7 @@ isFavorite(callback: AsyncCallback<boolean>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1338,7 +1338,7 @@ isFavorite():Promise<boolean>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1379,7 +1379,7 @@ trash(isTrash: boolean, callback: AsyncCallback<void>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1424,7 +1424,7 @@ trash(isTrash: boolean): Promise<void>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1462,7 +1462,7 @@ isTrash(callback: AsyncCallback<boolean>): void
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1507,7 +1507,7 @@ isTrash():Promise<boolean>
**示例:**
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1527,6 +1527,239 @@ async function example() {
}
```
### deleteAsset<sup>8+</sup>
deleteAsset(uri: string): Promise
<void>
;
删除媒体文件资源
**系统接口**
:此接口为系统接口。
**需要权限**
:ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
**系统能力**
:SystemCapability.Multimedia.MediaLibrary.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | --------------- |
| uri | string | 是 | 需要删除的媒体文件资源的uri |
**示例:**
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
fileType
=
mediaLibrary
.
MediaType
.
FILE
let
option
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
fileType
.
toString
()],
};
const
context
=
getContext
(
this
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
option
);
let
asset
=
await
fetchFileResult
.
getFirstObject
();
if
(
asset
==
undefined
)
{
console
.
error
(
'
asset not exist
'
)
return
}
media
.
deleteAsset
(
asset
.
uri
).
then
(()
=>
{
console
.
info
(
"
deleteAsset successfully
"
);
}).
catch
((
err
)
=>
{
console
.
info
(
"
deleteAsset failed with error:
"
+
err
);
});
}
```
deleteAsset(uri: string, callback: AsyncCallback
<void>
): void;
删除媒体文件资源
**系统接口**
:此接口为系统接口。
**需要权限**
:ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
**系统能力**
:SystemCapability.Multimedia.MediaLibrary.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | --------------- |
| uri | string | 是 | 需要删除的媒体文件资源的uri |
**示例:**
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
fileType
=
mediaLibrary
.
MediaType
.
FILE
let
option
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
fileType
.
toString
()],
};
const
context
=
getContext
(
this
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
option
);
let
asset
=
await
fetchFileResult
.
getFirstObject
();
if
(
asset
==
undefined
)
{
console
.
error
(
'
asset not exist
'
)
return
}
media
.
deleteAsset
(
asset
.
uri
,
(
err
)
=>
{
if
(
err
!=
undefined
)
{
console
.
info
(
"
deleteAsset successfully
"
);
}
else
{
console
.
info
(
"
deleteAsset failed with error:
"
+
err
);
}
});
}
```
### getActivePeers<sup>8+</sup>
getActivePeers(): Promise
<Array
<
PeerInfo
>
>;
获取在线对端设备的信息,使用Promise方式返回异步结果
**系统接口**
:此接口为系统接口。
**需要权限**
:ohos.permission.READ_MEDIA
**系统能力**
:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| Promise
<Array
<
PeerInfo
>
> | 返回获取的所有在线对端设备的PeerInfo |
**示例:**
```
js
async
function
example
()
{
const
context
=
getContext
(
this
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
media
.
getActivePeers
().
then
((
devicesInfo
)
=>
{
if
(
devicesInfo
!=
undefined
)
{
for
(
let
i
=
0
;
i
<
devicesInfo
.
length
;
i
++
)
{
console
.
info
(
'
get distributed info
'
+
devicesInfo
[
i
].
deviceName
+
devicesInfo
[
i
].
networkId
);
}
}
else
{
console
.
info
(
'
get distributed info is undefined!
'
)
}
}).
catch
((
err
)
=>
{
console
.
info
(
"
get distributed info failed with error:
"
+
err
);
});
}
```
getActivePeers(callback: AsyncCallback
<Array
<
PeerInfo
>
>): void;
获取在线对端设备的信息,使用callback方式返回异步结果。
**系统接口**
:此接口为系统接口。
**需要权限**
:ohos.permission.READ_MEDIA
**系统能力**
:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| callback: AsyncCallback
<Array
<
PeerInfo
>
> | 返回获取的所有在线对端设备的PeerInfo |
**示例:**
```
js
async
function
example
()
{
const
context
=
getContext
(
this
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
media
.
getActivePeers
((
err
,
devicesInfo
)
=>
{
if
(
devicesInfo
!=
undefined
)
{
for
(
let
i
=
0
;
i
<
devicesInfo
.
length
;
i
++
)
{
console
.
info
(
'
get distributed info
'
+
devicesInfo
[
i
].
deviceName
+
devicesInfo
[
i
].
networkId
);
}
}
else
{
console
.
info
(
'
get distributed fail, message =
'
+
err
)
}
})
}
```
### getAllPeers<sup>8+</sup>
getAllPeers(): Promise
<Array
<
PeerInfo
>
>;
获取所有对端设备的信息,使用Promise方式返回异步结果
**系统接口**
:此接口为系统接口。
**需要权限**
:ohos.permission.READ_MEDIA
**系统能力**
:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| Promise
<Array
<
PeerInfo
>
> | 返回获取的所有对端设备的PeerInfo |
**示例:**
```
js
async
function
example
()
{
const
context
=
getContext
(
this
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
media
.
getAllPeers
().
then
((
devicesInfo
)
=>
{
if
(
devicesInfo
!=
undefined
)
{
for
(
let
i
=
0
;
i
<
devicesInfo
.
length
;
i
++
)
{
console
.
info
(
'
get distributed info
'
+
devicesInfo
[
i
].
deviceName
+
devicesInfo
[
i
].
networkId
);
}
}
else
{
console
.
info
(
'
get distributed info is undefined!
'
)
}
}).
catch
((
err
)
=>
{
console
.
info
(
"
get distributed info failed with error:
"
+
err
);
});
}
```
getAllPeers(callback: AsyncCallback
<Array
<
PeerInfo
>
>): void;
获取所有对端设备的信息,使用callback方式返回异步结果。
**系统接口**
:此接口为系统接口。
**需要权限**
:ohos.permission.READ_MEDIA
**系统能力**
:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| callback: AsyncCallback
<Array
<
PeerInfo
>
> | 返回获取的所有对端设备的PeerInfo |
**示例:**
```
js
async
function
example
()
{
const
context
=
getContext
(
this
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
media
.
getAllPeers
((
err
,
devicesInfo
)
=>
{
if
(
devicesInfo
!=
undefined
)
{
for
(
let
i
=
0
;
i
<
devicesInfo
.
length
;
i
++
)
{
console
.
info
(
'
get distributed info
'
+
devicesInfo
[
i
].
deviceName
+
devicesInfo
[
i
].
networkId
);
}
}
else
{
console
.
info
(
'
get distributed fail, message =
'
+
err
)
}
})
}
```
## FetchFileResult<sup>7+</sup>
文件检索结果集。
...
...
@@ -1547,7 +1780,7 @@ getCount(): number
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
fileType
=
mediaLibrary
.
MediaType
.
FILE
;
...
...
@@ -1578,7 +1811,7 @@ isAfterLast(): boolean
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1616,7 +1849,7 @@ close(): void
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1647,7 +1880,7 @@ getFirstObject(callback: AsyncCallback<FileAsset>): void
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1684,7 +1917,7 @@ getFirstObject(): Promise<FileAsset>
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1719,7 +1952,7 @@ async function example() {
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1756,7 +1989,7 @@ async function example() {
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1789,7 +2022,7 @@ getLastObject(callback: AsyncCallback<FileAsset>): void
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1826,7 +2059,7 @@ getLastObject(): Promise<FileAsset>
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1858,7 +2091,7 @@ getPositionObject(index: number, callback: AsyncCallback<FileAsset>): void
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1901,7 +2134,7 @@ getPositionObject(index: number): Promise<FileAsset>
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1913,9 +2146,9 @@ async function example() {
};
let
fetchFileResult
=
await
media
.
getFileAssets
(
getImageOp
);
fetchFileResult
.
getPositionObject
(
1
)
.
then
(
function
(
fileAsset
){
console
.
log
(
'
[Demo]
fileAsset.displayName : '
+
fileAsset
.
displayName
);
console
.
log
(
'
fileAsset.displayName :
'
+
fileAsset
.
displayName
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
[Demo]
getFileAssets failed with error:"
+
err
);
console
.
info
(
"
getFileAssets failed with error:
"
+
err
);
});
}
```
...
...
@@ -1936,7 +2169,7 @@ getAllObject(callback: AsyncCallback<Array<FileAsset>>): void
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -1973,7 +2206,7 @@ getAllObject(): Promise<Array<FileAsset>>
**示例**
:
```
```
js
async
function
example
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
...
...
@@ -2024,7 +2257,7 @@ commitModify(callback: AsyncCallback<void>): void
**示例**
:
```
```
js
async
function
example
()
{
let
AlbumNoArgsfetchOp
=
{
selections
:
''
,
...
...
@@ -2061,7 +2294,7 @@ commitModify(): Promise<void>
**示例**
:
```
```
js
async
function
example
()
{
let
AlbumNoArgsfetchOp
=
{
selections
:
''
,
...
...
@@ -2097,7 +2330,7 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileRe
**示例**
:
```
```
js
async
function
example
()
{
let
AlbumNoArgsfetchOp
=
{
selections
:
''
,
...
...
@@ -2140,7 +2373,7 @@ async function example() {
**示例**
:
```
```
js
async
function
example
()
{
let
AlbumNoArgsfetchOp
=
{
selections
:
''
,
...
...
@@ -2163,7 +2396,8 @@ async function example() {
## PeerInfo<sup>8+</sup>
注册设备的信息。
此接口为系统接口。
**系统接口**
:此接口为系统接口。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.DistributedCore
...
...
@@ -2235,7 +2469,8 @@ async function example() {
## DeviceType<sup>8+</sup>
枚举,设备类型。
此接口为系统接口。
**系统接口**
:此接口为系统接口。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.DistributedCore
...
...
@@ -2267,7 +2502,8 @@ async function example() {
## Size<sup>8+</sup>
图片尺寸。
系统能力: 以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.Core
**系统能力:**
以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ---- | ---- | -------- |
...
...
@@ -2302,3 +2538,4 @@ async function example() {
| type | string | 是 | 媒体类型,包括:image, video, media,当前仅支持media类型 |
| count | number | 是 | 媒体选择,count = 1表示单选,count大于1表示多选。 |
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录