diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 71f5f2a90b50513c194c3dad027b86abcb296984..4ae4ecd6a7843cd4781431ba5eed30afd0989f11 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -434,18 +434,6 @@ Enumerates the interrupt types. | INTERRUPT_TYPE_BEGIN | 1 | Audio playback interruption started. | | INTERRUPT_TYPE_END | 2 | Audio playback interruption ended. | - -## InterruptForceType9+ - -Enumerates the interrupt force types. - -**System capability:** SystemCapability.Multimedia.Audio.Renderer - -| Name | Default Value | Description | -| :-------------- | :------------ | :----------------------------------------- | -| INTERRUPT_FORCE | 0 | Forced action taken by system. | -| INTERRUPT_SHARE | 1 | App can choose to take action or ignore. | - ## InterruptHint Enumerates the interrupt hints. @@ -542,20 +530,6 @@ Describes audio capturer configuration options. | streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Stream information. | | capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | Capturer information. | -## InterruptEvent9+ - -Describes the interrupt event received by the app when playback is interrupted. - -**System capability:** SystemCapability.Multimedia.Audio.Renderer - -**Parameters:** - -| Name | Type | Mandatory | Description | -| :-------- | :-------------------------------------------- | :-------- | :---------------------------------------------------------------- | -| eventType | [InterruptType](#interrupttype) | Yes | Whether the interruption has started or finished. | -| forceType | [InterruptForceType](#interruptforcetype9) | Yes | Whether the action is taken by system or to be taken by the app. | -| hintType | [InterruptHint](#interrupthint) | Yes | Type of action. | - ## AudioInterrupt The parameters passed in by the audio listener event. @@ -2560,52 +2534,6 @@ audioRenderer.getRenderRate().then((renderRate) => { }); ``` - -### on('interrupt')9+ - -on(type: 'interrupt', callback: Callback\): void - -Subscribes to audio interrupt events. This API uses a callback to get interrupt events. The interrupt event is triggered when audio rendering is interrupted. - -**System capability:** SystemCapability.Multimedia.Audio.Renderer - -**Parameters:** - -| Name | Type | Mandatory | Description | -| :------- | :-------------------------------------------- | :-------- | :---------------------------------------------- | -| type | string | Yes | Type of the playback event to subscribe to. | -| callback | Callback<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to listen for interrupt callback. | - -**Example:** - -``` -audioRenderer.on('interrupt', (interruptEvent) => { - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Force paused. Stop writing'); - isPlay = false; - break; - case audio.InterruptHint.INTERRUPT_HINT_STOP: - console.log('Force stopped. Stop writing'); - isPlay = false; - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - console.log('Resume force paused renderer or ignore'); - startRenderer(); - break; - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Choose to pause or ignore'); - pauseRenderer(); - break; - } - } -}); -``` - ### on('markReach')8+ on(type: 'markReach', frame: number, callback: (position: number) => {}): void diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md deleted file mode 100644 index 6a51a41b6fba50c1c4f7a061d313482e1df57ad9..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ /dev/null @@ -1,2798 +0,0 @@ -# Camera - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -## Modules to Import - -``` -import camera from '@ohos.multimedia.camera'; -``` - -## Required Permissions - -``` -ohos.permission.CAMERA -``` -## getCameraManager(context: Context, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets a **CameraManager** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CameraManager instance | - -**Example** - -``` -camera.getCameraManager(context, (err, cameraManager) => { - if (err) { - console.error('Failed to get the CameraManager instance ${err.message}'); - return; - } - console.log('Callback returned with the CameraManager instance'); -}); -``` - -## getCameraManager(context: Context): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets a **CameraManager** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------| -| context | Context | Yes | Application context | - -**Return values** - -| Type | Description | -|-------------------------|--------------------------------------------------------| -| Promise | Promise used to return the **CameraManager** instance | - -**Example** - -``` -camera.getCameraManager(context).then((cameraManger) => { - console.log('Promise returned with the CameraManager instance.'); -}) -``` - -## CameraStatus - -Enumerates camera status types. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default Value | Description | -|---------------------------|---------------|--------------------| -| CAMERA_STATUS_APPEAR | 0 | Camera appear | -| CAMERA_STATUS_DISAPPEAR | 1 | Camera disappear | -| CAMERA_STATUS_AVAILABLE | 2 | Camera available | -| CAMERA_STATUS_UNAVAILABLE | 3 | Camera unavailable | - - -## CameraPosition - -Enumerates the camera positions. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|-----------------------------|---------------|-----------------------| -| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position | -| CAMERA_POSITION_BACK | 1 | Rear camera | -| CAMERA_POSITION_FRONT | 2 | Front camera | - -## CameraType - -Enumerates the camera types. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|-------------------------|---------------|-------------------------| -| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type | -| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera | -| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera | -| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera | -| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera | - - -## ConnectionType - -Enumerates camera connection types. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|------------------------------|---------------|----------------------------| -| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB | -| CAMERA_CONNECTION_REMOTE | 2 | Remote camera | - -## CameraManager - -Implements camera management, including getting supported cameras and creating **CameraInput** instances. - -### getCameras(callback: AsyncCallback\>): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets all cameras supported by the device. This method uses an asynchronous callback to return the array of supported cameras. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|---------------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras. | - -**Example** - -``` -cameraManager.getCameras((err, cameras) => { - if (err) { - console.error('Failed to get the cameras. ${err.message}'); - return; - } - console.log('Callback returned with an array of supported cameras: ' + cameras.length); -}) -``` - -### getCameras(): Promise\>; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets all cameras supported by the device. This method uses a promise to return the array of supported cameras. - -**Return values** - -| Type | Description | -|------------------------|--------------------------------------------------------| -| Promise\> | Promise used to return an array of supported cameras | - - -**Example** - -``` -cameraManager.getCameras().then((cameraArray) => { - console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); -}) -``` - -### createCameraInput(cameraId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera ID. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Default value | Mandatory | Description | -|----------|------------------------------|-----------|--------------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraId, (err, cameraInput) => { - if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback returned with the CameraInput instance.'); -}) -``` - -### createCameraInput(cameraId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera ID. This method uses a promise to return the instance. - -**Parameters** - -| Name | Default value | Mandatory | Description | -|----------|-----------------------------|-----------|------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | - -**Return values** - -| Type | Description | -|-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraId).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance'); -}) -``` - -### createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-----------------------------|-----------|---------------------------------------------------| -| position | CameraPosition | Yes | Camera position | -| type | CameraType | Yes | Camera type | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { - if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback returned with the CameraInput instance'); -}) -``` - -### createCameraInput(position: CameraPosition, type: CameraType): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses a promise to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------------|-----------|----------------------------------------| -| position | CameraPosition | Yes | Camera position | -| type | CameraType | Yes | Camera type | - -**Return values** - -| Type | Description | -|-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance.'); -}) -``` - -### on(type: 'cameraStatus', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for camera status changes. This method uses a callback to get camera status changes. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :--------------------------------------------------- | -| type | string | Yes | Camera status event. | -| callback | Callback | Yes | Callback used to get the camera status change. | - -**Example** - -``` -cameraManager.on('cameraStatus', (cameraStatusInfo) => { - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); -}) -``` - -## Camera - -when we call *cameraManager.getCameras()* API, then it will return the **Camera** class which will have all camera-related metadata such as *cameraId, cameraPosition, cameraType & connectionType*. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Fields** - -| Name | Type | Access | Description | -|----------------|----------------|----------|------------------------| -| cameraId | string | readonly | Camera ID | -| cameraPosition | cameraPosition | readonly | Camera position | -| cameraType | cameraType | readonly | Camera type | -| connectionType | connectionType | readonly | Camera connection type | - -``` -async function getCameraInfo() { - var cameraManager = await camera.getCameraManager(); - var cameras = await cameraManager.getCameras(); - var cameraObj = cameras[0]; - var cameraId = cameraObj.cameraId; - var cameraPosition = cameraObj.cameraPosition; - var cameraType = cameraObj.cameraType; - var cameraId = cameraObj.connectionType; -} - -``` - -## CameraStatusInfo - -This interface is a CameraManager callback API return. **CameraStatusInfo** will have *Camera* class & *CameraStatus* predefine constants.From *Camera* class, we can have all camera-related metadata & from *CameraStatus* constants, we will have information such as *APPEAR, DISAPPEAR, AVAILABLE & UNAVAILABLE*. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Fields** - -| Name | Type | Description | -|----------------|----------------|------------------| -| camera | Camera | Camera object | -| status | CameraStatus | Camera status | - - -## CameraInput - -Implements a **CameraInput** instance. - -### getCameraId(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the camera ID based on which this **CameraInput** instance is created. This method uses an asynchronous callback to return the camera ID. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|------------------------|-----------|---------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the camera ID | - -``` -cameraInput.getCameraId((err, cameraId) => { - if (err) { - console.error('Failed to get the camera ID. ${err.message}'); - return; - } - console.log('Callback returned with the camera ID: ' + cameraId); -}) -``` - -### getCameraId(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the camera ID based on which this **CameraInput** instance is created. This method uses a promise to return the camera ID. - -**Return values** - -| Type | Description | -|------------------------|--------------------------------------| -| Promise | Promise used to return the camera ID | - -**Example** - -``` -cameraInput.getCameraId().then((cameraId) => { - console.log('Promise returned with the camera ID:' + cameraId); -}) -``` - -### hasFlash(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether the device has flash light. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-------------------------|-----------|----------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the flash light support status | - -**Example** - -``` -cameraInput.hasFlash((err, status) => { - if (err) { - console.error('Failed to check whether the device has flash light. ${err.message}'); - return; - } - console.log('Callback returned with flash light support status: ' + status); -}) -``` - -### hasFlash(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether the device has flash light. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|--------------------------------------------------------| -| Promise | Promise used to return the flash light support status | - -**Example** - -``` -cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); -}) -``` - -### isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified flash mode is supported. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the device flash support status | - -**Example** - -``` -cameraInput.isFlashModeSupported(flashMode, (err, status) => { - if (err) { - console.error('Failed to check whether the flash mode is supported. ${err.message}'); - return; - } - console.log('Callback returned with the flash mode support status: ' + status); -}) -``` - -### isFlashModeSupported(flashMode: FlashMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified flash mode is supported. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return flash mode support status. | - -**Example** - -``` -cameraInput.isFlashModeSupported(flashMode).then((status) => { - console.log('Promise returned with flash mode support status.' + status); -}) -``` - -### setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets flash mode. This method uses an asynchronous callback to return the result. - -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.setFlashMode(flashMode, (err) => { - if (err) { - console.error('Failed to set the flash mode ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setFlashMode.'); -}) -``` - -### setFlashMode(flashMode: FlashMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets flash mode. This method uses a promise to return the result. - -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | - -**Return values** - -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.setFlashMode(flashMode).then(() => { - console.log('Promise returned with the successful execution of setFlashMode.'); -}) -``` - -### getFlashMode(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current flash mode. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current flash mode | - -**Example** - -``` -cameraInput.getFlashMode((err, flashMode) => { - if (err) { - console.error('Failed to get the flash mode ${err.message}'); - return; - } - console.log('Callback returned with current flash mode: ' + flashMode); -}) -``` - -### getFlashMode(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current flash mode. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the flash mode | - -**Example** - -``` -cameraInput.getFlashMode().then((flashMode) => { - console.log('Promise returned with current flash mode : ' + flashMode); -}) -``` - -### isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified focus mode is supported. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the device focus support status | - -**Example** - -``` -cameraInput.isFocusModeSupported(afMode, (err, status) => { - if (err) { - console.error('Failed to check whether the focus mode is supported. ${err.message}'); - return; - } - console.log('Callback returned with the focus mode support status: ' + status); -}) -``` - -### isFocusModeSupported(afMode: FocusMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified focus mode is supported. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode support status. | - -**Example** - -``` -cameraInput.isFocusModeSupported(afMode).then((status) => { - console.log('Promise returned with focus mode support status.' + status); -}) -``` - -### setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets focus mode. This method uses an asynchronous callback to return the result. - -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.setFocusMode(afMode, (err) => { - if (err) { - console.error('Failed to set the focus mode ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setFocusMode.'); -}) -``` - -### setFocusMode(afMode: FocusMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets focus mode. This method uses a promise to return the result. - -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|-----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | - -**Return values** - -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.setFocusMode(afMode).then(() => { - console.log('Promise returned with the successful execution of setFocusMode.'); -}) -``` - -### getFocusMode(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the current focus mode. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current focus mode | - -**Example** - -``` -cameraInput.getFocusMode((err, afMode) => { - if (err) { - console.error('Failed to get the focus mode ${err.message}'); - return; - } - console.log('Callback returned with current focus mode: ' + afMode); -}) -``` - -### getFocusMode(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the current focus mode. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode | - -**Example** - -``` -cameraInput.getFocusMode().then((afMode) => { - console.log('Promise returned with current focus mode : ' + afMode); -}) -``` - -### getZoomRatioRange\(callback: AsyncCallback\>\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the zoom ratios of all zoom values. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the zoom ratio range | - -**Example** - -``` -cameraInput.getZoomRatioRange((err, zoomRatioRange) => { - if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); - return; - } - console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); -}) -``` - -### getZoomRatioRange\(\): Promise\>; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the zoom ratios of all zoom values. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|------------------------|---------------------------------------------| -| Promise\> | Promise used to return the zoom ratio range | - -**Example** - -``` -cameraInput.getZoomRatioRange().then((zoomRatioRange) => { - console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); -}) -``` - -### setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets a zoom ratio. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|------------------------------------| -| zoomRatio | number | Yes | Zoom ratio | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.setZoomRatio(zoomRatio, (err) => { - if (err) { - console.error('Failed to set the zoom ratio value ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setZoomRatio.'); -}) -``` - -### setZoomRatio(zoomRatio: number): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets a zoom ratio. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|----------|-----------|-------------| -| zoomRatio | number | Yes | zoom ratio | - -**Return values** - -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.setZoomRatio(zoomRatio).then(() => { - console.log('Promise returned with the successful execution of setZoomRatio.'); -}) -``` - -### getZoomRatio(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current zoom ratio value. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current zoom ratio value | - -**Example** - -``` -cameraInput.getZoomRatio((err, zoomRatio) => { - if (err) { - console.error('Failed to get the zoom ratio ${err.message}'); - return; - } - console.log('Callback returned with current zoom ratio: ' + zoomRatio); -}) -``` - -### getZoomRatio(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current zoom ratio value. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the zoom ratio vaule | - -**Example** - -``` -cameraInput.getZoomRatio().then((zoomRatio) => { - console.log('Promise returned with current zoom ratio : ' + zoomRatio); -}) -``` - -### release\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CameraInput** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.release((err) => { - if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CameraInput** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.release().then(() => { - console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); -}) -``` - -### on(type: 'focusStateChange', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for focus state changes. This method uses a callback to get focus state changes. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the focus state change. | - -**Example** - -``` -cameraInput.on('focusStateChange', (focusState) => { - console.log('Focus state : ' + focusState); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **CameraInput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Camera input error event. | -| callback | Callback | Yes | Callback used to get the camera input errors. | - -**Example** - -``` -cameraInput.on('error', (cameraInputError) => { - console.log('Camera input error code: ' + cameraInputError.code); -}) -``` - -## FlashMode - -Enumerates the flash modes. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|------------------------|---------------|------------------------| -| FLASH_MODE_CLOSE | 0 | Flash mode close | -| FLASH_MODE_OPEN | 1 | Flash mode open | -| FLASH_MODE_AUTO | 2 | Flash mode auto | -| FLASH_MODE_ALWAYS_OPEN | 3 | Flash mode always open | - -## FocusMode - -Enumerates the focus modes. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|----------------------------|---------------|----------------------------| -| FOCUS_MODE_MANUAL | 0 | Focus mode manual | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Focus mode continuous auto | -| FOCUS_MODE_AUTO | 2 | Focus mode auto | -| FOCUS_MODE_LOCKED | 3 | Focus mode locked | - -## createCaptureSession\(context: Context, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CaptureSession** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CaptureSession instance | - -**Example** - -``` -captureSession.createCaptureSession((context), (err, captureSession) => { - if (err) { - console.error('Failed to create the CaptureSession instance. ${err.message}'); - return; - } - console.log('Callback returned with the CaptureSession instance.' + captureSession); -}); -``` - -## createCaptureSession(context: Context\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CaptureSession** instance. This method uses a promise to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | - -**Return values** - -| Type | Description | -|---------------------------|---------------------------------------------------| -| Promise | Promise used to return the CaptureSession instance. | - -**Example** - -``` -captureSession.createCaptureSession(context).then((captureSession) => { - console.log('Promise returned with the CaptureSession instance'); -}) -``` - -## CaptureSession - -Implements session capture. - -### beginConfig\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.beginConfig((err) => { - if (err) { - console.error('Failed to start the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the begin config success.'); -}); -``` - -### beginConfig\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts configuration for this CaptureSession instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.beginConfig().then(() => { - console.log('Promise returned to indicate the begin config success.'); -}) -``` - -### commitConfig\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Commits the configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.commitConfig((err) => { - if (err) { - console.error('Failed to commit the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the commit config success.'); -}); -``` - -### commitConfig\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Commits the configuration for this CaptureSession instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.commitConfig().then(() => { - console.log('Promise returned to indicate the commit config success.'); -}) -``` - -### addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a CameraInput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|----------------------|-----------|---------------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addInput(cameraInput, (err) => { - if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is added.'); -}); -``` - -### addInput\(cameraInput: CameraInput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a CameraInput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|---------------------|-----------|-------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | - -**Return values** - -| Type | Description | -|----------------|------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addInput(cameraInput).then(() => { - console.log('Promise used to indicate that the CameraInput instance is added.'); -}) -``` - -### addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PreviewOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|-------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addOutput(previewOutput, (err) => { - if (err) { - console.error('Failed to add the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); -}); -``` - -### addOutput\(previewOutput: PreviewOutput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PreviewOutput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addOutput(previewOutput).then(() => { - console.log('Promise used to indicate that the PreviewOutput instance is added.'); -}) -``` - -### addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PhotoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to add the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); -}); -``` - -### addOutput\(photoOutput: PhotoOutput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PhotoOutput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | - -**Return values** - -| Type | Description | -|---------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addOutput(photoOutput).then(() => { - console.log('Promise used to indicate that the PhotoOutput instance is added.'); -}) -``` - -### addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a VideoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addOutput(videoOutput, (err) => { - if (err) { - console.error('Failed to add the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is added.'); -}); -``` - -### addOutput\(videoOutput: VideoOutput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a VideoOutput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addOutput(videoOutput).then(() => { - console.log('Promise used to indicate that the VideoOutput instance is added.'); -}) -``` - -### removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|----------------------|-----------|------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeInput(cameraInput, (err) => { - if (err) { - console.error('Failed to remove the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the cameraInput instance is removed.'); -}); -``` - -### removeInput\(cameraInput: CameraInput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|---------------------|-----------|---------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.removeInput(cameraInput).then(() => { - console.log('Promise returned to indicate that the cameraInput instance is removed.'); -}) -``` - -### removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeOutput(previewOutput, (err) => { - if (err) { - console.error('Failed to remove the PreviewOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is removed.'); -}); -``` - -### removeOutput(previewOutput: PreviewOutput): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-----------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | - - -**Return values** - -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.removeOutput(previewOutput).then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); -}) -``` - -### removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to remove the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); -}); -``` - -### removeOutput(photoOutput: PhotoOutput): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|---------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | - - -**Return values** - -| Type | Description | -|---------------|------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.removeOutput(photoOutput).then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); -}) -``` - -### removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeOutput(videoOutput, (err) => { - if (err) { - console.error('Failed to remove the VideoOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is removed.'); -}); -``` - -### removeOutput(videoOutput: VideoOutput): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|---------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | - - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.removeOutput(videoOutput).then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is removed.'); -}) -``` - -### start\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.start((err) => { - if (err) { - console.error('Failed to start the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session start success.'); -}); -``` - -### start\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts this **CaptureSession** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.start().then(() => { - console.log('Promise returned to indicate the session start success.'); -}) -``` - -### stop\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.stop((err) => { - if (err) { - console.error('Failed to stop the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session stop success.'); -}); -``` - -### stop(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops this **CaptureSession** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.stop().then(() => { - console.log('Promise returned to indicate the session stop success.'); -}) -``` - -### release\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.release((err) => { - if (err) { - console.error('Failed to release the CaptureSession instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CaptureSession** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.release().then(() => { - console.log('Promise returned to indicate that the CaptureSession instance is released successfully.'); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **CaptureSession** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Capture session error event. | -| callback | Callback | Yes | Callback used to get the capture session errors. | - -**Example** - -``` -captureSession.on('error', (captureSessionError) => { - console.log('Capture session error code: ' + captureSessionError.code); -}) -``` - -## createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PreviewOutput** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | -| callback | AsyncCallback | Yes | Callback used to return the PreviewOutput instance | - -**Example** - -``` -camera.createPreviewOutput((surfaceId), (err, previewOutput) => { - if (err) { - console.error('Failed to create the PreviewOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with previewOutput instance'); -}); -``` - -## createPreviewOutput(surfaceId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PreviewOutput** instance. This method uses a promise to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | - -**Return values** - -| Type | Description | -|-------------------------|---------------------------------------------------| -| Promise | Promise used to return the PreviewOutput instance | - -**Example** - -``` -camera.createPreviewOutput(surfaceId).then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance'); -}) -``` - -## PreviewOutput - -Implements preview output. - -### release(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PreviewOutput** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -previewOutput.release((err) => { - if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PreviewOutput** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -previewOutput.release().then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); -}) -``` - -### on(type: 'frameStart', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for preview frame start events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -previewOutput.on('frameStart', () => { - console.log('Preview frame started'); -}) -``` - -### on(type: 'frameEnd', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for preview frame end event. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -previewOutput.on('frameEnd', () => { - console.log('Preview frame ended'); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **PreviewOutput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Preview output error event. | -| callback | Callback | Yes | Callback used to get the preview output errors. | - -**Example** - -``` -previewOutput.on('error', (previewOutputError) => { - console.log('Preview output error code: ' + previewOutputError.code); -}) -``` - -## createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PhotoOutput** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | -| callback | AsyncCallback | Yes | Callback used to return the PhotoOutput instance | - -**Example** - -``` -camera.createPhotoOutput((surfaceId), (err, photoOutput) => { - if (err) { - console.error('Failed to create the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with the PhotoOutput instance.'); -}); -``` - -## createPhotoOutput(surfaceId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PhotoOutput** instance. This method uses a promise to return the PhotoOutput instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | - -**Return values** - -| Type | Description | -|-------------------------|--------------------------------------------------| -| Promise | Promise used to return the PhotoOutput instance | - -**Example** - -``` -camera.createPhotoOutput(surfaceId).then((photoOutput) => { - console.log('Promise returned with PhotoOutput instance'); -}) -``` -## ImageRotation - -Enumerates the image rotation angles. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default Value | Description | -|--------------|---------------|----------------------------------------| -| ROTATION_0 | 0 | The capture image rotates 0 degrees | -| ROTATION_90 | 90 | The capture image rotates 90 degrees | -| ROTATION_180 | 180 | The capture image rotates 180 degrees | -| ROTATION_270 | 270 | The capture image rotates 270 degrees | - - -## Location - -Defines the location of a captured image. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Type | Access | Description | -|-----------|--------|--------------|-------------| -| latitude | number | read / write | Latitude | -| longitude | number | read / write | Longitude | - -## QualityLevel - -Enumerates the image quality levels. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|----------------------|---------------|----------------------| -| QUALITY_LEVEL_HIGH | 0 | High image quality | -| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality | -| QUALITY_LEVEL_LOW | 2 | Low image quality | - - -## PhotoCaptureSetting - -Defines the settings for image capture. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Type | Mandatory | Description | -|----------|---------------|-----------|---------------------| -| quality | QualityLevel | Optional | Photo image quality | -| rotation | ImageRotation | Optional | Photo rotation | - - -## PhotoOutput - -Implements photo output. - -### capture(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Captures a photo. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -photoOutput.capture((err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); -``` - -### capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Captures a photo with the specified capture settings. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | Yes | Photo capture settings | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -photoOutput.capture(settings, (err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); -``` - -### capture(setting?: PhotoCaptureSetting): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Captures a photo with the specified capture settings. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | No | Photo capture settings | - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -photoOutput.capture().then(() => { - console.log('Promise returned to indicate that photo capture request success.'); -}) -``` - -### release(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PhotoOutput** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -photoOutput.release((err) => { - if (err) { - console.error('Failed to release the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PhotoOutput** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -photoOutput.release().then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); -}) -``` - -### on(type: 'captureStart', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for photo capture start events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture ID. | - -**Example** - -``` -photoOutput.on('captureStart', (captureId) => { - console.log('photo capture stated, captureId : ' + captureId); -}) -``` - -### on(type: 'frameShutter', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for frame shutter events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the frame shutter information.| - -**Example** - -``` -photoOutput.on('frameShutter', (frameShutterInfo) => { - console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); - console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); -}) -``` - -### on(type: 'captureEnd', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for photo capture end events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :------------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture end information | - -**Example** - -``` -photoOutput.on('captureEnd', (captureEndInfo) => { - console.log('photo capture end, captureId : ' + captureEndInfo.captureId); - console.log('frameCount : ' + captureEndInfo.frameCount); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **PhotoOutput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Photo output error event. | -| callback | Callback | Yes | Callback used to get the photo output errors. | - -**Example** - -``` -photoOutput.on('error', (photoOutputError) => { - console.log('Photo output error code: ' + photoOutputError.code); -}) -``` - -## createVideoOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **VideoOutput** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | -| callback | AsyncCallback | Yes | Callback used to return the VideoOutput instance | - -**Example** - -``` -camera.createVideoOutput((surfaceId), (err, videoOutput) => { - if (err) { - console.error('Failed to create the VideoOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with the VideoOutput instance'); -}); -``` - -## createVideoOutput(surfaceId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **VideoOutput** instance. This method uses a promise to return the VideoOutput instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | - -**Return values** - -| Type | Description | -|---------------------------------------|-------------------------------------------------| -| Promise<[VideoOutput](#videooutput)\> | Promise used to return the VideoOutput instance | - -**Example** - -``` -camera.createVideoOutput(surfaceId).then((videoOutput) => { - console.log('Promise returned with the VideoOutput instance'); -}) -``` -## VideoOutput - -Implements video output. - -### start(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts the video output. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.start((err) => { - if (err) { - console.error('Failed to start the video output ${err.message}'); - return; - } - console.log('Callback invoked to indicate the video output start success.'); -}); -``` - -### start(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts the video output. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -videoOutput.start().then(() => { - console.log('Promise returned to indicate that start method execution success.'); -}) -``` - -### stop(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops the video output. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.stop((err) => { - if (err) { - console.error('Failed to stop the video output ${err.message}'); - return; - } - console.log('Callback invoked to indicate the video output stop success.'); -}); -``` - -### stop(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops the video output. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -videoOutput.start().then(() => { - console.log('Promise returned to indicate that stop method execution success.'); -}) -``` - -### release(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this VideoOutput instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.release((err) => { - if (err) { - console.error('Failed to release the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this VideoOutput instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -videoOutput.release().then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); -}) -``` - -### on(type: 'frameStart', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for video frame start events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.on('frameStart', () => { - console.log('Video frame started'); -}) -``` - -### on(type: 'frameEnd', callback: Callback): void; - -Listens for video frame end events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.on('frameEnd', () => { - console.log('Video frame ended'); -}) -``` - -### on(type: 'error', callback: Callback): void; - -Listens for **VideoOutput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Video output error event. | -| callback | Callback | Yes | Callback used to get the video output errors. | - -**Example** - -``` -videoOutput.on('error', (VideoOutputError) => { - console.log('Video output error code: ' + VideoOutputError.code); -}) -``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index 89c0c298d6a369fcf7ac7fc3abc63be304b56977..ae07870d380fb69569ef860b469f865b2d3baad6 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -125,73 +125,6 @@ Creates an **AudioRecorder** instance to control audio recording. let audiorecorder = media.createAudioRecorder(); ``` -## media.createVideoRecorder9+ - -createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void - -Creates a **VideoRecorder** instance in asynchronous mode. This API uses a callback to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance created.| - -**Example** - -```js -let videoRecorder - -media.createVideoRecorder((error, video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info(`video createVideoRecorder fail, error:${error.message}`); - } -}); -``` - -## media.createVideoRecorder9+ - -createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> - -Creates a **VideoRecorder** instance in asynchronous mode. This API uses a promise to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance created.| - -**Example** - -```js -let videoRecorder - -function failureCallback(error) { - console.info(`video failureCallback, error:${error.message}`); -} -function catchCallback(error) { - console.info(`video catchCallback, error:${error.message}`); -} - -await media.createVideoRecorder.then((video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info('video createVideoRecorder fail'); - } -}, failureCallback).catch(catchCallback); -``` - - - ## MediaErrorCode8+ Enumerates the media error codes. @@ -1836,662 +1769,6 @@ Enumerates the audio output formats. | AMR_WB | 4 | AMR_WB.
This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | AAC_ADTS | 6 | Audio Data Transport Stream (ADTS), which is a transport stream format of AAC-based audio.| -## VideoRecorder9+ - -Implements video recording. Before calling an API of the **VideoRecorder** class, you must call [createVideoRecorder()](#mediacreatevideorecorder9) to create a [VideoRecorder](#videorecorder9) instance. - -For details about the video recording demo, see [Video Recording Development](../../media/video-recorder.md). - -### Attributes - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Readable| Writable| Description | -| ------------------ | -------------------------------------- | ---- | ---- | ---------------- | -| state8+ | [VideoRecordState](#videorecordstate9) | Yes | No | Video recording state.| - -### prepare9+ - -prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; - -Sets video recording parameters in asynchronous mode. This API uses a callback to return the result. - -**Required permissions:** ohos.permission.MICROPHONE and ohos.permission.CAMERA - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------------- | ---- | ----------------------------------- | -| config | [VideoRecorderConfig](#videorecorderconfig9) | Yes | Video recording parameters to set. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // The file must be created by the caller and granted with proper permissions. - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// asyncallback -let videoRecorder = null; -let events = require('events'); -let eventEmitter = new events.EventEmitter(); - -eventEmitter.on('prepare', () => { - videoRecorder.prepare(videoConfig, (err) => { - if (typeof (err) == 'undefined') { - console.info('prepare success'); - } else { - console.info('prepare failed and error is ' + err.message); - } - }); -}); - -media.createVideoRecorder((err, recorder) => { - if (typeof (err) == 'undefined' && typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - eventEmitter.emit('prepare'); // Trigger the 'prepare' event. - } else { - console.info('createVideoRecorder failed and error is ' + err.message); - } -}); -``` - -### prepare9+ - -prepare(config: VideoRecorderConfig): Promise\; - -Sets video recording parameters in asynchronous mode. This API uses a promise to return the result. - -**Required permissions:** ohos.permission.MICROPHONE and ohos.permission.CAMERA - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | -------------------------------------------- | ---- | ------------------------ | -| config | [VideoRecorderConfig](#videorecorderconfig9) | Yes | Video recording parameters to set.| - -**Return value** - -| Type | Description | -| -------------- | ---------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // The file must be created by the caller and granted with proper permissions. - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// promise -let videoRecorder = null; -await media.createVideoRecorder().then((recorder) => { - if (typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - } else { - console.info('createVideoRecorder failed'); - } -}, (err) => { - console.info('error hanppend message is ' + err.message); -}).catch((err) => { - console.info('catch err error message is ' + err.message); -}); - -await videoRecorder.prepare(videoConfig).then(() => { - console.info('prepare success'); -}, (err) => { - console.info('prepare failed and error is ' + err.message); -}).catch((err) => { - console.info('prepare failed and catch error is ' + err.message); -}); -``` - -### getInputSurface9+ - -getInputSurface(callback: AsyncCallback\): void; - -Obtains the surface required for recording in asynchronous mode. This surface is provided for the caller. The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding data. - -Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp is based on the system startup time. - -This API can be called only after [prepare()](#videorecorder_prepare1) is called. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | --------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to obtain the result.| - -**Example** - -```js -// asyncallback -let surfaceID = null; // Surface ID passed to the external system. -videoRecorder.getInputSurface((err, surfaceId) => { - if (typeof (err) == 'undefined') { - console.info('getInputSurface success'); - surfaceID = surfaceId; - } else { - console.info('getInputSurface failed and error is ' + err.message); - } -}); -``` - -### getInputSurface9+ - -getInputSurface(): Promise\; - - Obtains the surface required for recording in asynchronous mode. This surface is provided for the caller. The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding data. - -Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp is based on the system startup time. - -This API can be called only after [prepare()](#videorecorder_prepare1) is called. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| ---------------- | -------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -let surfaceID = null; // Surface ID passed to the external system. -await videoRecorder.getInputSurface().then((surfaceId) => { - console.info('getInputSurface success'); - surfaceID = surfaceId; -}, (err) => { - console.info('getInputSurface failed and error is ' + err.message); -}).catch((err) => { - console.info('getInputSurface failed and catch error is ' + err.message); -}); -``` - -### start9+ - -start(callback: AsyncCallback\): void; - -Starts video recording in asynchronous mode. This API uses a callback to return the result. - -This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.start((err) => { - if (typeof (err) == 'undefined') { - console.info('start videorecorder success'); - } else { - console.info('start videorecorder failed and error is ' + err.message); - } -}); -``` - -### start9+ - -start(): Promise\; - -Starts video recording in asynchronous mode. This API uses a promise to return the result. - -This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.start().then(() => { - console.info('start videorecorder success'); -}, (err) => { - console.info('start videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('start videorecorder failed and catch error is ' + err.message); -}); -``` - -### pause9+ - -pause(callback: AsyncCallback\): void; - -Pauses video recording in asynchronous mode. This API uses a callback to return the result. - -This API can be called only after [start()](#videorecorder_start1) is called. You can resume recording by calling [resume()](#videorecorder_resume1). - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.pause((err) => { - if (typeof (err) == 'undefined') { - console.info('pause videorecorder success'); - } else { - console.info('pause videorecorder failed and error is ' + err.message); - } -}); -``` - -### pause9+ - -pause(): Promise\; - -Pauses video recording in asynchronous mode. This API uses a promise to return the result. - -This API can be called only after [start()](#videorecorder_start1) is called. You can resume recording by calling [resume()](#videorecorder_resume1). - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.pause().then(() => { - console.info('pause videorecorder success'); -}, (err) => { - console.info('pause videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('pause videorecorder failed and catch error is ' + err.message); -}); -``` - -### resume9+ - -resume(callback: AsyncCallback\): void; - -Resumes video recording in asynchronous mode. This API uses a callback to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.resume((err) => { - if (typeof (err) == 'undefined') { - console.info('resume videorecorder success'); - } else { - console.info('resume videorecorder failed and error is ' + err.message); - } -}); -``` - -### resume9+ - -resume(): Promise\; - -Resumes video recording in asynchronous mode. This API uses a promise to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.resume().then(() => { - console.info('resume videorecorder success'); -}, (err) => { - console.info('resume videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('resume videorecorder failed and catch error is ' + err.message); -}); -``` - -### stop9+ - -stop(callback: AsyncCallback\): void; - -Stops video recording in asynchronous mode. This API uses a callback to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.stop((err) => { - if (typeof (err) == 'undefined') { - console.info('stop videorecorder success'); - } else { - console.info('stop videorecorder failed and error is ' + err.message); - } -}); -``` - -### stop9+ - -stop(): Promise\; - -Stops video recording in asynchronous mode. This API uses a promise to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.stop().then(() => { - console.info('stop videorecorder success'); -}, (err) => { - console.info('stop videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('stop videorecorder failed and catch error is ' + err.message); -}); -``` - -### release9+ - -release(callback: AsyncCallback\): void; - -Releases the video recording resource in asynchronous mode. This API uses a callback to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.release((err) => { - if (typeof (err) == 'undefined') { - console.info('release videorecorder success'); - } else { - console.info('release videorecorder failed and error is ' + err.message); - } -}); -``` - -### release9+ - -release(): Promise\; - -Releases the video recording resource in asynchronous mode. This API uses a promise to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ----------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.release().then(() => { - console.info('release videorecorder success'); -}, (err) => { - console.info('release videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('release videorecorder failed and catch error is ' + err.message); -}); -``` - -### reset9+ - -reset(callback: AsyncCallback\): void; - -Resets video recording in asynchronous mode. This API uses a callback to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.reset((err) => { - if (typeof (err) == 'undefined') { - console.info('reset videorecorder success'); - } else { - console.info('reset videorecorder failed and error is ' + err.message); - } -}); -``` - -### reset9+ - -reset(): Promise\; - -Resets video recording in asynchronous mode. This API uses a promise to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.reset().then(() => { - console.info('reset videorecorder success'); -}, (err) => { - console.info('reset videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('reset videorecorder failed and catch error is ' + err.message); -}); -``` - -### on('error')9+ - -on(type: 'error', callback: ErrorCallback): void - -Subscribes to the video recording error event. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to, which is 'error' in this API.
The 'error' event is triggered when an error occurs during video recording.| -| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. | - -**Example** - -```js -videoRecorder.on('error', (error) => { // Set the 'error' event callback. - console.info(`audio error called, errName is ${error.name}`); // Print the error name. - console.info(`audio error called, errCode is ${error.code}`); // Print the error code. - console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type. -}); -// This event is reported when an error occurs during the retrieval of videoRecordState. -``` - -## VideoRecordState9+ - -Enumerates the video recording states. You can obtain the state through the **state** attribute. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Description | -| -------- | ------ | ---------------------- | -| idle | string | The video recorder is idle. | -| prepared | string | The video recording parameters are set.| -| playing | string | Video recording is in progress. | -| paused | string | Video recording is paused. | -| stopped | string | Video recording is stopped. | -| error | string | Audio playback is in the error state. | - -## VideoRecorderConfig9+ - -Describes the video recording parameters. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Mandatory| Description | -| --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| audioSourceType | [AudioSourceType](#audiosourcetype9) | Yes | Type of the audio source for video recording. | -| videoSourceType | [VideoSourceType](#videosourcetype9) | Yes | Type of the video source for video recording. | -| profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. | -| rotation | number | No | Rotation angle of the recorded video. | -| location | [Location](#location) | No | Geographical location of the recorded video. | -| url | string | Yes | Video output URL. Supported: fd://xx (fd number)
![](figures/en-us_image_url.png)
The file must be created by the caller and granted with proper permissions.| - -## AudioSourceType9+ - -Enumerates the audio source types for video recording. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Value | Description | -| ------------------------- | ---- | ---------------------- | -| AUDIO_SOURCE_TYPE_DEFAULT | 0 | Default audio input source.| -| AUDIO_SOURCE_TYPE_MIC | 1 | Mic audio input source. | - -## VideoSourceType9+ - -Enumerates the video source types for video recording. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Value | Description | -| ----------------------------- | ---- | ------------------------------- | -| VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | The input surface carries raw data.| -| VIDEO_SOURCE_TYPE_SURFACE_ES | 1 | The input surface carries ES data. | - -## VideoRecorderProfile9+ - -Describes the video recording profile. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Mandatory| Description | -| ---------------- | -------------------------------------------- | ---- | ---------------- | -| audioBitrate | number | Yes | Audio encoding bit rate.| -| audioChannels | number | Yes | Number of audio channels.| -| audioCodec | [CodecMimeType](#codecmimetype8) | Yes | Audio encoding format. | -| audioSampleRate | number | Yes | Audio sampling rate. | -| fileFormat | [ContainerFormatType](#containerformattype8) | Yes | Container format of a file.| -| videoBitrate | number | Yes | Video encoding bit rate.| -| videoCodec | [CodecMimeType](#codecmimetype8) | Yes | Video encoding format. | -| videoFrameWidth | number | Yes | Width of the recorded video frame.| -| videoFrameHeight | number | Yes | Height of the recorded video frame.| -| videoFrameRate | number | Yes | Video frame rate. | - ## ContainerFormatType8+ Enumerates the container format types (CFTs). diff --git a/zh-cn/application-dev/media/audio-capturer.md b/zh-cn/application-dev/media/audio-capturer.md index 89dfe30f66c2716c046c9d4f23e4fc901d0e9fdd..40dfa18e4dea4a40d6e068b7390e2588df36d5b3 100644 --- a/zh-cn/application-dev/media/audio-capturer.md +++ b/zh-cn/application-dev/media/audio-capturer.md @@ -8,6 +8,8 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 在进行应用开发的过程中,建议开发者通过on('stateChange')方法订阅AudioCapturer的状态变更。因为针对AudioCapturer的某些操作,仅在音频采集器在固定状态时才能执行。如果应用在音频采集器处于错误状态时执行操作,系统可能会抛出异常或生成其他未定义的行为。 +详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md) + ## 开发步骤 1. 使用createAudioCapturer()创建一个AudioCapturer实例。 diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index 826e2fa10f5ff7f53ae7dd6a7abafddcc60b85b4..e723548ed6fc93135f0bcd635b64e42e86543107 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -16,7 +16,7 @@ ## 开发步骤 -详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档AudioPlayer](../reference/apis/js-apis-media.md) ### 全流程场景 diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index fdc08dad061492b743beb85783bd620a7bfbb89c..6027db0bcb5c223796c7713d7b74d5c396e4bc95 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -16,7 +16,7 @@ ## 开发步骤 -详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档AudioRecorder](../reference/apis/js-apis-media.md) ### 全流程场景 diff --git a/zh-cn/application-dev/media/audio-renderer.md b/zh-cn/application-dev/media/audio-renderer.md index 7ea9ce05ffc93dab6dae46a083dab7512432f1bc..e1c2509561e1e3b9ab36e9119aac9a80b6ec4ef0 100644 --- a/zh-cn/application-dev/media/audio-renderer.md +++ b/zh-cn/application-dev/media/audio-renderer.md @@ -16,7 +16,7 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 ### 异步操作 -为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考[js-apis-audio](../reference/apis/js-apis-audio.md#audiorenderer8)。 +为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考[音频管理API文档AudioRenderer](../reference/apis/js-apis-audio.md#audiorenderer8)。 ## 开发步骤 diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index 7ae121dd86608a0d32bafb663f2ec4a08a77edd0..749bcf03fe58ca3de75ab91976eb9a65788b4c29 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -4,12 +4,10 @@ 图片开发的主要工作是将获取到的图片进行解码,将解码后的pixelmap编码成支持的格式,本文将对图片的解码、编码等场景开发进行介绍说明。 -## 接口说明 - -详细API含义请参考[js-apis-image.md](../reference/apis/js-apis-image.md) - ## 开发步骤 +详细API含义请参考:[图片处理API文档](../reference/apis/js-apis-image.md) + ### 全流程场景 包含流程:创建实例,读取图片信息,读写pixelmap,更新数据,打包像素,释放资源等流程。 diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index cb7610269fe9bd1bb94979fb9a009ec26601ac75..6cef265938cb3311f38ee90a467fd8b53ce167c3 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -35,7 +35,7 @@ ## 开发步骤 -详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档VideoPlayer](../reference/apis/js-apis-media.md) ### 全流程场景