提交 b8fda9b3 编写于 作者: Z zengyawen

update docs

Signed-off-by: Nzengyawen <zengyawen1@huawei.com>
上级 27beebc7
...@@ -5,14 +5,10 @@ ...@@ -5,14 +5,10 @@
## 导入模块 ## 导入模块
``` ```js
import camera from '@ohos.multimedia.camera'; import camera from '@ohos.multimedia.camera';
``` ```
## 权限
ohos.permission.CAMERA
## camera.getCameraManager ## camera.getCameraManager
getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): void getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): void
...@@ -30,7 +26,7 @@ getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): voi ...@@ -30,7 +26,7 @@ getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): voi
**示例:** **示例:**
``` ```js
camera.getCameraManager(context, (err, cameraManager) => { camera.getCameraManager(context, (err, cameraManager) => {
if (err) { if (err) {
console.error('Failed to get the CameraManager instance ${err.message}'); console.error('Failed to get the CameraManager instance ${err.message}');
...@@ -62,7 +58,7 @@ getCameraManager(context: Context): Promise<CameraManager\> ...@@ -62,7 +58,7 @@ getCameraManager(context: Context): Promise<CameraManager\>
**示例:** **示例:**
``` ```js
camera.getCameraManager(context).then((cameraManager) => { camera.getCameraManager(context).then((cameraManager) => {
console.log('Promise returned with the CameraManager instance.'); console.log('Promise returned with the CameraManager instance.');
}) })
...@@ -72,55 +68,65 @@ camera.getCameraManager(context).then((cameraManager) => { ...@@ -72,55 +68,65 @@ camera.getCameraManager(context).then((cameraManager) => {
枚举,相机状态。 枚举,相机状态。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 默认值 | 说明 | | 名称 | | 说明 |
| ------------------------- | ------ | ------------ | | ------------------------- | ---- | ------------ |
| CAMERA_STATUS_APPEAR | 0 | 相机存在。 | | CAMERA_STATUS_APPEAR | 0 | 相机存在。 |
| CAMERA_STATUS_DISAPPEAR | 1 | 相机不存在。 | | CAMERA_STATUS_DISAPPEAR | 1 | 相机不存在。 |
| CAMERA_STATUS_AVAILABLE | 2 | 相机就绪。 | | CAMERA_STATUS_AVAILABLE | 2 | 相机就绪。 |
| CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪。 | | CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪。 |
## CameraPosition ## CameraPosition
枚举,相机方向。 枚举,相机方向。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 默认值 | 说明 | | 名称 | | 说明 |
| --------------------------- | ------ | ---------------- | | --------------------------- | ---- | ---------------- |
| CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方向相机。 | | CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方向相机。 |
| CAMERA_POSITION_BACK | 1 | 后置相机。 | | CAMERA_POSITION_BACK | 1 | 后置相机。 |
| CAMERA_POSITION_FRONT | 2 | 前置相机。 | | CAMERA_POSITION_FRONT | 2 | 前置相机。 |
## CameraType ## CameraType
枚举,相机类型。 枚举,相机类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 默认值 | 说明 | | 名称 | | 说明 |
| ----------------------- | ------ | ---------------- | | ----------------------- | ---- | ---------------- |
| CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型。 | | CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型。 |
| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 | | CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 |
| CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机。 | | CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机。 |
| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 | | CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 |
| CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机。 | | CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机。 |
## ConnectionType ## ConnectionType
枚举,相机连接类型。 枚举,相机连接类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ---------------------------- | ---- | ------------- |
| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。 |
| CAMERA_CONNECTION_USB_PLUGIN | 1 | 外置USB相机。 |
| CAMERA_CONNECTION_REMOTE | 2 | 分布式相机。 |
## Size
| 名称 | 默认值 | 说明 | 用于表示相机预览、照片、视频支持的尺寸大小。
| ---------------------------- | ------ | ------------- |
| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。 |
| CAMERA_CONNECTION_USB_PLUGIN | 1 | 外置USB相机。 |
| CAMERA_CONNECTION_REMOTE | 2 | 分布式相机。 |
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ---- | ---- | ------------ |
| height | string | 是 | 是 | 图像的高度。 |
| width | number | 是 | 是 | 图像的宽度。 |
## CameraManager ## CameraManager
...@@ -142,7 +148,7 @@ getCameras(callback: AsyncCallback<Array<Camera\>\>): void ...@@ -142,7 +148,7 @@ getCameras(callback: AsyncCallback<Array<Camera\>\>): void
**示例:** **示例:**
``` ```js
cameraManager.getCameras((err, cameras) => { cameraManager.getCameras((err, cameras) => {
if (err) { if (err) {
console.error('Failed to get the cameras. ${err.message}'); console.error('Failed to get the cameras. ${err.message}');
...@@ -169,7 +175,7 @@ getCameras(): Promise<Array<Camera\>\> ...@@ -169,7 +175,7 @@ getCameras(): Promise<Array<Camera\>\>
**示例:** **示例:**
``` ```js
cameraManager.getCameras().then((cameraArray) => { cameraManager.getCameras().then((cameraArray) => {
console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); console.log('Promise returned with an array of supported cameras: ' + cameraArray.length);
}) })
...@@ -181,18 +187,20 @@ createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput\>): void ...@@ -181,18 +187,20 @@ createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput\>): void
使用相机ID异步创建CameraInput实例,通过注册回调函数获取结果。 使用相机ID异步创建CameraInput实例,通过注册回调函数获取结果。
**需要权限:** ohos.permission.CAMERA
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **参数:**
| 名称 | 默认值 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ----------------------------------- | | -------- | ------------------------------------------- | ---- | ----------------------------------- |
| cameraId | string | 是 | 指定相机ID。 | | cameraId | string | 是 | 指定相机ID。 |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | | callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 |
**示例:** **示例:**
``` ```js
cameraManager.createCameraInput(cameraId, (err, cameraInput) => { cameraManager.createCameraInput(cameraId, (err, cameraInput) => {
if (err) { if (err) {
console.error('Failed to create the CameraInput instance. ${err.message}'); console.error('Failed to create the CameraInput instance. ${err.message}');
...@@ -208,11 +216,13 @@ createCameraInput(cameraId: string): Promise<CameraInput\> ...@@ -208,11 +216,13 @@ createCameraInput(cameraId: string): Promise<CameraInput\>
使用相机ID异步创建CameraInput实例,通过Promise获取结果。 使用相机ID异步创建CameraInput实例,通过Promise获取结果。
**需要权限:** ohos.permission.CAMERA
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **参数:**
| 名称 | 默认值 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------ | | -------- | ------ | ---- | ------------ |
| cameraId | string | 是 | 指定相机ID。 | | cameraId | string | 是 | 指定相机ID。 |
...@@ -224,7 +234,7 @@ createCameraInput(cameraId: string): Promise<CameraInput\> ...@@ -224,7 +234,7 @@ createCameraInput(cameraId: string): Promise<CameraInput\>
**示例:** **示例:**
``` ```js
cameraManager.createCameraInput(cameraId).then((cameraInput) => { cameraManager.createCameraInput(cameraId).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance'); console.log('Promise returned with the CameraInput instance');
}) })
...@@ -236,6 +246,8 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal ...@@ -236,6 +246,8 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
使用相机位置和相机类型异步创建CameraInput实例,通过注册回调函数获取结果。 使用相机位置和相机类型异步创建CameraInput实例,通过注册回调函数获取结果。
**需要权限:** ohos.permission.CAMERA
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **参数:**
...@@ -248,8 +260,8 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal ...@@ -248,8 +260,8 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
**示例:** **示例:**
``` ```js
cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
if (err) { if (err) {
console.error('Failed to create the CameraInput instance. ${err.message}'); console.error('Failed to create the CameraInput instance. ${err.message}');
return; return;
...@@ -264,6 +276,8 @@ createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInp ...@@ -264,6 +276,8 @@ createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInp
使用相机位置和相机类型异步创建CameraInput实例,通过Promise获取结果。 使用相机位置和相机类型异步创建CameraInput实例,通过Promise获取结果。
**需要权限:** ohos.permission.CAMERA
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **参数:**
...@@ -281,8 +295,8 @@ createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInp ...@@ -281,8 +295,8 @@ createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInp
**示例:** **示例:**
``` ```js
cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => { cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance.'); console.log('Promise returned with the CameraInput instance.');
}) })
``` ```
...@@ -304,8 +318,12 @@ on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void ...@@ -304,8 +318,12 @@ on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void
**示例:** **示例:**
``` ```js
cameraManager.on('cameraStatus', (cameraStatusInfo) => { cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
if (err) {
console.error('Failed to get cameraStatus callback. ${err.message}');
return;
}
console.log('camera : ' + cameraStatusInfo.camera.cameraId); console.log('camera : ' + cameraStatusInfo.camera.cameraId);
console.log('status: ' + cameraStatusInfo.status); console.log('status: ' + cameraStatusInfo.status);
}) })
...@@ -315,7 +333,7 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { ...@@ -315,7 +333,7 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => {
调用[camera.getCameraManager](#cameragetcameramanager)后,将返回Camera实例,包括相机ID、位置、类型、连接类型等相机相关的元数据。 调用[camera.getCameraManager](#cameragetcameramanager)后,将返回Camera实例,包括相机ID、位置、类型、连接类型等相机相关的元数据。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core。
| 名称 | 类型 | 只读 | 说明 | | 名称 | 类型 | 只读 | 说明 |
| -------------- | --------------------------------- | ---- | -------------- | | -------------- | --------------------------------- | ---- | -------------- |
...@@ -326,24 +344,23 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { ...@@ -326,24 +344,23 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => {
**示例:** **示例:**
``` ```js
async function getCameraInfo() { async function getCameraInfo("cameraId") {
var cameraManager = await camera.getCameraManager(); var cameraManager = await camera.getCameraManager();
var cameras = await cameraManager.getCameras(); var cameras = await cameraManager.getCameras();
var cameraObj = cameras[0]; var cameraObj = cameras[0];
var cameraId = cameraObj.cameraId; var cameraId = cameraObj.cameraId;
var cameraPosition = cameraObj.cameraPosition; var cameraPosition = cameraObj.cameraPosition;
var cameraType = cameraObj.cameraType; var cameraType = cameraObj.cameraType;
var cameraId = cameraObj.connectionType; var connectionType = cameraObj.connectionType;
} }
``` ```
## CameraStatusInfo ## CameraStatusInfo
相机管理器回调返回的接口实例,表示相机状态信息。 相机管理器回调返回的接口实例,表示相机状态信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core。
| 名称 | 类型 | 说明 | | 名称 | 类型 | 说明 |
| ------ | ----------------------------- | ---------- | | ------ | ----------------------------- | ---------- |
...@@ -371,7 +388,7 @@ getCameraId(callback: AsyncCallback<string\>\): void ...@@ -371,7 +388,7 @@ getCameraId(callback: AsyncCallback<string\>\): void
**示例:** **示例:**
``` ```js
cameraInput.getCameraId((err, cameraId) => { cameraInput.getCameraId((err, cameraId) => {
if (err) { if (err) {
console.error('Failed to get the camera ID. ${err.message}'); console.error('Failed to get the camera ID. ${err.message}');
...@@ -397,7 +414,7 @@ getCameraId(): Promise<string\> ...@@ -397,7 +414,7 @@ getCameraId(): Promise<string\>
**示例:** **示例:**
``` ```js
cameraInput.getCameraId().then((cameraId) => { cameraInput.getCameraId().then((cameraId) => {
console.log('Promise returned with the camera ID:' + cameraId); console.log('Promise returned with the camera ID:' + cameraId);
}) })
...@@ -420,7 +437,7 @@ hasFlash(callback: AsyncCallback<boolean\>): void ...@@ -420,7 +437,7 @@ hasFlash(callback: AsyncCallback<boolean\>): void
**示例:** **示例:**
``` ```js
cameraInput.hasFlash((err, status) => { cameraInput.hasFlash((err, status) => {
if (err) { if (err) {
console.error('Failed to check whether the device has flash light. ${err.message}'); console.error('Failed to check whether the device has flash light. ${err.message}');
...@@ -446,7 +463,7 @@ hasFlash(): Promise<boolean\> ...@@ -446,7 +463,7 @@ hasFlash(): Promise<boolean\>
**示例:** **示例:**
``` ```js
cameraInput.hasFlash().then((status) => { cameraInput.hasFlash().then((status) => {
console.log('Promise returned with the flash light support status:' + status); console.log('Promise returned with the flash light support status:' + status);
}) })
...@@ -469,8 +486,8 @@ isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): v ...@@ -469,8 +486,8 @@ isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): v
**示例:** **示例:**
``` ```js
cameraInput.isFlashModeSupported(flashMode, (err, status) => { cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
if (err) { if (err) {
console.error('Failed to check whether the flash mode is supported. ${err.message}'); console.error('Failed to check whether the flash mode is supported. ${err.message}');
return; return;
...@@ -501,8 +518,8 @@ isFlashModeSupported(flashMode: FlashMode): Promise<boolean\> ...@@ -501,8 +518,8 @@ isFlashModeSupported(flashMode: FlashMode): Promise<boolean\>
**示例:** **示例:**
``` ```js
cameraInput.isFlashModeSupported(flashMode).then((status) => { cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
console.log('Promise returned with flash mode support status.' + status); console.log('Promise returned with flash mode support status.' + status);
}) })
``` ```
...@@ -529,8 +546,8 @@ setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void ...@@ -529,8 +546,8 @@ setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
cameraInput.setFlashMode(flashMode, (err) => { cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
if (err) { if (err) {
console.error('Failed to set the flash mode ${err.message}'); console.error('Failed to set the flash mode ${err.message}');
return; return;
...@@ -566,8 +583,8 @@ setFlashMode(flashMode: FlashMode): Promise<void\> ...@@ -566,8 +583,8 @@ setFlashMode(flashMode: FlashMode): Promise<void\>
**示例:** **示例:**
``` ```js
cameraInput.setFlashMode(flashMode).then(() => { cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFlashMode.'); console.log('Promise returned with the successful execution of setFlashMode.');
}) })
``` ```
...@@ -588,7 +605,7 @@ getFlashMode(callback: AsyncCallback<FlashMode\>): void ...@@ -588,7 +605,7 @@ getFlashMode(callback: AsyncCallback<FlashMode\>): void
**示例:** **示例:**
``` ```js
cameraInput.getFlashMode((err, flashMode) => { cameraInput.getFlashMode((err, flashMode) => {
if (err) { if (err) {
console.error('Failed to get the flash mode ${err.message}'); console.error('Failed to get the flash mode ${err.message}');
...@@ -614,7 +631,7 @@ getFlashMode(): Promise<FlashMode\> ...@@ -614,7 +631,7 @@ getFlashMode(): Promise<FlashMode\>
**示例:** **示例:**
``` ```js
cameraInput.getFlashMode().then((flashMode) => { cameraInput.getFlashMode().then((flashMode) => {
console.log('Promise returned with current flash mode : ' + flashMode); console.log('Promise returned with current flash mode : ' + flashMode);
}) })
...@@ -637,8 +654,8 @@ isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void ...@@ -637,8 +654,8 @@ isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void
**示例:** **示例:**
``` ```js
cameraInput.isFocusModeSupported(afMode, (err, status) => { cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
if (err) { if (err) {
console.error('Failed to check whether the focus mode is supported. ${err.message}'); console.error('Failed to check whether the focus mode is supported. ${err.message}');
return; return;
...@@ -669,8 +686,8 @@ isFocusModeSupported(afMode: FocusMode): Promise<boolean\> ...@@ -669,8 +686,8 @@ isFocusModeSupported(afMode: FocusMode): Promise<boolean\>
**示例:** **示例:**
``` ```js
cameraInput.isFocusModeSupported(afMode).then((status) => { cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
console.log('Promise returned with focus mode support status.' + status); console.log('Promise returned with focus mode support status.' + status);
}) })
``` ```
...@@ -694,8 +711,8 @@ setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void ...@@ -694,8 +711,8 @@ setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
cameraInput.setFocusMode(afMode, (err) => { cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
if (err) { if (err) {
console.error('Failed to set the focus mode ${err.message}'); console.error('Failed to set the focus mode ${err.message}');
return; return;
...@@ -728,8 +745,8 @@ setFocusMode(afMode: FocusMode): Promise<void\> ...@@ -728,8 +745,8 @@ setFocusMode(afMode: FocusMode): Promise<void\>
**示例:** **示例:**
``` ```js
cameraInput.setFocusMode(afMode).then(() => { cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFocusMode.'); console.log('Promise returned with the successful execution of setFocusMode.');
}) })
``` ```
...@@ -750,7 +767,7 @@ getFocusMode(callback: AsyncCallback<FocusMode\>): void ...@@ -750,7 +767,7 @@ getFocusMode(callback: AsyncCallback<FocusMode\>): void
**示例:** **示例:**
``` ```js
cameraInput.getFocusMode((err, afMode) => { cameraInput.getFocusMode((err, afMode) => {
if (err) { if (err) {
console.error('Failed to get the focus mode ${err.message}'); console.error('Failed to get the focus mode ${err.message}');
...@@ -776,7 +793,7 @@ getFocusMode(): Promise<FocusMode\> ...@@ -776,7 +793,7 @@ getFocusMode(): Promise<FocusMode\>
**示例:** **示例:**
``` ```js
cameraInput.getFocusMode().then((afMode) => { cameraInput.getFocusMode().then((afMode) => {
console.log('Promise returned with current focus mode : ' + afMode); console.log('Promise returned with current focus mode : ' + afMode);
}) })
...@@ -798,7 +815,7 @@ getZoomRatioRange\(callback: AsyncCallback<Array<number\>\>\): void ...@@ -798,7 +815,7 @@ getZoomRatioRange\(callback: AsyncCallback<Array<number\>\>\): void
**示例:** **示例:**
``` ```js
cameraInput.getZoomRatioRange((err, zoomRatioRange) => { cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
if (err) { if (err) {
console.error('Failed to get the zoom ratio range. ${err.message}'); console.error('Failed to get the zoom ratio range. ${err.message}');
...@@ -824,7 +841,7 @@ getZoomRatioRange\(\): Promise<Array<number\>\> ...@@ -824,7 +841,7 @@ getZoomRatioRange\(\): Promise<Array<number\>\>
**示例:** **示例:**
``` ```js
cameraInput.getZoomRatioRange().then((zoomRatioRange) => { cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length);
}) })
...@@ -847,8 +864,8 @@ setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void ...@@ -847,8 +864,8 @@ setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
cameraInput.setZoomRatio(zoomRatio, (err) => { cameraInput.setZoomRatio(1, (err) => {
if (err) { if (err) {
console.error('Failed to set the zoom ratio value ${err.message}'); console.error('Failed to set the zoom ratio value ${err.message}');
return; return;
...@@ -879,8 +896,8 @@ setZoomRatio(zoomRatio: number): Promise<void\> ...@@ -879,8 +896,8 @@ setZoomRatio(zoomRatio: number): Promise<void\>
**示例:** **示例:**
``` ```js
cameraInput.setZoomRatio(zoomRatio).then(() => { cameraInput.setZoomRatio(1).then(() => {
console.log('Promise returned with the successful execution of setZoomRatio.'); console.log('Promise returned with the successful execution of setZoomRatio.');
}) })
``` ```
...@@ -901,7 +918,7 @@ getZoomRatio(callback: AsyncCallback<number\>): void ...@@ -901,7 +918,7 @@ getZoomRatio(callback: AsyncCallback<number\>): void
**示例:** **示例:**
``` ```js
cameraInput.getZoomRatio((err, zoomRatio) => { cameraInput.getZoomRatio((err, zoomRatio) => {
if (err) { if (err) {
console.error('Failed to get the zoom ratio ${err.message}'); console.error('Failed to get the zoom ratio ${err.message}');
...@@ -927,7 +944,7 @@ getZoomRatio(): Promise<number\> ...@@ -927,7 +944,7 @@ getZoomRatio(): Promise<number\>
**示例:** **示例:**
``` ```js
cameraInput.getZoomRatio().then((zoomRatio) => { cameraInput.getZoomRatio().then((zoomRatio) => {
console.log('Promise returned with current zoom ratio : ' + zoomRatio); console.log('Promise returned with current zoom ratio : ' + zoomRatio);
}) })
...@@ -949,8 +966,8 @@ release\(callback: AsyncCallback<void\>\): void ...@@ -949,8 +966,8 @@ release\(callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
camera.release((err) => { cameraInput.release((err) => {
if (err) { if (err) {
console.error('Failed to release the CameraInput instance ${err.message}'); console.error('Failed to release the CameraInput instance ${err.message}');
return; return;
...@@ -975,7 +992,7 @@ release(): Promise<void\> ...@@ -975,7 +992,7 @@ release(): Promise<void\>
**示例:** **示例:**
``` ```js
cameraInput.release().then(() => { cameraInput.release().then(() => {
console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
}) })
...@@ -998,7 +1015,7 @@ on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void ...@@ -998,7 +1015,7 @@ on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void
**示例:** **示例:**
``` ```js
cameraInput.on('focusStateChange', (focusState) => { cameraInput.on('focusStateChange', (focusState) => {
console.log('Focus state : ' + focusState); console.log('Focus state : ' + focusState);
}) })
...@@ -1014,14 +1031,14 @@ on(type: 'error', callback: ErrorCallback<CameraInputError\>): void ...@@ -1014,14 +1031,14 @@ on(type: 'error', callback: ErrorCallback<CameraInputError\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| :------- | :------------------------------- | :--- | :---------------------------------------------- | | :------- | :------------------------------- | :--- | :----------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即CameraInput错误事件。 | | type | string | 是 | 监听事件,固定为'error',即CameraInput错误事件。 |
| callback | ErrorCallback<CameraInputError\> | 是 | 回调函数,用于获取结果。 | | callback | ErrorCallback<CameraInputError\> | 是 | 回调函数,用于获取结果。 |
**示例:** **示例:**
``` ```js
cameraInput.on('error', (cameraInputError) => { cameraInput.on('error', (cameraInputError) => {
console.log('Camera input error code: ' + cameraInputError.code); console.log('Camera input error code: ' + cameraInputError.code);
}) })
...@@ -1032,39 +1049,39 @@ cameraInput.on('error', (cameraInputError) => { ...@@ -1032,39 +1049,39 @@ cameraInput.on('error', (cameraInputError) => {
枚举,闪光灯模式。 枚举,闪光灯模式。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core。
| 名称 | 默认值 | 说明 | | 名称 | | 说明 |
| ---------------------- | ------ | ------------ | | ---------------------- | ---- | ------------ |
| FLASH_MODE_CLOSE | 0 | 闪光灯关闭。 | | FLASH_MODE_CLOSE | 0 | 闪光灯关闭。 |
| FLASH_MODE_OPEN | 1 | 闪光灯开启。 | | FLASH_MODE_OPEN | 1 | 闪光灯开启。 |
| FLASH_MODE_AUTO | 2 | 自动闪光灯。 | | FLASH_MODE_AUTO | 2 | 自动闪光灯。 |
| FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。 | | FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。 |
## FocusMode ## FocusMode
枚举,焦距模式。 枚举,焦距模式。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core。
| 名称 | 默认值 | 说明 | | 名称 | | 说明 |
| -------------------------- | ------ | ------------------ | | -------------------------- | ---- | ------------------ |
| FOCUS_MODE_MANUAL | 0 | 手动变焦模式。 | | FOCUS_MODE_MANUAL | 0 | 手动变焦模式。 |
| FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动变焦模式。 | | FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动变焦模式。 |
| FOCUS_MODE_AUTO | 2 | 自动变焦模式。 | | FOCUS_MODE_AUTO | 2 | 自动变焦模式。 |
| FOCUS_MODE_LOCKED | 3 | 定焦模式。 | | FOCUS_MODE_LOCKED | 3 | 定焦模式。 |
## FocusState ## FocusState
枚举,焦距状态。 枚举,焦距状态。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core。
| 名称 | 默认值 | 说明 | | 名称 | | 说明 |
| --------------------- | ------ | ------------ | | --------------------- | ---- | ------------ |
| FOCUS_STATE_SCAN | 0 | 扫描状态。 | | FOCUS_STATE_SCAN | 0 | 扫描状态。 |
| FOCUS_STATE_FOCUSED | 1 | 相机已对焦。 | | FOCUS_STATE_FOCUSED | 1 | 相机已对焦。 |
| FOCUS_STATE_UNFOCUSED | 2 | 相机未对焦。 | | FOCUS_STATE_UNFOCUSED | 2 | 相机未对焦。 |
## camera.createCaptureSession ## camera.createCaptureSession
...@@ -1083,7 +1100,7 @@ createCaptureSession\(context: Context, callback: AsyncCallback<CaptureSession\> ...@@ -1083,7 +1100,7 @@ createCaptureSession\(context: Context, callback: AsyncCallback<CaptureSession\>
**示例:** **示例:**
``` ```js
camera.createCaptureSession((context), (err, captureSession) => { camera.createCaptureSession((context), (err, captureSession) => {
if (err) { if (err) {
console.error('Failed to create the CaptureSession instance. ${err.message}'); console.error('Failed to create the CaptureSession instance. ${err.message}');
...@@ -1115,7 +1132,7 @@ createCaptureSession(context: Context\): Promise<CaptureSession\>; ...@@ -1115,7 +1132,7 @@ createCaptureSession(context: Context\): Promise<CaptureSession\>;
**示例:** **示例:**
``` ```js
camera.createCaptureSession(context).then((captureSession) => { camera.createCaptureSession(context).then((captureSession) => {
console.log('Promise returned with the CaptureSession instance'); console.log('Promise returned with the CaptureSession instance');
}) })
...@@ -1141,7 +1158,7 @@ beginConfig\(callback: AsyncCallback<void\>\): void ...@@ -1141,7 +1158,7 @@ beginConfig\(callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.beginConfig((err) => { captureSession.beginConfig((err) => {
if (err) { if (err) {
console.error('Failed to start the configuration. ${err.message}'); console.error('Failed to start the configuration. ${err.message}');
...@@ -1168,7 +1185,7 @@ beginConfig\(\): Promise<void\> ...@@ -1168,7 +1185,7 @@ beginConfig\(\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.beginConfig().then(() => { captureSession.beginConfig().then(() => {
console.log('Promise returned to indicate the begin config success.'); console.log('Promise returned to indicate the begin config success.');
}) })
...@@ -1190,7 +1207,7 @@ commitConfig\(callback: AsyncCallback<void\>\): void ...@@ -1190,7 +1207,7 @@ commitConfig\(callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.commitConfig((err) => { captureSession.commitConfig((err) => {
if (err) { if (err) {
console.error('Failed to commit the configuration. ${err.message}'); console.error('Failed to commit the configuration. ${err.message}');
...@@ -1216,7 +1233,7 @@ commitConfig\(\): Promise<void\> ...@@ -1216,7 +1233,7 @@ commitConfig\(\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.commitConfig().then(() => { captureSession.commitConfig().then(() => {
console.log('Promise returned to indicate the commit config success.'); console.log('Promise returned to indicate the commit config success.');
}) })
...@@ -1239,7 +1256,7 @@ addInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void ...@@ -1239,7 +1256,7 @@ addInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.addInput(cameraInput, (err) => { captureSession.addInput(cameraInput, (err) => {
if (err) { if (err) {
console.error('Failed to add the CameraInput instance. ${err.message}'); console.error('Failed to add the CameraInput instance. ${err.message}');
...@@ -1271,7 +1288,7 @@ addInput\(cameraInput: CameraInput\): Promise<void\> ...@@ -1271,7 +1288,7 @@ addInput\(cameraInput: CameraInput\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.addInput(cameraInput).then(() => { captureSession.addInput(cameraInput).then(() => {
console.log('Promise used to indicate that the CameraInput instance is added.'); console.log('Promise used to indicate that the CameraInput instance is added.');
}) })
...@@ -1294,7 +1311,7 @@ addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): void ...@@ -1294,7 +1311,7 @@ addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.addOutput(previewOutput, (err) => { captureSession.addOutput(previewOutput, (err) => {
if (err) { if (err) {
console.error('Failed to add the PreviewOutput instance ${err.message}'); console.error('Failed to add the PreviewOutput instance ${err.message}');
...@@ -1326,7 +1343,7 @@ addOutput\(previewOutput: PreviewOutput\): Promise<void\> ...@@ -1326,7 +1343,7 @@ addOutput\(previewOutput: PreviewOutput\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.addOutput(previewOutput).then(() => { captureSession.addOutput(previewOutput).then(() => {
console.log('Promise used to indicate that the PreviewOutput instance is added.'); console.log('Promise used to indicate that the PreviewOutput instance is added.');
}) })
...@@ -1349,7 +1366,7 @@ addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback<void\>\): void ...@@ -1349,7 +1366,7 @@ addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.addOutput(photoOutput, (err) => { captureSession.addOutput(photoOutput, (err) => {
if (err) { if (err) {
console.error('Failed to add the PhotoOutput instance ${err.message}'); console.error('Failed to add the PhotoOutput instance ${err.message}');
...@@ -1381,7 +1398,7 @@ addOutput\(photoOutput: PhotoOutput\): Promise<void\> ...@@ -1381,7 +1398,7 @@ addOutput\(photoOutput: PhotoOutput\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.addOutput(photoOutput).then(() => { captureSession.addOutput(photoOutput).then(() => {
console.log('Promise used to indicate that the PhotoOutput instance is added.'); console.log('Promise used to indicate that the PhotoOutput instance is added.');
}) })
...@@ -1404,7 +1421,7 @@ addOutput\(videoOutput: VideoOutput, callback: AsyncCallback<void\>\): void ...@@ -1404,7 +1421,7 @@ addOutput\(videoOutput: VideoOutput, callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.addOutput(videoOutput, (err) => { captureSession.addOutput(videoOutput, (err) => {
if (err) { if (err) {
console.error('Failed to add the VideoOutput instance ${err.message}'); console.error('Failed to add the VideoOutput instance ${err.message}');
...@@ -1436,7 +1453,7 @@ addOutput\(videoOutput: VideoOutput\): Promise<void\> ...@@ -1436,7 +1453,7 @@ addOutput\(videoOutput: VideoOutput\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.addOutput(videoOutput).then(() => { captureSession.addOutput(videoOutput).then(() => {
console.log('Promise used to indicate that the VideoOutput instance is added.'); console.log('Promise used to indicate that the VideoOutput instance is added.');
}) })
...@@ -1459,7 +1476,7 @@ removeInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void ...@@ -1459,7 +1476,7 @@ removeInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.removeInput(cameraInput, (err) => { captureSession.removeInput(cameraInput, (err) => {
if (err) { if (err) {
console.error('Failed to remove the CameraInput instance. ${err.message}'); console.error('Failed to remove the CameraInput instance. ${err.message}');
...@@ -1491,7 +1508,7 @@ removeInput\(cameraInput: CameraInput\): Promise<void\> ...@@ -1491,7 +1508,7 @@ removeInput\(cameraInput: CameraInput\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.removeInput(cameraInput).then(() => { captureSession.removeInput(cameraInput).then(() => {
console.log('Promise returned to indicate that the cameraInput instance is removed.'); console.log('Promise returned to indicate that the cameraInput instance is removed.');
}) })
...@@ -1514,7 +1531,7 @@ removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): vo ...@@ -1514,7 +1531,7 @@ removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): vo
**示例:** **示例:**
``` ```js
captureSession.removeOutput(previewOutput, (err) => { captureSession.removeOutput(previewOutput, (err) => {
if (err) { if (err) {
console.error('Failed to remove the PreviewOutput instance. ${err.message}'); console.error('Failed to remove the PreviewOutput instance. ${err.message}');
...@@ -1548,7 +1565,7 @@ removeOutput(previewOutput: PreviewOutput): Promise<void\> ...@@ -1548,7 +1565,7 @@ removeOutput(previewOutput: PreviewOutput): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.removeOutput(previewOutput).then(() => { captureSession.removeOutput(previewOutput).then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); console.log('Promise returned to indicate that the PreviewOutput instance is removed.');
}) })
...@@ -1571,7 +1588,7 @@ removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void\>): void ...@@ -1571,7 +1588,7 @@ removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
captureSession.removeOutput(photoOutput, (err) => { captureSession.removeOutput(photoOutput, (err) => {
if (err) { if (err) {
console.error('Failed to remove the PhotoOutput instance. ${err.message}'); console.error('Failed to remove the PhotoOutput instance. ${err.message}');
...@@ -1605,7 +1622,7 @@ removeOutput(photoOutput: PhotoOutput): Promise<void\> ...@@ -1605,7 +1622,7 @@ removeOutput(photoOutput: PhotoOutput): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.removeOutput(photoOutput).then(() => { captureSession.removeOutput(photoOutput).then(() => {
console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); console.log('Promise returned to indicate that the PhotoOutput instance is removed.');
}) })
...@@ -1628,7 +1645,7 @@ removeOutput(videoOutput: VideoOutput, callback: AsyncCallback<void\>): void ...@@ -1628,7 +1645,7 @@ removeOutput(videoOutput: VideoOutput, callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
captureSession.removeOutput(videoOutput, (err) => { captureSession.removeOutput(videoOutput, (err) => {
if (err) { if (err) {
console.error('Failed to remove the VideoOutput instance. ${err.message}'); console.error('Failed to remove the VideoOutput instance. ${err.message}');
...@@ -1662,7 +1679,7 @@ removeOutput(videoOutput: VideoOutput): Promise<void\> ...@@ -1662,7 +1679,7 @@ removeOutput(videoOutput: VideoOutput): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.removeOutput(videoOutput).then(() => { captureSession.removeOutput(videoOutput).then(() => {
console.log('Promise returned to indicate that the VideoOutput instance is removed.'); console.log('Promise returned to indicate that the VideoOutput instance is removed.');
}) })
...@@ -1684,7 +1701,7 @@ start\(callback: AsyncCallback<void\>\): void ...@@ -1684,7 +1701,7 @@ start\(callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.start((err) => { captureSession.start((err) => {
if (err) { if (err) {
console.error('Failed to start the session ${err.message}'); console.error('Failed to start the session ${err.message}');
...@@ -1710,7 +1727,7 @@ start\(\): Promise<void\> ...@@ -1710,7 +1727,7 @@ start\(\): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.start().then(() => { captureSession.start().then(() => {
console.log('Promise returned to indicate the session start success.'); console.log('Promise returned to indicate the session start success.');
}) })
...@@ -1733,7 +1750,7 @@ stop\(callback: AsyncCallback<void\>\): void ...@@ -1733,7 +1750,7 @@ stop\(callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.stop((err) => { captureSession.stop((err) => {
if (err) { if (err) {
console.error('Failed to stop the session ${err.message}'); console.error('Failed to stop the session ${err.message}');
...@@ -1759,7 +1776,7 @@ stop(): Promise<void\> ...@@ -1759,7 +1776,7 @@ stop(): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.stop().then(() => { captureSession.stop().then(() => {
console.log('Promise returned to indicate the session stop success.'); console.log('Promise returned to indicate the session stop success.');
}) })
...@@ -1781,7 +1798,7 @@ release\(callback: AsyncCallback<void\>\): void ...@@ -1781,7 +1798,7 @@ release\(callback: AsyncCallback<void\>\): void
**示例:** **示例:**
``` ```js
captureSession.release((err) => { captureSession.release((err) => {
if (err) { if (err) {
console.error('Failed to release the CaptureSession instance ${err.message}'); console.error('Failed to release the CaptureSession instance ${err.message}');
...@@ -1807,7 +1824,7 @@ release(): Promise<void\> ...@@ -1807,7 +1824,7 @@ release(): Promise<void\>
**示例:** **示例:**
``` ```js
captureSession.release().then(() => { captureSession.release().then(() => {
console.log('Promise returned to indicate that the CaptureSession instance is released successfully.'); console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
}) })
...@@ -1823,19 +1840,39 @@ on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void ...@@ -1823,19 +1840,39 @@ on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| :------- | :---------------------------------- | :--- | :-------------------------------------------- | | :------- | :---------------------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 | | type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 |
| callback | ErrorCallback<CaptureSessionError\> | 是 | 回调函数,用于获取错误信息。 | | callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
``` ```js
captureSession.on('error', (captureSessionError) => { captureSession.on('error', (captureSessionError) => {
console.log('Capture session error code: ' + captureSessionError.code); console.log('Capture session error code: ' + captureSessionError.code);
}) })
``` ```
## CaptureSessionErrorCode
枚举,拍照会话的错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
## CaptureSessionError
拍照会话错误对象。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 说明 |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CaptureSessionError](#capturesessionerror) | CaptureSession中的错误码。 |
## camera.createPreviewOutput ## camera.createPreviewOutput
createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput\>): void createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput\>): void
...@@ -1853,8 +1890,8 @@ createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput\>): ...@@ -1853,8 +1890,8 @@ createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput\>):
**示例:** **示例:**
``` ```js
camera.createPreviewOutput((surfaceId), (err, previewOutput) => { camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => {
if (err) { if (err) {
console.error('Failed to create the PreviewOutput instance. ${err.message}'); console.error('Failed to create the PreviewOutput instance. ${err.message}');
return; return;
...@@ -1885,8 +1922,8 @@ createPreviewOutput(surfaceId: string): Promise\<PreviewOutput> ...@@ -1885,8 +1922,8 @@ createPreviewOutput(surfaceId: string): Promise\<PreviewOutput>
**示例:** **示例:**
``` ```js
camera.createPreviewOutput(surfaceId).then((previewOutput) => { camera.createPreviewOutput("surfaceId").then((previewOutput) => {
console.log('Promise returned with the PreviewOutput instance'); console.log('Promise returned with the PreviewOutput instance');
}) })
``` ```
...@@ -1911,7 +1948,7 @@ release(callback: AsyncCallback<void\>): void ...@@ -1911,7 +1948,7 @@ release(callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
previewOutput.release((err) => { previewOutput.release((err) => {
if (err) { if (err) {
console.error('Failed to release the PreviewOutput instance ${err.message}'); console.error('Failed to release the PreviewOutput instance ${err.message}');
...@@ -1938,7 +1975,7 @@ release(): Promise<void\> ...@@ -1938,7 +1975,7 @@ release(): Promise<void\>
**示例:** **示例:**
``` ```js
previewOutput.release().then(() => { previewOutput.release().then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
}) })
...@@ -1961,7 +1998,7 @@ on(type: 'frameStart', callback: AsyncCallback<void\>): void ...@@ -1961,7 +1998,7 @@ on(type: 'frameStart', callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
previewOutput.on('frameStart', () => { previewOutput.on('frameStart', () => {
console.log('Preview frame started'); console.log('Preview frame started');
}) })
...@@ -1984,7 +2021,7 @@ on(type: 'frameEnd', callback: AsyncCallback<void\>): void ...@@ -1984,7 +2021,7 @@ on(type: 'frameEnd', callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
previewOutput.on('frameEnd', () => { previewOutput.on('frameEnd', () => {
console.log('Preview frame ended'); console.log('Preview frame ended');
}) })
...@@ -2000,19 +2037,39 @@ on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void ...@@ -2000,19 +2037,39 @@ on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| :------- | :--------------------------------- | :--- | :-------------------------------------------- | | :------- | :----------------------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。 | | type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。 |
| callback | ErrorCallback<PreviewOutputError\> | 是 | 回调函数,用于获取错误信息。 | | callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
``` ```js
previewOutput.on('error', (previewOutputError) => { previewOutput.on('error', (previewOutputError) => {
console.log('Preview output error code: ' + previewOutputError.code); console.log('Preview output error code: ' + previewOutputError.code);
}) })
``` ```
## PreviewOutputErrorCode
枚举,预览输出的错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
## PreviewOutputError
预览输出错误对象。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 说明 |
| ---- | ------------------------------------------------- | ---------------------- |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | PreviewOut中的错误码。 |
## camera.createPhotoOutput ## camera.createPhotoOutput
createPhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput\>): void createPhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput\>): void
...@@ -2030,8 +2087,8 @@ createPhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput\>): voi ...@@ -2030,8 +2087,8 @@ createPhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput\>): voi
**示例:** **示例:**
``` ```js
camera.createPhotoOutput((surfaceId), (err, photoOutput) => { camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => {
if (err) { if (err) {
console.error('Failed to create the PhotoOutput instance. ${err.message}'); console.error('Failed to create the PhotoOutput instance. ${err.message}');
return; return;
...@@ -2062,8 +2119,8 @@ createPhotoOutput(surfaceId: string): Promise<PhotoOutput\> ...@@ -2062,8 +2119,8 @@ createPhotoOutput(surfaceId: string): Promise<PhotoOutput\>
**示例:** **示例:**
``` ```js
camera.createPhotoOutput(surfaceId).then((photoOutput) => { camera.createPhotoOutput("surfaceId").then((photoOutput) => {
console.log('Promise returned with PhotoOutput instance'); console.log('Promise returned with PhotoOutput instance');
}) })
``` ```
...@@ -2071,35 +2128,33 @@ camera.createPhotoOutput(surfaceId).then((photoOutput) => { ...@@ -2071,35 +2128,33 @@ camera.createPhotoOutput(surfaceId).then((photoOutput) => {
枚举,图片旋转角度。 枚举,图片旋转角度。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 默认值 | 说明 |
| ------------ | ------ | --------------- |
| ROTATION_0 | 0 | 图片旋转0度。 |
| ROTATION_90 | 90 | 图片旋转90度。 |
| ROTATION_180 | 180 | 图片旋转180度。 |
| ROTATION_270 | 270 | 图片旋转270度。 |
| 名称 | 值 | 说明 |
| ------------ | ---- | --------------- |
| ROTATION_0 | 0 | 图片旋转0度。 |
| ROTATION_90 | 90 | 图片旋转90度。 |
| ROTATION_180 | 180 | 图片旋转180度。 |
| ROTATION_270 | 270 | 图片旋转270度。 |
## QualityLevel ## QualityLevel
枚举,图片质量。 枚举,图片质量。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 默认值 | 说明 | | 名称 | | 说明 |
| -------------------- | ------ | -------------- | | -------------------- | ---- | -------------- |
| QUALITY_LEVEL_HIGH | 0 | 图片质量高。 | | QUALITY_LEVEL_HIGH | 0 | 图片质量高。 |
| QUALITY_LEVEL_MEDIUM | 1 | 图片质量中等。 | | QUALITY_LEVEL_MEDIUM | 1 | 图片质量中等。 |
| QUALITY_LEVEL_LOW | 2 | 图片质量差。 | | QUALITY_LEVEL_LOW | 2 | 图片质量差。 |
## PhotoCaptureSetting ## PhotoCaptureSetting
拍摄照片的设置。 拍摄照片的设置。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 **系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | -------------- | | -------- | ------------------------------- | ---- | -------------- |
...@@ -2127,7 +2182,7 @@ capture(callback: AsyncCallback<void\>): void ...@@ -2127,7 +2182,7 @@ capture(callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
photoOutput.capture((err) => { photoOutput.capture((err) => {
if (err) { if (err) {
console.error('Failed to capture the photo ${err.message}'); console.error('Failed to capture the photo ${err.message}');
...@@ -2154,7 +2209,7 @@ capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void ...@@ -2154,7 +2209,7 @@ capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
photoOutput.capture(settings, (err) => { photoOutput.capture(settings, (err) => {
if (err) { if (err) {
console.error('Failed to capture the photo ${err.message}'); console.error('Failed to capture the photo ${err.message}');
...@@ -2187,7 +2242,7 @@ capture(setting?: PhotoCaptureSetting): Promise<void\> ...@@ -2187,7 +2242,7 @@ capture(setting?: PhotoCaptureSetting): Promise<void\>
**示例:** **示例:**
``` ```js
photoOutput.capture().then(() => { photoOutput.capture().then(() => {
console.log('Promise returned to indicate that photo capture request success.'); console.log('Promise returned to indicate that photo capture request success.');
}) })
...@@ -2209,7 +2264,7 @@ release(callback: AsyncCallback<void\>): void ...@@ -2209,7 +2264,7 @@ release(callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
photoOutput.release((err) => { photoOutput.release((err) => {
if (err) { if (err) {
console.error('Failed to release the PhotoOutput instance ${err.message}'); console.error('Failed to release the PhotoOutput instance ${err.message}');
...@@ -2236,7 +2291,7 @@ release(): Promise<void\> ...@@ -2236,7 +2291,7 @@ release(): Promise<void\>
**示例:** **示例:**
``` ```js
photoOutput.release().then(() => { photoOutput.release().then(() => {
console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.');
}) })
...@@ -2259,8 +2314,8 @@ on(type: 'captureStart', callback: AsyncCallback<number\>): void ...@@ -2259,8 +2314,8 @@ on(type: 'captureStart', callback: AsyncCallback<number\>): void
**示例:** **示例:**
``` ```js
photoOutput.on('captureStart', (captureId) => { photoOutput.on('captureStart', (err, captureId) => {
console.log('photo capture stated, captureId : ' + captureId); console.log('photo capture stated, captureId : ' + captureId);
}) })
``` ```
...@@ -2269,20 +2324,20 @@ photoOutput.on('captureStart', (captureId) => { ...@@ -2269,20 +2324,20 @@ photoOutput.on('captureStart', (captureId) => {
on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void
监听帧刷新,通过注册回调函数获取结果。 监听快门,通过注册回调函数获取结果。
**系统能力:** SystemCapability.Multimedia.Camera.Core **系统能力:** SystemCapability.Multimedia.Camera.Core
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| :------- | :------------------------------- | :--- | :--------------------------------------------- | | :------- | :---------------------------------------------------- | :--- | :--------------------------------------------- |
| type | string | 是 | 监听事件,固定为'frameShutter',即帧刷新事件。 | | type | string | 是 | 监听事件,固定为'frameShutter',即帧刷新事件。 |
| callback | AsyncCallback<FrameShutterInfo\> | 是 | 回调函数,用于获取相关信息。 | | callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | 是 | 回调函数,用于获取相关信息。 |
**示例:** **示例:**
``` ```js
photoOutput.on('frameShutter', (frameShutterInfo) => { photoOutput.on('frameShutter', (frameShutterInfo) => {
console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); console.log('photo capture end, captureId : ' + frameShutterInfo.captureId);
console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); console.log('Timestamp for frame : ' + frameShutterInfo.timestamp);
...@@ -2299,14 +2354,14 @@ on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void ...@@ -2299,14 +2354,14 @@ on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| :------- | :----------------------------- | :--- | :--------------------------------------------- | | :------- | :------------------------------------------------ | :--- | :--------------------------------------------- |
| type | string | 是 | 监听事件,固定为'captureEnd',即拍照停止事件。 | | type | string | 是 | 监听事件,固定为'captureEnd',即拍照停止事件。 |
| callback | AsyncCallback<CaptureEndInfo\> | 是 | 回调函数,用于获取相关信息。 | | callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | 是 | 回调函数,用于获取相关信息。 |
**示例:** **示例:**
``` ```js
photoOutput.on('captureEnd', (captureEndInfo) => { photoOutput.on('captureEnd', (captureEndInfo) => {
console.log('photo capture end, captureId : ' + captureEndInfo.captureId); console.log('photo capture end, captureId : ' + captureEndInfo.captureId);
console.log('frameCount : ' + captureEndInfo.frameCount); console.log('frameCount : ' + captureEndInfo.frameCount);
...@@ -2323,19 +2378,61 @@ on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void ...@@ -2323,19 +2378,61 @@ on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| :------- | :------------------------------- | :--- | :---------------------------------------- | | :------- | :---------------------------------------------------- | :--- | :---------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 | | type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 |
| callback | ErrorCallback<PhotoOutputError\> | 是 | 回调函数,用于获取错误信息。 | | callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
``` ```js
photoOutput.on('error', (photoOutputError) => { photoOutput.on('error', (photoOutputError) => {
console.log('Photo output error code: ' + photoOutputError.code); console.log('Photo output error code: ' + photoOutputError.code);
}) })
``` ```
## FrameShutterInfo
快门事件信息。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ----------------------------- |
| captureId | number | 是 | CaptureId,本次拍摄动作的ID。 |
| timestamp | number | 是 | 时间戳。 |
## CaptureEndInfo
拍照停止信息。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ----------------------------- |
| captureId | number | 是 | CaptureId,本次拍摄动作的ID。 |
| frameCount | number | 是 | 帧计数。 |
## PhotoOutputErrorCode
枚举,拍照输出的错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
## PhotoOutputError
拍照输出错误对象。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 说明 |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | PhotoOutput中的错误码。 |
## camera.createVideoOutput ## camera.createVideoOutput
createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput\>): void createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput\>): void
...@@ -2353,8 +2450,8 @@ createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput\>): voi ...@@ -2353,8 +2450,8 @@ createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput\>): voi
**示例:** **示例:**
``` ```js
camera.createVideoOutput((surfaceId), (err, videoOutput) => { camera.createVideoOutput(("surfaceId"), (err, videoOutput) => {
if (err) { if (err) {
console.error('Failed to create the VideoOutput instance. ${err.message}'); console.error('Failed to create the VideoOutput instance. ${err.message}');
return; return;
...@@ -2385,8 +2482,9 @@ createVideoOutput(surfaceId: string): Promise<VideoOutput\> ...@@ -2385,8 +2482,9 @@ createVideoOutput(surfaceId: string): Promise<VideoOutput\>
**示例:** **示例:**
``` ```js
camera.createVideoOutput(surfaceId).then((videoOutput) => { camera.createVideoOutput("surfaceId"
).then((videoOutput) => {
console.log('Promise returned with the VideoOutput instance'); console.log('Promise returned with the VideoOutput instance');
}) })
``` ```
...@@ -2411,7 +2509,7 @@ start(callback: AsyncCallback<void\>): void ...@@ -2411,7 +2509,7 @@ start(callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
videoOutput.start((err) => { videoOutput.start((err) => {
if (err) { if (err) {
console.error('Failed to start the video output ${err.message}'); console.error('Failed to start the video output ${err.message}');
...@@ -2438,7 +2536,7 @@ start(): Promise<void\> ...@@ -2438,7 +2536,7 @@ start(): Promise<void\>
**示例:** **示例:**
``` ```js
videoOutput.start().then(() => { videoOutput.start().then(() => {
console.log('Promise returned to indicate that start method execution success.'); console.log('Promise returned to indicate that start method execution success.');
}) })
...@@ -2460,7 +2558,7 @@ stop(callback: AsyncCallback<void\>): void ...@@ -2460,7 +2558,7 @@ stop(callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
videoOutput.stop((err) => { videoOutput.stop((err) => {
if (err) { if (err) {
console.error('Failed to stop the video output ${err.message}'); console.error('Failed to stop the video output ${err.message}');
...@@ -2486,7 +2584,7 @@ stop(): Promise<void\> ...@@ -2486,7 +2584,7 @@ stop(): Promise<void\>
**示例:** **示例:**
``` ```js
videoOutput.start().then(() => { videoOutput.start().then(() => {
console.log('Promise returned to indicate that stop method execution success.'); console.log('Promise returned to indicate that stop method execution success.');
}) })
...@@ -2508,7 +2606,7 @@ release(callback: AsyncCallback<void\>): void ...@@ -2508,7 +2606,7 @@ release(callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
videoOutput.release((err) => { videoOutput.release((err) => {
if (err) { if (err) {
console.error('Failed to release the VideoOutput instance ${err.message}'); console.error('Failed to release the VideoOutput instance ${err.message}');
...@@ -2535,7 +2633,7 @@ release(): Promise<void\> ...@@ -2535,7 +2633,7 @@ release(): Promise<void\>
**示例:** **示例:**
``` ```js
videoOutput.release().then(() => { videoOutput.release().then(() => {
console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); console.log('Promise returned to indicate that the VideoOutput instance is released successfully.');
}) })
...@@ -2558,7 +2656,7 @@ on(type: 'frameStart', callback: AsyncCallback<void\>): void ...@@ -2558,7 +2656,7 @@ on(type: 'frameStart', callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
videoOutput.on('frameStart', () => { videoOutput.on('frameStart', () => {
console.log('Video frame started'); console.log('Video frame started');
}) })
...@@ -2581,7 +2679,7 @@ on(type: 'frameEnd', callback: AsyncCallback<void\>): void ...@@ -2581,7 +2679,7 @@ on(type: 'frameEnd', callback: AsyncCallback<void\>): void
**示例:** **示例:**
``` ```js
videoOutput.on('frameEnd', () => { videoOutput.on('frameEnd', () => {
console.log('Video frame ended'); console.log('Video frame ended');
}) })
...@@ -2597,15 +2695,35 @@ on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void ...@@ -2597,15 +2695,35 @@ on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| :------- | :-------------------------- | :--- | :-------------------------------------------- | | :------- | :----------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 | | type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 |
| callback | Callback<VideoOutputError\> | 是 | 回调函数,用于获取错误信息。 | | callback | Callback<[VideoOutputError](#videooutputerror)\> | 是 | 回调函数,用于获取错误信息。 |
**示例:** **示例:**
``` ```js
videoOutput.on('error', (VideoOutputError) => { videoOutput.on('error', (VideoOutputError) => {
console.log('Video output error code: ' + VideoOutputError.code); console.log('Video output error code: ' + VideoOutputError.code);
}) })
``` ```
\ No newline at end of file
## VideoOutputErrorCode
枚举,视频输出的错误码。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 值 | 说明 |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | 未知错误。 |
## VideoOutputError
视频输出错误对象。
**系统能力:** SystemCapability.Multimedia.Camera.Core
| 名称 | 类型 | 说明 |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | VideoOutput中的错误码。 |
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册