gallery

Gallery模块管理系统相册,支持从相册中选择图片或视频文件、保存图片或视频文件到相册等功能。通过plus.gallery获取相册管理对象。

方法:

对象:

回调方法:

权限:

5+功能模块(permissions)

{
// ...
"permissions":{
	// ...
	"Gallery": {
		"description": "系统相册"
	}
}
}
			

GalleryOptions

JSON对象,从相册中选择文件的参数

interface plus.gallery.GalleryOptions {
	readonly attribute Boolean animation;
	readonly attribute String filename;
	readonly attribute GalleryFilter filter;
	readonly attribute Number maximum;
	readonly attribute Boolean multiple;
	readonly attribute PopPosition popover;
	readonly attribute Array<String> selected;
	readonly attribute Boolean system;
	attribute Function onmaxed;
}
				

属性:

GalleryFilter

相册选择文件过滤类型

属性:

GallerySaveEvent

保存图片到相册成功事件

属性:

PopPosition

JSON对象,弹出拍照或摄像界面指示位置

属性:

GalleryPickSuccessCallback

单选系统相册图片成功的回调

void onSuccess( file ) {
	// Success code
}
				

说明:

系统相册中单选图片或视频文件成功的回调函数,在选择文件操作成功时调用。

参数:

返回值:

void : 无

GalleryMultiplePickSuccessCallback

多选系统相册图片成功的回调

void onSuccess( event ) {
	// Pick success
	var files = event.files; // 保存多选的图片或视频文件路径
}
				

说明:

系统相册中多选图片或视频文件成功的回调函数,在多选择文件操作成功时调用。

参数:

返回值:

void : 无

GallerySuccessCallback

操作系统相册成功的回调

void onSuccess(GallerySaveEvent event) {
	// Success code
}
				

说明:

系统相册操作成功的回调函数,在保存文件到系统相册操作成功时调用。

参数:

返回值:

void : 无

GalleryErrorCallback

系统相册操作失败的回调

void onError( error ) {
	// Handle error
	var code = error.code; // 错误编码
	var message = error.message; // 错误描述信息
}
				

说明:

系统相册操作失败的回调函数,在选择或保存图片操作失败时调用。

参数:

返回值:

void : 无