提交 f7b50d75 编写于 作者: G Gloria

Update docs against 21128+2111820928

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 89fe0a15
...@@ -91,7 +91,7 @@ Enable the default system audio effect. ...@@ -91,7 +91,7 @@ Enable the default system audio effect.
## Obtaining the Global Audio Effect Mode ## Obtaining the Global Audio Effect Mode
You can obtain the global audio effect mode corresponding to a specific audio content type (specified by **ContentType**) and audio stream usage (specified by **StreamUsage**). You can obtain the global audio effect mode corresponding to a specific audio stream usage (specified by **StreamUsage**).
For an audio playback application, pay attention to the audio effect mode used by the audio stream of the application and perform corresponding operations. For example, for a music application, select the audio effect mode for the music scenario. Before obtaining the global audio effect mode, call **getStreamManager()** to create an **AudioStreamManager** instance. For an audio playback application, pay attention to the audio effect mode used by the audio stream of the application and perform corresponding operations. For example, for a music application, select the audio effect mode for the music scenario. Before obtaining the global audio effect mode, call **getStreamManager()** to create an **AudioStreamManager** instance.
### Creating an AudioStreamManager Instance ### Creating an AudioStreamManager Instance
...@@ -107,7 +107,7 @@ Create an **AudioStreamManager** instance. Before using **AudioStreamManager** A ...@@ -107,7 +107,7 @@ Create an **AudioStreamManager** instance. Before using **AudioStreamManager** A
### Querying the Audio Effect Mode of the Corresponding Scenario ### Querying the Audio Effect Mode of the Corresponding Scenario
```js ```js
audioStreamManager.getAudioEffectInfoArray(audio.ContentType.CONTENT_TYPE_MUSIC, audio.StreamUsage.STREAM_USAGE_MEDIA, async (err, audioEffectInfoArray) => { audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MEDIA, async (err, audioEffectInfoArray) => {
if (err) { if (err) {
console.error('Failed to get effect info array'); console.error('Failed to get effect info array');
return; return;
......
...@@ -170,6 +170,7 @@ Obtains the output capability supported by a camera. This API returns the result ...@@ -170,6 +170,7 @@ Obtains the output capability supported by a camera. This API returns the result
**Example** **Example**
```js ```js
let cameras = cameraManager.getSupportedCameras();
let cameraDevice = cameras[0]; let cameraDevice = cameras[0];
let cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice); let cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice);
...@@ -581,6 +582,160 @@ cameraManager.on('cameraMute', (err, curMuetd) => { ...@@ -581,6 +582,160 @@ cameraManager.on('cameraMute', (err, curMuetd) => {
}) })
``` ```
### isPrelaunchSupported
isPrelaunchSupported(camera: CameraDevice): boolean
Checks whether a camera supports prelaunch. This API is called in prior to **setPrelaunchConfig**.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | --------- |
| camera | [CameraDevice](#cameradevice) | Yes| Camera object.|
**Return value**
| Type| Description|
| -------- | --------------- |
| boolean | Returns whether the camera supports prelaunch. The value **true** means that the camera supports prelaunch, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
| ID | Error Message |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect. |
**Example**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
if(this.cameraManager.isPrelaunchSupported(cameras[0])) {
this.cameraManager.setPrelaunchConfig({cameraDevice: cameras[0]});
}
```
### setPrelaunchConfig
setPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void
**System API**: This is a system API.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | --------- |
| prelaunchConfig | [PrelaunchConfig](#prelaunchconfig) | Yes| Prelaunch configuration.|
**Error codes**
For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
| ID | Error Message |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect. |
| 7400102 | Operation not allow. |
**Example**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
if(this.cameraManager.isPrelaunchSupported(cameras[0])) {
try {
this.cameraManager.setPrelaunchConfig({cameraDevice: cameras[0]});
} catch (error) {
console.error(`catch error: Code: ${error.code}, message: ${error.message}`);
}
}
```
### prelaunch
prelaunch(): void
Prelaunches the camera. This API is called when the camera application is started after a user clicks the system camera icon.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Example**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
try {
this.cameraManager.prelaunch();
} catch (error) {
console.error(`catch error: Code: ${error.code}, message: ${error.message}`);
}
```
### createDeferredPreviewOutput
createDeferredPreviewOutput(profile: Profile): PreviewOutput
Creates a deferred **PreviewOutput** instance and adds it to the data stream instead of a common **PreviewOutput** instance during stream configuration.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | --------- |
| profile | [Profile](#profile) | Yes| Configuration file of the camera preview stream.|
**Return value**
| Type| Description|
| -------- | --------------- |
| [PreviewOutput](#previewoutput) | Returns a **PreviewOutput** instance.|
**Error codes**
For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
| ID | Error Message |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect. |
**Example**
```js
function getDeferredPreviewOutput(context: Context, previewProfile: camera.Profile): Promise<PreviewOutput> {
const cameraManager = camera.getCameraManager(context);
const output: Promise<PreviewOutput> = cameraManager.createDeferredPreviewOutput(previewProfile);
return output;
}
```
## PrelaunchConfig
Defines the camera prelaunch configuration.
Currently, the configuration is used for sensor-level prelaunch. It will be used for stream-level prelaunch in a later version.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory | Description |
| ------ | ----------------------------- | -------------- | ---------- |
| cameraDevice | [CameraDevice](#cameradevice) | Yes | Camera object.|
## CameraStatusInfo ## CameraStatusInfo
Describes the camera status information. Describes the camera status information.
...@@ -835,7 +990,7 @@ cameraInput.close().then(() => { ...@@ -835,7 +990,7 @@ cameraInput.close().then(() => {
### on('error') ### on('error')
on(type: 'error', camera:CameraDevice, callback: ErrorCallback\<BusinessError\>): void on(type: 'error', camera:CameraDevice, callback: ErrorCallback): void
Listens for **CameraInput** errors. This API uses a callback to return the result. Listens for **CameraInput** errors. This API uses a callback to return the result.
...@@ -847,12 +1002,11 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul ...@@ -847,12 +1002,11 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul
| -------- | -------------------------------- | --- | ------------------------------------------- | | -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **CameraInput** instance is created. This event is triggered and the result is returned when an error occurs on the camera. For example, if the device is unavailable or a conflict occurs, the error information is returned.| | type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **CameraInput** instance is created. This event is triggered and the result is returned when an error occurs on the camera. For example, if the device is unavailable or a conflict occurs, the error information is returned.|
| cameraDevice | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.| | cameraDevice | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
| callback | ErrorCallback\<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
```js ```js
let cameraDevice = cameras[0];
cameraInput.on('error', cameraDevice, (error) => { cameraInput.on('error', cameraDevice, (error) => {
console.log(`Camera input error code: ${error.code}`); console.log(`Camera input error code: ${error.code}`);
}) })
...@@ -883,7 +1037,7 @@ Enumerates the exposure modes. ...@@ -883,7 +1037,7 @@ Enumerates the exposure modes.
| EXPOSURE_MODE_AUTO | 1 | Auto exposure. The metering point can be set by calling [setMeteringPoint](#setmeteringpoint).| | EXPOSURE_MODE_AUTO | 1 | Auto exposure. The metering point can be set by calling [setMeteringPoint](#setmeteringpoint).|
| EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | Continuous auto exposure. The metering point cannot be set.| | EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | Continuous auto exposure. The metering point cannot be set.|
## FocusMode ## FocusMode
Enumerates the focus modes. Enumerates the focus modes.
...@@ -2288,7 +2442,7 @@ captureSession.on('focusStateChange', (err, focusState) => { ...@@ -2288,7 +2442,7 @@ captureSession.on('focusStateChange', (err, focusState) => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void on(type: 'error', callback: ErrorCallback): void
Listens for **CaptureSession** errors. This API uses a callback to return the errors. Listens for **CaptureSession** errors. This API uses a callback to return the errors.
...@@ -2299,7 +2453,7 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er ...@@ -2299,7 +2453,7 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | | -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as **beginConfig()**, **commitConfig()**, and **addInput**.| | type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as **beginConfig()**, **commitConfig()**, and **addInput**.|
| callback | ErrorCallback\<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback| Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -2547,7 +2701,7 @@ previewOutput.on('frameEnd', () => { ...@@ -2547,7 +2701,7 @@ previewOutput.on('frameEnd', () => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void on(type: 'error', callback: ErrorCallback): void
Listens for **PreviewOutput** errors. This API uses a callback to return the errors. Listens for **PreviewOutput** errors. This API uses a callback to return the errors.
...@@ -2558,7 +2712,7 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err ...@@ -2558,7 +2712,7 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------| ---- | ------------------------ | | -------- | --------------| ---- | ------------------------ |
| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the use of a preview-related API such as **start()** or **release()**.| | type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the use of a preview-related API such as **start()** or **release()**.|
| callback | ErrorCallback\<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -2568,6 +2722,49 @@ previewOutput.on('error', (previewOutputError) => { ...@@ -2568,6 +2722,49 @@ previewOutput.on('error', (previewOutputError) => {
}) })
``` ```
### addDeferredSurface
addDeferredSurface(surfaceId: string): void
Adds a surface for delayed preview. This API can run after **session.commitConfig()** is used to commit the configuration for a stream and **session.start()** is used to start the stream.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------| ---- | ------------------------ |
| surfaceId | string | Yes| Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)**.|
**Error codes**
For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
| ID | Error Message |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect |
**Example**
```js
function async preview(context: Context, cameraInfo: camera.Device, previewProfile: camera.Profile, photoProfile: camera.Profile, surfaceId: string): Promise<void> {
const cameraManager: camera.CameraManager = camera.getCameraManager(context);
const cameraInput camera.CameraInput = await cameraManager.createCameraInput(cameraInfo)
const previewOutput: camera.PreviewOutput = await cameraManager.createDeferredPreviewOutput(previewProfile);
const photoOutput: camera.PhotoOutput = await cameraManager.createPhotoOutput(photoProfile);
const session: camera.CaptureSession = await this.mCameraManager.createCaptureSession();
await session.beginConfig();
await session.addInput(cameraInput);
await session.addOutput(previewOutput);
await session.addOutput(photoOutput);
await session.commitConfig();
await session.start();
await previewOutput.addDeferredSurface(surfaceId);
}
```
## ImageRotation ## ImageRotation
Enumerates the image rotation angles. Enumerates the image rotation angles.
...@@ -2772,6 +2969,17 @@ For details about the error codes, see [CameraErrorCode](#cameraerrorcode). ...@@ -2772,6 +2969,17 @@ For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
**Example** **Example**
```js ```js
let captureLocation = {
latitude: 0,
longitude: 0,
altitude: 0,
}
let settings = {
quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
rotation: camera.ImageRotation.ROTATION_0,
location: captureLocation,
mirror: false
}
photoOutput.capture(settings).then(() => { photoOutput.capture(settings).then(() => {
console.log('Promise returned to indicate that photo capture request success.'); console.log('Promise returned to indicate that photo capture request success.');
}).catch((err) => { }).catch((err) => {
...@@ -2938,7 +3146,7 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => { ...@@ -2938,7 +3146,7 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void on(type: 'error', callback: ErrorCallback): void
Listens for **PhotoOutput** errors. This API uses a callback to return the errors. Listens for **PhotoOutput** errors. This API uses a callback to return the errors.
...@@ -2949,7 +3157,7 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error ...@@ -2949,7 +3157,7 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ----------------------------------- | | -------- | ------------- | ---- | ----------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a photographing-related API.| | type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a photographing-related API.|
| callback | ErrorCallback\<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -2959,6 +3167,153 @@ photoOutput.on('error', (error) => { ...@@ -2959,6 +3167,153 @@ photoOutput.on('error', (error) => {
}) })
``` ```
### isQuickThumbnailSupported
isQuickThumbnailSupported(): boolean
Checks whether the quick thumbnail feature is supported.
This API takes effect after **CaptureSession.addOutput** and **CaptureSession.addInput** and before **CaptureSession.commitConfig**.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
| Type| Description|
| --------- | ------ |
| boolean | Returns whether the quick thumbnail feature is supported. The value **true** means that the quick thumbnail feature is supported, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
| ID | Error Message |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect |
**Example**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// Create a CaptureSession instance.
this.captureSession = await this.cameraManager.createCaptureSession()
// Start configuration for the session.
await this.captureSession.beginConfig()
// Add a CameraInput instance to the session.
this.mCameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// Add a PhotoOutput instance to the session.
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
```
### enableQuickThumbnail
enableQuickThumbnail(enabled: boolean): void
Enables or disables the quick thumbnail feature.
This API takes effect after **CaptureSession.addOutput** and **CaptureSession.addInput** and before **CaptureSession.commitConfig**.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ----------------------------------- |
| enabled | boolean | Yes | Whether to enable the quick thumbnail feature. The value **true** means to enable the quick thumbnail feature, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
| ID | Error Message |
| --------------- | --------------- |
| 7400101 | Parameter missing or parameter type incorrect |
**Example**
```js
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// Create a CaptureSession instance.
this.captureSession = await this.cameraManager.createCaptureSession()
// Start configuration for the session.
await this.captureSession.beginConfig()
// Add a CameraInput instance to the session.
this.cameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// Add a PhotoOutput instance to the session.
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
if (isSupported) {
// Enable the quick thumbnail feature.
this.photoOutPut.enableQuickThumbnail(true)
}
```
### on('quickThumbnail')
on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void
Listens for the quick thumbnail output events.
The listening takes effect after **enableQuickThumbnail(true)** is called.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ----------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'quickThumbnail'**.|
| callback | AsyncCallback\<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise that returns a **PixelMap** instance.|
**Example**
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// Create a CaptureSession instance.
this.captureSession = await this.cameraManager.createCaptureSession()
// Start configuration for the session.
await this.captureSession.beginConfig()
// Add a CameraInput instance to the session.
this.cameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// Add a PhotoOutput instance to the session.
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
if (isSupported) {
// Enable the quick thumbnail feature.
this.photoOutPut.enableQuickThumbnail(true)
}
this.photoOutPut.on('quickThumbnail', (err, pixelmap) => {
if (err || pixelmap === undefined) {
Logger.error(this.tag, 'photoOutPut on thumbnail failed ')
return
}
// Display or save the PixelMap instance.
this.showOrSavePicture(pixelmap)
})
```
## FrameShutterInfo ## FrameShutterInfo
Defines the frame shutter information. Defines the frame shutter information.
...@@ -3217,7 +3572,7 @@ videoOutput.on('frameEnd', () => { ...@@ -3217,7 +3572,7 @@ videoOutput.on('frameEnd', () => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void on(type: 'error', callback: ErrorCallback): void
Listens for errors that occur during video recording. This API uses a callback to return the result. Listens for errors that occur during video recording. This API uses a callback to return the result.
...@@ -3228,7 +3583,7 @@ Listens for errors that occur during video recording. This API uses a callback t ...@@ -3228,7 +3583,7 @@ Listens for errors that occur during video recording. This API uses a callback t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | -------------------------------------- | | -------- | ----------- | ---- | -------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a recording-related API such as **start()** and **release()**.| | type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a recording-related API such as **start()** and **release()**.|
| callback | Callback\<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -3385,7 +3740,7 @@ metadataOutput.on('metadataObjectsAvailable', (err, metadataObjectArr) => { ...@@ -3385,7 +3740,7 @@ metadataOutput.on('metadataObjectsAvailable', (err, metadataObjectArr) => {
### on('error') ### on('error')
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void on(type: 'error', callback: ErrorCallback): void
Listens for metadata errors. This API uses an asynchronous callback to return the result. Listens for metadata errors. This API uses an asynchronous callback to return the result.
...@@ -3396,7 +3751,7 @@ Listens for metadata errors. This API uses an asynchronous callback to return th ...@@ -3396,7 +3751,7 @@ Listens for metadata errors. This API uses an asynchronous callback to return th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | --------------------------------------- | | -------- | ------------- | ---- | --------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **metadataOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a metadata-related API such as **start()** and **release()**.| | type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **metadataOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a metadata-related API such as **start()** and **release()**.|
| callback | Callback\<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
......
...@@ -883,7 +883,7 @@ async function Demo() { ...@@ -883,7 +883,7 @@ async function Demo() {
getColorSpace(): colorSpaceManager.ColorSpaceManager getColorSpace(): colorSpaceManager.ColorSpaceManager
Obtains the color space of this image Obtains the color space of this image.
**System capability**: SystemCapability.Multimedia.Image.Core **System capability**: SystemCapability.Multimedia.Image.Core
......
...@@ -311,7 +311,7 @@ Enumerates the media description keys. ...@@ -311,7 +311,7 @@ Enumerates the media description keys.
**System capability**: SystemCapability.Multimedia.Media.Core **System capability**: SystemCapability.Multimedia.Media.Core
| Name | Value | Description | | Name | Value | Description |
| ----------------------------- | --------------- | ------------------------------------------------------------ | | ------------------------ | --------------- | ------------------------------------------------------------ |
| MD_KEY_TRACK_INDEX | 'track_index' | Track index, which is a number. | | MD_KEY_TRACK_INDEX | 'track_index' | Track index, which is a number. |
| MD_KEY_TRACK_TYPE | 'track_type' | Track type, which is a number. For details, see [MediaType](#mediatype8).| | MD_KEY_TRACK_TYPE | 'track_type' | Track type, which is a number. For details, see [MediaType](#mediatype8).|
| MD_KEY_CODEC_MIME | 'codec_mime' | Codec MIME type, which is a string. | | MD_KEY_CODEC_MIME | 'codec_mime' | Codec MIME type, which is a string. |
...@@ -322,7 +322,6 @@ Enumerates the media description keys. ...@@ -322,7 +322,6 @@ Enumerates the media description keys.
| MD_KEY_FRAME_RATE | 'frame_rate' | Video frame rate, which is a number, in units of 100 fps.| | MD_KEY_FRAME_RATE | 'frame_rate' | Video frame rate, which is a number, in units of 100 fps.|
| MD_KEY_AUD_CHANNEL_COUNT | 'channel_count' | Number of audio channels, which is a number. | | MD_KEY_AUD_CHANNEL_COUNT | 'channel_count' | Number of audio channels, which is a number. |
| MD_KEY_AUD_SAMPLE_RATE | 'sample_rate' | Sampling rate, which is a number, in units of Hz. | | MD_KEY_AUD_SAMPLE_RATE | 'sample_rate' | Sampling rate, which is a number, in units of Hz. |
| MD_KEY_LANGUAGE<sup>10+</sup> | "language" | Language, which is a string. |
## BufferingInfoType<sup>8+</sup> ## BufferingInfoType<sup>8+</sup>
...@@ -1001,124 +1000,6 @@ for (let i = 0; i < arrayDescription.length; i++) { ...@@ -1001,124 +1000,6 @@ for (let i = 0; i < arrayDescription.length; i++) {
} }
``` ```
### selectTrack<sup>10+</sup><a name=avplayer_selecttrack></a>
selectTrack(index: number): void
Selects an audio track. This API can be called only when the AVPlayer is in the prepared state. You can listen for the [trackChange event](#trackchange_on) to determine whether the API calling takes effect.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| index | number | Yes | Track ID, which can be obtained by calling [getTrackDescription](#avplayer_gettrackdescription).|
**Example**
```js
let index = 2
avPlayer.selectTrack(index)
```
### deselectTrack<sup>10+</sup><a name=avplayer_deselecttrack></a>
deselectTrack(index: number): void
Deselects an audio track. The default audio track will be used after the audio track is deselected. This API can be called only when the AVPlayer is in the prepared state. You can listen for the [trackChange event](#trackchange_on) to determine whether the API calling takes effect.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| index | number | Yes | Track ID. You can obtain the ID of the current track by calling [getCurrentTrack](#avplayer_getcurrenttrack).|
**Example**
```js
let index = 2
avPlayer.deselectTrack(index)
```
### getCurrentTrack<sup>10+</sup><a name=avplayer_getcurrenttrack></a>
getCurrentTrack(trackType: MediaType, callback: AsyncCallback\<number>): void
Obtains the ID of the current track. This API uses an asynchronous callback to return the result. It can be called only when the AVPlayer is in the prepared, playing, paused, or completed state.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ------------------------------------------------------------ |
| trackType | [MediaType](#mediatype) | Yes | Enumerates the media types. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the current track. If **-1** is returned, no track for the specified media type exists.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | ------------------------------------------ |
| 5400102 | Operation not allowed. Return by callback. |
**Example**
```js
let mediaType = media.MediaType.MEDIA_TYPE_AUD;
let trackIndex = null;
avPlayer.getCurrentTrack(mediaType, (err, index) => {
if (err == null) {
console.info('getCurrentTrack success');
trackIndex = index;
} else {
console.error('getCurrentTrack failed and error is ' + err.message);
}
});
```
### getCurrentTrack<sup>10+</sup>
getCurrentTrack(trackType: MediaType): Promise\<number>
Obtains the ID of the current track. This API uses a promise to return the result. It can be called only when the AVPlayer is in the prepared, playing, paused, or completed state.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
**Return value**
| Type | Description |
| ---------------- | ------------------------------------------------------------ |
| trackType | [MediaType](#mediatype) |
| Promise\<number>| Promise used to return the current track. If **-1** is returned, no track for the specified media type exists.|
**Error codes**
For details about the error codes, see [Media Error Codes](../errorcodes/errorcode-media.md).
| ID| Error Message |
| -------- | ----------------------------------------- |
| 5400102 | Operation not allowed. Return by promise. |
**Example**
```js
let mediaType = media.MediaType.MEDIA_TYPE_AUD;
let trackIndex = null;
avPlayer.getCurrentTrack(mediaType).then((index) => {
console.info('getCurrentTrack success');
trackIndex = index;
}).catch((err) => {
console.error('getCurrentTrack failed and catch error is ' + err.message);
});
```
### seek<sup>9+</sup><a name=avplayer_seek></a> ### seek<sup>9+</sup><a name=avplayer_seek></a>
seek(timeMs: number, mode?:SeekMode): void seek(timeMs: number, mode?:SeekMode): void
...@@ -1725,49 +1606,6 @@ Unsubscribes from the audio interruption event. ...@@ -1725,49 +1606,6 @@ Unsubscribes from the audio interruption event.
avPlayer.off('audioInterrupt') avPlayer.off('audioInterrupt')
``` ```
### on('trackChange')<sup>10+</sup><a name = trackchange_on></a>
on(type: 'trackChange', callback: (index: number, isSelect: boolean) => void): void;
Subscribes to track changes, which are triggered by calling **selectTrack** or **deselectTrack**.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ----------------------------------------------------- |
| type | string | Yes | Event type, which is **'trackChange'** in this case.|
| callback | function | Yes | Callback invoked when the event is triggered. |
**Example**
```js
avPlayer.on('trackChange', (index: number, isSelect: boolean) => {
console.info('trackChange success, and index is:' + index + ', isSelect is :' + isSelect)
})
```
### off('trackChange')<sup>10+</sup><a name = trackchange_off></a>
off(type: 'trackChange'): void
Unsubscribes from track changes
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | --------------------------------------------------------- |
| type | string | Yes | Event type, which is **'trackChange'** in this case.|
**Example**
```js
avPlayer.off('trackChange')
```
## AVPlayerState<sup>9+</sup><a name = avplayerstate></a> ## AVPlayerState<sup>9+</sup><a name = avplayerstate></a>
Enumerates the states of the [AVPlayer](#avplayer9). Your application can proactively obtain the AVPlayer state through the **state** attribute or obtain the reported AVPlayer state by subscribing to the [stateChange](#stateChange_on) event. For details about the rules for state transition, see [Audio Playback](../../media/using-avplayer-for-playback.md). Enumerates the states of the [AVPlayer](#avplayer9). Your application can proactively obtain the AVPlayer state through the **state** attribute or obtain the reported AVPlayer state by subscribing to the [stateChange](#stateChange_on) event. For details about the rules for state transition, see [Audio Playback](../../media/using-avplayer-for-playback.md).
...@@ -2680,6 +2518,8 @@ Enumerates the AVRecorder states. You can obtain the state through the **state** ...@@ -2680,6 +2518,8 @@ Enumerates the AVRecorder states. You can obtain the state through the **state**
Describes the audio and video recording parameters. Describes the audio and video recording parameters.
The **audioSourceType** and **videoSourceType** parameters are used to distinguish audio-only recording, video-only recording, and audio and video recording. For audio-only recording, set only **audioSourceType**. For video-only recording, set only **videoSourceType**. For audio and video recording, set both **audioSourceType** and **videoSourceType**.
**System capability**: SystemCapability.Multimedia.Media.AVRecorder **System capability**: SystemCapability.Multimedia.Media.AVRecorder
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -2691,8 +2531,6 @@ Describes the audio and video recording parameters. ...@@ -2691,8 +2531,6 @@ Describes the audio and video recording parameters.
| rotation | number | No | Rotation angle of the recorded video. The value can only be 0 (default), 90, 180, or 270. | | rotation | number | No | Rotation angle of the recorded video. The value can only be 0 (default), 90, 180, or 270. |
| location | [Location](#location) | No | Geographical location of the recorded video. By default, the geographical location information is not recorded. | | location | [Location](#location) | No | Geographical location of the recorded video. By default, the geographical location information is not recorded. |
The **audioSourceType** and **videoSourceType** parameters are used to distinguish audio-only recording, video-only recording, and audio and video recording. For audio-only recording, set only **audioSourceType**. For video-only recording, set only **videoSourceType**. For audio and video recording, set both **audioSourceType** and **videoSourceType**.
## AVRecorderProfile<sup>9+</sup> ## AVRecorderProfile<sup>9+</sup>
Describes the audio and video recording profile. Describes the audio and video recording profile.
...@@ -3517,13 +3355,15 @@ Enumerates the video recording states. You can obtain the state through the **st ...@@ -3517,13 +3355,15 @@ Enumerates the video recording states. You can obtain the state through the **st
Describes the video recording parameters. Describes the video recording parameters.
The **audioSourceType** and **videoSourceType** parameters are used to distinguish video-only recording from audio and video recording. (For audio-only recording recording, use **[AVRecorder](#avrecorder9)** or **[AudioRecorder](#audiorecorderdeprecated)**.) For video-only recording, set only **videoSourceType**. For audio and video recording, set both **audioSourceType** and **videoSourceType**.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder **System capability**: SystemCapability.Multimedia.Media.VideoRecorder
**System API**: This is a system API. **System API**: This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | | --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
| audioSourceType | [AudioSourceType](#audiosourcetype9) | Yes | Type of the audio source for video recording. | | audioSourceType | [AudioSourceType](#audiosourcetype9) | No | Type of the audio source for video recording. This parameter is mandatory for audio recording. |
| videoSourceType | [VideoSourceType](#videosourcetype9) | Yes | Type of the video source for video recording. | | videoSourceType | [VideoSourceType](#videosourcetype9) | Yes | Type of the video source for video recording. |
| profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. | | profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. |
| rotation | number | No | Rotation angle of the recorded video. The value can only be 0 (default), 90, 180, or 270. | | rotation | number | No | Rotation angle of the recorded video. The value can only be 0 (default), 90, 180, or 270. |
...@@ -3540,10 +3380,10 @@ Describes the video recording profile. ...@@ -3540,10 +3380,10 @@ Describes the video recording profile.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------------- | -------------------------------------------- | ---- | ---------------- | | ---------------- | -------------------------------------------- | ---- | ---------------- |
| audioBitrate | number | Yes | Audio encoding bit rate.| | audioBitrate | number | No | Audio encoding bit rate. This parameter is mandatory for audio recording.|
| audioChannels | number | Yes | Number of audio channels.| | audioChannels | number | No | Number of audio channels. This parameter is mandatory for audio recording.|
| audioCodec | [CodecMimeType](#codecmimetype8) | Yes | Audio encoding format. | | audioCodec | [CodecMimeType](#codecmimetype8) | No | Audio encoding format. This parameter is mandatory for audio recording. |
| audioSampleRate | number | Yes | Audio sampling rate. | | audioSampleRate | number | No | Audio sampling rate. This parameter is mandatory for audio recording. |
| fileFormat | [ContainerFormatType](#containerformattype8) | Yes | Container format of a file.| | fileFormat | [ContainerFormatType](#containerformattype8) | Yes | Container format of a file.|
| videoBitrate | number | Yes | Video encoding bit rate.| | videoBitrate | number | Yes | Video encoding bit rate.|
| videoCodec | [CodecMimeType](#codecmimetype8) | Yes | Video encoding format. | | videoCodec | [CodecMimeType](#codecmimetype8) | Yes | Video encoding format. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册