diff --git a/en/application-dev/media/audio-effect-management.md b/en/application-dev/media/audio-effect-management.md index e1de3111d8b776c87e5bf772b33ea619df813ced..884a9a9636e23f46b44ae73e5e75756bea27f438 100644 --- a/en/application-dev/media/audio-effect-management.md +++ b/en/application-dev/media/audio-effect-management.md @@ -91,7 +91,7 @@ Enable the default system audio effect. ## 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. ### Creating an AudioStreamManager Instance @@ -107,7 +107,7 @@ Create an **AudioStreamManager** instance. Before using **AudioStreamManager** A ### Querying the Audio Effect Mode of the Corresponding Scenario ```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) { console.error('Failed to get effect info array'); return; diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 56a63d8d5620ba09928caffd6de17861f500b2cb..d9ec7a942cc86ce8d331eb8920b81111e1c8c8c4 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -170,6 +170,7 @@ Obtains the output capability supported by a camera. This API returns the result **Example** ```js +let cameras = cameraManager.getSupportedCameras(); let cameraDevice = cameras[0]; let cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice); @@ -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 { + const cameraManager = camera.getCameraManager(context); + const output: Promise = 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 Describes the camera status information. @@ -835,7 +990,7 @@ cameraInput.close().then(() => { ### on('error') -on(type: 'error', camera:CameraDevice, callback: ErrorCallback\): void +on(type: 'error', camera:CameraDevice, callback: ErrorCallback): void 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 | -------- | -------------------------------- | --- | ------------------------------------------- | | 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.| -| callback | ErrorCallback\ | 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** ```js -let cameraDevice = cameras[0]; cameraInput.on('error', cameraDevice, (error) => { console.log(`Camera input error code: ${error.code}`); }) @@ -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_CONTINUOUS_AUTO | 2 | Continuous auto exposure. The metering point cannot be set.| - ## FocusMode +## FocusMode Enumerates the focus modes. @@ -2288,7 +2442,7 @@ captureSession.on('focusStateChange', (err, focusState) => { ### on('error') -on(type: 'error', callback: ErrorCallback\): void +on(type: 'error', callback: ErrorCallback): void 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 | 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**.| -| callback | ErrorCallback\ | 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** @@ -2547,7 +2701,7 @@ previewOutput.on('frameEnd', () => { ### on('error') -on(type: 'error', callback: ErrorCallback\): void +on(type: 'error', callback: ErrorCallback): void 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 | 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()**.| -| callback | ErrorCallback\ | 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** @@ -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 { + 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 Enumerates the image rotation angles. @@ -2772,6 +2969,17 @@ For details about the error codes, see [CameraErrorCode](#cameraerrorcode). **Example** ```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(() => { console.log('Promise returned to indicate that photo capture request success.'); }).catch((err) => { @@ -2938,7 +3146,7 @@ photoOutput.on('captureEnd', (err, captureEndInfo) => { ### on('error') -on(type: 'error', callback: ErrorCallback\): void +on(type: 'error', callback: ErrorCallback): void 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 | 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.| -| callback | ErrorCallback\ | 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** @@ -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\): 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 Defines the frame shutter information. @@ -3217,7 +3572,7 @@ videoOutput.on('frameEnd', () => { ### on('error') -on(type: 'error', callback: ErrorCallback\): void +on(type: 'error', callback: ErrorCallback): void 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 | 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()**.| -| callback | Callback\ | 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** @@ -3385,7 +3740,7 @@ metadataOutput.on('metadataObjectsAvailable', (err, metadataObjectArr) => { ### on('error') -on(type: 'error', callback: ErrorCallback\): void +on(type: 'error', callback: ErrorCallback): void 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 | 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()**.| -| callback | Callback\ | 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** diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index 24c8730727b438c9efd3bfd4244fa55a5a605add..e09c5fd1a1b2fc826611889232ccaf2ad8717d43 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -883,7 +883,7 @@ async function Demo() { getColorSpace(): colorSpaceManager.ColorSpaceManager -Obtains the color space of this image +Obtains the color space of this image. **System capability**: SystemCapability.Multimedia.Image.Core diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index 4f290e8cc883e736d7aeacd4bebd26940c699217..5654300a33ef42db7686a4c3de3ff541f4bdb8a0 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -310,19 +310,18 @@ Enumerates the media description keys. **System capability**: SystemCapability.Multimedia.Media.Core -| Name | Value | Description | -| ----------------------------- | --------------- | ------------------------------------------------------------ | -| 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_CODEC_MIME | 'codec_mime' | Codec MIME type, which is a string. | -| MD_KEY_DURATION | 'duration' | Media duration, which is a number, in units of ms. | -| MD_KEY_BITRATE | 'bitrate' | Bit rate, which is a number, in units of bit/s. | -| MD_KEY_WIDTH | 'width' | Video width, which is a number, in units of pixel. | -| MD_KEY_HEIGHT | 'height' | Video height, which is a number, in units of pixel. | -| 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_SAMPLE_RATE | 'sample_rate' | Sampling rate, which is a number, in units of Hz. | -| MD_KEY_LANGUAGE10+ | "language" | Language, which is a string. | +| Name | Value | Description | +| ------------------------ | --------------- | ------------------------------------------------------------ | +| 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_CODEC_MIME | 'codec_mime' | Codec MIME type, which is a string. | +| MD_KEY_DURATION | 'duration' | Media duration, which is a number, in units of ms. | +| MD_KEY_BITRATE | 'bitrate' | Bit rate, which is a number, in units of bit/s. | +| MD_KEY_WIDTH | 'width' | Video width, which is a number, in units of pixel. | +| MD_KEY_HEIGHT | 'height' | Video height, which is a number, in units of pixel. | +| 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_SAMPLE_RATE | 'sample_rate' | Sampling rate, which is a number, in units of Hz. | ## BufferingInfoType8+ @@ -1001,124 +1000,6 @@ for (let i = 0; i < arrayDescription.length; i++) { } ``` -### selectTrack10+ - -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) -``` - -### deselectTrack10+ - -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) -``` - -### getCurrentTrack10+ - -getCurrentTrack(trackType: MediaType, callback: AsyncCallback\): 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\ | 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); - } -}); -``` - -### getCurrentTrack10+ - -getCurrentTrack(trackType: MediaType): Promise\ - -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\| 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); -}); -``` - ### seek9+ seek(timeMs: number, mode?:SeekMode): void @@ -1725,49 +1606,6 @@ Unsubscribes from the audio interruption event. avPlayer.off('audioInterrupt') ``` -### on('trackChange')10+ - -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')10+ - -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') -``` - ## AVPlayerState9+ 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** 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 | Name | Type | Mandatory| Description | @@ -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. | | 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**. - ## AVRecorderProfile9+ Describes the audio and video recording profile. @@ -3517,13 +3355,15 @@ Enumerates the video recording states. You can obtain the state through the **st 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 API**: This is a system API. | 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. | | 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. | @@ -3540,10 +3380,10 @@ Describes the video recording profile. | 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. | +| audioBitrate | number | No | Audio encoding bit rate. This parameter is mandatory for audio recording.| +| audioChannels | number | No | Number of audio channels. This parameter is mandatory for audio recording.| +| audioCodec | [CodecMimeType](#codecmimetype8) | No | Audio encoding format. This parameter is mandatory for audio recording. | +| audioSampleRate | number | No | Audio sampling rate. This parameter is mandatory for audio recording. | | fileFormat | [ContainerFormatType](#containerformattype8) | Yes | Container format of a file.| | videoBitrate | number | Yes | Video encoding bit rate.| | videoCodec | [CodecMimeType](#codecmimetype8) | Yes | Video encoding format. |