camera

Camera模块管理设备的摄像头,可用于拍照、摄像操作,通过plus.camera获取摄像头管理对象。

方法:

对象:

回调方法:

权限:

5+功能模块(permissions)

{
// ...
"permissions":{
	// ...
	"Camera": {
		"description": "摄像头"
	}
}
}
			

Camera

摄像头对象

interface Camera {
	readonly attribute String[] supportedImageResolutions;
	readonly attribute String[] supportedVideoResolutions;
	readonly attribute String[] supportedImageFormats;
	readonly attribute String[] supportedVideoFormats;
	function void captureImage(successCB, errorCB, option);
	function void startVideoCapture(successCB, errorCB, option);
	function void stopVideoCapture();
}
				

属性:

方法:

CameraOptions

JSON对象,调用摄像头的参数

interface CameraOptions {
	attribute String filename;
	attribute String format;
	attribute String index;
	attribute Number videoMaximumDuration;
	attribute Boolean optimize;
	attribute String resolution;
	attribute PopPosition popover;
}
				

属性:

PopPosition

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

属性:

CameraSuccessCallback

调用摄像头操作成功回调

void onSuccess( capturedFile ) {
	// Caputre image/video file code.
}
				

说明:

调用摄像头操作成功的回调函数,在拍照或摄像操作成功时调用,用于返回图片或视频文件的路径。

参数:

返回值:

void : 无

CameraErrorCallback

摄像头操作失败回调

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

参数:

返回值:

void : 无