From 69f4938497719004cbe94d9a78463cb3143cf305 Mon Sep 17 00:00:00 2001 From: Gloria Date: Thu, 27 Jul 2023 09:47:10 +0800 Subject: [PATCH] Update docs against 20443+20557+20565+21196+21128+21161+21150+20272+21146+21025+21112+21006+21225 Signed-off-by: wusongqing --- .../js-apis-WorkSchedulerExtensionAbility.md | 2 +- .../reference/apis/js-apis-audio.md | 782 ++++++++++++++++-- ...-resourceschedule-deviceUsageStatistics.md | 2 +- .../windowmanager/application-window-fa.md | 3 +- 4 files changed, 719 insertions(+), 70 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md index 33555ada83..b9649e5104 100644 --- a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @@ -22,7 +22,7 @@ import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| context | [WorkSchedulerExtensionContext](js-apis-inner-application-WorkSchedulerExtensionContext.md) | Yes| No| Context of the **WorkSchedulerExtension**. This context is inherited from **ExtensionContext**.| +| context10+ | [WorkSchedulerExtensionContext](js-apis-inner-application-WorkSchedulerExtensionContext.md) | Yes| No| Context of the **WorkSchedulerExtension**. This context is inherited from **ExtensionContext**.| ## WorkSchedulerExtensionAbility.onWorkStart diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 9885bb2ee4..1a104a95a4 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -534,7 +534,6 @@ Enumerates the audio content types. | CONTENT_TYPE_MOVIE | 3 | Movie. | | CONTENT_TYPE_SONIFICATION | 4 | Notification tone. | | CONTENT_TYPE_RINGTONE8+ | 5 | Ringtone. | -| CONTENT_TYPE_ULTRASONIC10+| 9 | Ultrasonic.
This is a system API.| ## StreamUsage Enumerates the audio stream usage. @@ -544,13 +543,25 @@ Enumerates the audio stream usage. | Name | Value | Description | | ------------------------------------------| ------ | ---------- | | STREAM_USAGE_UNKNOWN | 0 | Unknown usage.| -| STREAM_USAGE_MEDIA | 1 | Used for media. | -| STREAM_USAGE_VOICE_COMMUNICATION | 2 | Used for voice communication.| -| STREAM_USAGE_VOICE_ASSISTANT9+ | 3 | Used for voice assistant.| -| STREAM_USAGE_ALARM10+ | 4 | Used for alarming. | -| STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | Used for notification.| -| STREAM_USAGE_ACCESSIBILITY10+ | 8 | Used for accessibility. | -| STREAM_USAGE_SYSTEM10+ | 9 | System tone (such as screen lock or keypad tone).
This is a system API.| +| STREAM_USAGE_MEDIA | 1 | Media. | +| STREAM_USAGE_MUSIC10+ | 1 | Music. | +| STREAM_USAGE_VOICE_COMMUNICATION | 2 | Voice communication.| +| STREAM_USAGE_VOICE_ASSISTANT9+ | 3 | Voice assistant.| +| STREAM_USAGE_ALARM10+ | 4 | Alarming. | +| STREAM_USAGE_VOICE_MESSAGE10+ | 5 | Voice message.| +| STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | Notification tone.| +| STREAM_USAGE_RINGTONE10+ | 6 | Ringtone. | +| STREAM_USAGE_NOTIFICATION10+ | 7 | Notification. | +| STREAM_USAGE_ACCESSIBILITY10+ | 8 | Accessibility. | +| STREAM_USAGE_SYSTEM10+ | 9 | System tone (such as screen lock sound effect or key tone).
This is a system API.| +| STREAM_USAGE_MOVIE10+ | 10 | Movie or video.| +| STREAM_USAGE_GAME10+ | 11 | Game sound effect. | +| STREAM_USAGE_AUDIOBOOK10+ | 12 | Audiobook. | +| STREAM_USAGE_NAVIGATION10+ | 13 | Navigation. | +| STREAM_USAGE_DTMF10+ | 14 | Dial tone.
This is a system API.| +| STREAM_USAGE_ENFORCED_TONE10+ | 15 | Forcible tone (such as camera shutter sound effect).
This is a system API.| +| STREAM_USAGE_ULTRASONIC10+ | 16 | Ultrasonic.
This is a system API.| + ## InterruptRequestType9+ @@ -661,7 +672,7 @@ Describes audio renderer information. | Name | Type | Mandatory | Description | | ------------- | --------------------------- | ---- | ---------------- | -| content | [ContentType](#contenttype) | Yes | Audio content type. | +| content | [ContentType](#contenttype) | No | Audio content type.
This parameter is mandatory in API versions 8 and 9 and optional since API version 10.| | usage | [StreamUsage](#streamusage) | Yes | Audio stream usage.| | rendererFlags | number | Yes | Audio renderer flags.| @@ -682,12 +693,22 @@ Describes the audio interruption result. Describes audio renderer configurations. -**System capability**: SystemCapability.Multimedia.Audio.Renderer - | Name | Type | Mandatory | Description | | ------------ | ---------------------------------------- | ---- | ---------------- | -| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Audio stream information.| -| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information.| +| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Audio stream information.
**System capability**: SystemCapability.Multimedia.Audio.Renderer| +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information.
**System capability**: SystemCapability.Multimedia.Audio.Renderer| +| privacyType10+ | [AudioPrivacyType](#audioprivacytype) | No| Whether the audio stream can be recorded by other applications. The default value is **0**.
**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture| + +## AudioPrivacyType10+ + +Enumerates whether an audio stream can be recorded by other applications. + +**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture + +| Name | Value | Description | +| -------------------- | ---- | -------------------------------- | +| PRIVACY_TYPE_PUBLIC | 0 | The audio stream can be recorded by other applications. | +| PRIVACY_TYPE_PRIVATE | 1 | The audio stream cannot be recorded by other applications.| ## InterruptEvent9+ @@ -779,21 +800,20 @@ Enumerates the device connection statuses. **System capability**: SystemCapability.Multimedia.Audio.Device -| Name | Value | Description | -| :--------- | :----- | :------------- | -| CONNECT | 0 | Connected. | -| DISCONNECT | 1 | Disconnected.| +| Name | Value | Description | +| :--------- | :--- | :------------- | +| CONNECT | 0 | Connected. | +| DISCONNECT | 1 | Disconnected.| ## AudioCapturerOptions8+ Describes audio capturer configurations. -**System capability**: SystemCapability.Multimedia.Audio.Capturer - -| Name | Type | Mandatory| Description | -| ------------ | --------------------------------------- | ---- | ---------------- | -| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Audio stream information.| -| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo) | Yes | Audio capturer information.| +| Name | Type | Mandatory| Description | +| ----------------------------------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Audio stream information.
**System capability**: SystemCapability.Multimedia.Audio.Capturer | +| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo) | Yes | Audio capturer information.
**System capability**: SystemCapability.Multimedia.Audio.Capturer | +| playbackCaptureConfig10+ | [AudioPlaybackCaptureConfig](#audioplaybackcaptureconfig) | No | Configuration of internal audio recording.
**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture | ## AudioCapturerInfo8+ @@ -810,14 +830,37 @@ Describes audio capturer information. Enumerates the audio source types. -**System capability**: SystemCapability.Multimedia.Audio.Core - | Name | Value | Description | | :------------------------------------------- | :----- | :--------------------- | -| SOURCE_TYPE_INVALID | -1 | Invalid audio source. | -| SOURCE_TYPE_MIC | 0 | Mic source. | -| SOURCE_TYPE_VOICE_RECOGNITION9+ | 1 | Voice recognition source. | -| SOURCE_TYPE_VOICE_COMMUNICATION | 7 | Voice communication source.| +| SOURCE_TYPE_INVALID | -1 | Invalid audio source.
**System capability**: SystemCapability.Multimedia.Audio.Core | +| SOURCE_TYPE_MIC | 0 | Mic source.
**System capability**: SystemCapability.Multimedia.Audio.Core| +| SOURCE_TYPE_VOICE_RECOGNITION9+ | 1 | Voice recognition source.
**System capability**: SystemCapability.Multimedia.Audio.Core | +| SOURCE_TYPE_PLAYBACK_CAPTURE10+ | 2 | Internal audio recording source.
**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture | +| SOURCE_TYPE_VOICE_COMMUNICATION | 7 | Voice communication source.
**System capability**: SystemCapability.Multimedia.Audio.Core| + +## AudioPlaybackCaptureConfig10+ + +Defines the configuration of internal audio recording. + +**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture + +| Name | Type | Mandatory| Description | +| ------------- | --------------------------------------------- | ---- | -------------------------------- | +| filterOptions | [CaptureFilterOptions](#capturefilteroptions) | Yes | Options for filtering the played audio streams to be recorded.| + +## CaptureFilterOptions10+ + +Defines the options for filtering the played audio streams to be recorded. + +**Required permissions**: ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO + +This permission is required when an application wants to record a played audio stream for which **StreamUsage** is set to **SOURCE_TYPE_VOICE_COMMUNICATION**. + +**System capability**: SystemCapability.Multimedia.Audio.PlaybackCapture + +| Name | Type | Mandatory| Description | +| ------ | ---------------------------------- | ---- | ------------------------------------------------------------ | +| usages | Array<[StreamUsage](#streamusage)> | Yes | [StreamUsage](#streamusage) of the audio stream to be recorded. You can specify zero or more stream usages. If the array is empty, the audio stream for which **StreamUsage** is **STREAM_USAGE_MEDIA** is recorded by default.| ## AudioScene8+ @@ -832,6 +875,17 @@ Enumerates the audio scenes. | AUDIO_SCENE_PHONE_CALL | 2 | Phone call audio scene.
This is a system API.| | AUDIO_SCENE_VOICE_CHAT | 3 | Voice chat audio scene. | +## VolumeAdjustType10+ + +Enumerates the volume adjustment types. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +| Name | Value | Description | +| :--------------------- | :----- | :-------------------------------------------- | +| VOLUME_UP | 0 | Adjusts the volume upwards.
This is a system API. | +| VOLUME_DOWN | 1 | Adjusts the volume downwards.
This is a system API. | + ## AudioManager Implements audio volume and audio device management. Before calling any API in **AudioManager**, you must use [getAudioManager](#audiogetaudiomanager) to create an **AudioManager** instance. @@ -2013,13 +2067,13 @@ audioManager.isMicrophoneMute().then((value) => { }); ``` -### on('volumeChange')9+ +### on('volumeChange')(deprecated) on(type: 'volumeChange', callback: Callback\): void > **NOTE** > -> You are advised to use [on('volumeChange')](#onvolumechange9) in **AudioVolumeManager**. +> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [on('volumeChange')](#onvolumechange9) in **AudioVolumeManager**. Subscribes to system volume change events. @@ -3005,6 +3059,280 @@ audioVolumeGroupManager.on('micStateChange', (micStateChange) => { }); ``` +### isVolumeUnadjustable10+ + +isVolumeUnadjustable(): boolean + +Checks whether the fixed volume mode is enabled. When the fixed volume mode is enabled, the volume cannot be adjusted. This API returns the result synchronously. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Return value** + +| Type | Description | +| ---------------------- | ------------------------------------------------------ | +| boolean | Returns the status of the fixed volume mode. The value **true** means that the fixed volume mode is enabled, and **false** means the opposite.| + +**Example** + +```js +bool volumeAdjustSwitch = audioVolumeGroupManager.isVolumeUnadjustable(); +console.info(`Whether it is volume unadjustable: ${volumeAdjustSwitch}.`); +``` + +### adjustVolumeByStep10+ + +adjustVolumeByStep(adjustType: VolumeAdjustType, callback: AsyncCallback<void>): void + +Adjusts the volume of the stream with the highest priority by step. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| adjustType | [VolumeAdjustType](#volumeadjusttype10) | Yes | Volume adjustment type. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by callback. | +| 6800301 | System error. Return by callback. | + +**Example** + +```js +audioVolumeGroupManager.adjustVolumeByStep(audio.VolumeAdjustType.VOLUME_UP, (err) => { + if (err) { + console.error(`Failed to adjust the volume by step. ${err}`); + return; + } else { + console.info('Success to adjust the volume by step.'); + } +}); +``` +### adjustVolumeByStep10+ + +adjustVolumeByStep(adjustType: VolumeAdjustType): Promise<void> + +Adjusts the volume of the stream with the highest priority by step. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| adjustType | [VolumeAdjustType](#volumeadjusttype10) | Yes | Volume adjustment type. | + +**Return value** + +| Type | Description | +| ------------------- | ----------------------------- | +| Promise<void> | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by promise. | +| 6800301 | System error. Return by promise. | + +**Example** + +```js +audioVolumeGroupManager.adjustVolumeByStep(audio.VolumeAdjustType.VOLUME_UP).then((value) => { + console.info('Success to adjust the volume by step.'); +}).catch((error) => { + console.error('Fail to adjust the volume by step.'); +}); +``` + +### adjustSystemVolumeByStep10+ + +adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType, callback: AsyncCallback<void>): void + +Adjusts the volume of a stream by step. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| adjustType | [VolumeAdjustType](#volumeadjusttype10) | Yes | Volume adjustment type. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by callback. | +| 6800301 | System error. Return by callback. | + +**Example** + +```js +audioVolumeGroupManager.adjustSystemVolumeByStep(audio.AudioVolumeType.MEDIA, audio.VolumeAdjustType.VOLUME_UP, (err) => { + if (err) { + console.error(`Failed to adjust the system volume by step ${err}`); + } else { + console.info('Success to adjust the system volume by step.'); + } +}); +``` +### adjustSystemVolumeByStep10+ + +adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType): Promise<void> + +Adjusts the volume of a stream by step. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| adjustType | [VolumeAdjustType](#volumeadjusttype10) | Yes | Volume adjustment type. | + +**Return value** + +| Type | Description | +| ------------------- | ----------------------------- | +| Promise<void> | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by promise. | +| 6800301 | System error. Return by promise. | + +**Example** + +```js +audioVolumeGroupManager.adjustSystemVolumeByStep(audio.AudioVolumeType.MEDIA, audio.VolumeAdjustType.VOLUME_UP).then((value) => { + console.info('Success to adjust the system volume by step.'); +}).catch((error) => { + console.error('Fail to adjust the system volume by step.'); +}); +``` + +### getSystemVolumeInDb10+ + +getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType, callback: AsyncCallback<number>): void + +Obtains the volume gain. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| volumeLevel | number | Yes | Volume level. | +| device | [DeviceType](#devicetype) | Yes | Device type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the volume gain (in dB). | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by callback. | +| 6800301 | System error. Return by callback. | + +**Example** + +```js +audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER, (err, dB) => { + if (err) { + console.error(`Failed to get the volume DB. ${err}`); + } else { + console.info(`Success to get the volume DB. ${dB}`); + } +}); +``` +### getSystemVolumeInDb10+ + +getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: DeviceType): Promise<number> + +Obtains the volume gain. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| volumeLevel | number | Yes | Volume level. | +| device | [DeviceType](#devicetype) | Yes | Device type. | + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------- | +| Promise<number> | Promise used to return the volume gain (in dB).| + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by promise. | +| 6800301 | System error. Return by promise. | + +**Example** + +```js +audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER).then((value) => { + console.info(`Success to get the volume DB. ${value}`); +}).catch((error) => { + console.error(`Fail to adjust the system volume by step. ${error}`); +}); +``` + ## AudioStreamManager9+ Implements audio stream management. Before calling any API in **AudioStreamManager**, you must use [getStreamManager](#getstreammanager9) to obtain an **AudioStreamManager** instance. @@ -3195,7 +3523,7 @@ async function getCurrentAudioCapturerInfoArray(){ ### on('audioRendererChange')9+ -on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArray>): void +on(type: 'audioRendererChange', callback: Callback<AudioRendererChangeInfoArray>): void Subscribes to audio renderer change events. @@ -3245,7 +3573,7 @@ audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => ### off('audioRendererChange')9+ -off(type: "audioRendererChange"): void +off(type: 'audioRendererChange'): void Unsubscribes from audio renderer change events. @@ -3274,7 +3602,7 @@ console.info('######### RendererChange Off is called #########'); ### on('audioCapturerChange')9+ -on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArray>): void +on(type: 'audioCapturerChange', callback: Callback<AudioCapturerChangeInfoArray>): void Subscribes to audio capturer change events. @@ -3323,7 +3651,7 @@ audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => ### off('audioCapturerChange')9+ -off(type: "audioCapturerChange"): void; +off(type: 'audioCapturerChange'): void; Unsubscribes from audio capturer change events. @@ -3408,7 +3736,7 @@ audioStreamManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => { ### getAudioEffectInfoArray10+ -getAudioEffectInfoArray(content: ContentType, usage: StreamUsage, callback: AsyncCallback<AudioEffectInfoArray>): void +getAudioEffectInfoArray(usage: StreamUsage, callback: AsyncCallback<AudioEffectInfoArray>): void Obtains information about the sound effect mode in use. This API uses an asynchronous callback to return the result. @@ -3418,14 +3746,21 @@ Obtains information about the sound effect mode in use. This API uses an asynchr | Name | Type | Mandatory | Description | | -------- | ----------------------------------- | -------- | --------------------------- | -| content | [ContentType](#contenttype) | Yes | Audio content type. | | usage | [StreamUsage](#streamusage) | Yes | Audio stream usage. | | callback | AsyncCallback<[AudioEffectInfoArray](#audioeffectinfoarray10)> | Yes | Callback used to return the information obtained.| +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by callback.| + **Example** ```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) => { console.info('getAudioEffectInfoArray **** Get Callback Called ****'); if (err) { console.error(`getAudioEffectInfoArray :ERROR: ${err}`); @@ -3438,7 +3773,7 @@ audioStreamManager.getAudioEffectInfoArray(audio.ContentType.CONTENT_TYPE_MUSIC, ### getAudioEffectInfoArray10+ -getAudioEffectInfoArray(content: ContentType, usage: StreamUsage): Promise<AudioEffectInfoArray> +getAudioEffectInfoArray(usage: StreamUsage): Promise<AudioEffectInfoArray> Obtains information about the sound effect mode in use. This API uses a promise to return the result. @@ -3448,7 +3783,6 @@ Obtains information about the sound effect mode in use. This API uses a promise | Name | Type | Mandatory | Description | | -------- | ----------------------------------- | -------- | --------------------------- | -| content | [ContentType](#contenttype) | Yes | Audio content type. | | usage | [StreamUsage](#streamusage) | Yes | Audio stream usage. | **Return value** @@ -3457,10 +3791,18 @@ Obtains information about the sound effect mode in use. This API uses a promise | --------------------------------------------------------------------------| --------------------------------------- | | Promise<[AudioEffectInfoArray](#audioeffectinfoarray10)> | Promise used to return the information obtained. | +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | Invalid parameter error. Return by promise. | + **Example** ```js -audioStreamManager.getAudioEffectInfoArray(audio.ContentType.CONTENT_TYPE_MUSIC, audio.StreamUsage.STREAM_USAGE_MEDIA).then((audioEffectInfoArray) => { +audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MEDIA).then((audioEffectInfoArray) => { console.info('getAudioEffectInfoArray ######### Get Promise is called ##########'); console.info(`The effect modes are: ${audioEffectInfoArray}`); }).catch((err) => { @@ -4277,8 +4619,8 @@ Describes an audio device. | deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.| | deviceType | [DeviceType](#devicetype) | Yes | No | Device type.| | id9+ | number | Yes | No | Device ID, which is unique. | -| name9+ | string | Yes | No | Device name.| -| address9+ | string | Yes | No | Device address.| +| name9+ | string | Yes | No | Device name.
For a Bluetooth device, you must request the **ohos.permission.USE_BLUETOOTH** permission.| +| address9+ | string | Yes | No | Device address.
For a Bluetooth device, you must request the **ohos.permission.USE_BLUETOOTH** permission.| | sampleRates9+ | Array<number> | Yes | No | Supported sampling rates.| | channelCounts9+ | Array<number> | Yes | No | Number of channels supported.| | channelMasks9+ | Array<number> | Yes | No | Supported channel masks.| @@ -4895,10 +5237,10 @@ async function getCacheDir(){ } let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); -let currStat = await fs.stat(path); -let buf = new ArrayBuffer(bufferSize); -let len = currStat.size % bufferSize == 0 ? Math.floor(currStat.size / bufferSize) : Math.floor(currStat.size / bufferSize + 1); -for (let i = 0;i < len; i++) { +fs.stat(path).then((stat) => { + let buf = new ArrayBuffer(bufferSize); + let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); + for (let i = 0;i < len; i++) { let options = { offset: i * bufferSize, length: bufferSize @@ -4913,7 +5255,9 @@ for (let i = 0;i < len; i++) { } }) }) -} + } +}); + ``` @@ -4949,21 +5293,22 @@ async function getCacheDir(){ } let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); -let currStat = await fs.stat(path); -let buf = new ArrayBuffer(bufferSize); -let len = currStat.size % bufferSize == 0 ? Math.floor(currStat.size / bufferSize) : Math.floor(currStat.size / bufferSize + 1); -for (let i = 0;i < len; i++) { - let options = { - offset: i * bufferSize, - length: bufferSize - } - let readsize = await fs.read(file.fd, buf, options) - try{ - let writeSize = await audioRenderer.write(buf); - } catch(err) { - console.error(`audioRenderer.write err: ${err}`); - } -} +fs.stat(path).then((stat) => { + let buf = new ArrayBuffer(bufferSize); + let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); + for (let i = 0;i < len; i++) { + let options = { + offset: i * bufferSize, + length: bufferSize + } + let readsize = await fs.read(file.fd, buf, options) + try{ + let writeSize = await audioRenderer.write(buf); + } catch(err) { + console.error(`audioRenderer.write err: ${err}`); + } + } +}); ``` ### getAudioTime8+ @@ -5276,6 +5621,216 @@ audioRenderer.setVolume(0.5, (err, data)=>{ }); ``` +### getMinStreamVolume10+ + +getMinStreamVolume(callback: AsyncCallback<number>): void + +Obtains the minimum volume of the application from the perspective of an audio stream. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | -----------| ------ | ------------------- | +|callback |AsyncCallback<number> | Yes |Callback used to return the minimum volume, ranging from 0 to 1.| + +**Example** + +```js +audioRenderer.getMinStreamVolume((err, minVolume) => { + if (err) { + console.error(`getMinStreamVolume error: ${err}`); + } else { + console.info(`getMinStreamVolume Success! ${minVolume}`); + } +}); +``` +### getMinStreamVolume10+ + +getMinStreamVolume(): Promise<number> + +Obtains the minimum volume of the application from the perspective of an audio stream. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Return value** + +| Type | Description | +| ------------------- | ----------------------------- | +| Promise<number>| Promise used to return the minimum volume, ranging from 0 to 1.| + +**Example** + +```js +audioRenderer.getMinStreamVolume().then((value) => { + console.info(`Get min stream volume Success! ${value}`); +}).catch((err) => { + console.error(`Get min stream volume Fail: ${err}`); +}); +``` + +### getMaxStreamVolume10+ + +getMaxStreamVolume(callback: AsyncCallback<number>): void + +Obtains the maximum volume of the application from the perspective of an audio stream. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | -----------| ------ | ------------------- | +|callback | AsyncCallback<number> | Yes |Callback used to return the maximum volume, ranging from 0 to 1.| + +**Example** + +```js +audioRenderer.getMaxStreamVolume((err, maxVolume) => { + if (err) { + console.error(`getMaxStreamVolume Fail: ${err}`); + } else { + console.info(`getMaxStreamVolume Success! ${maxVolume}`); + } +}); +``` +### getMaxStreamVolume10+ + +getMaxStreamVolume(): Promise<number> + +Obtains the maximum volume of the application from the perspective of an audio stream. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Return value** + +| Type | Description | +| ------------------- | ----------------------------- | +| Promise<number>| Promise used to return the maximum volume, ranging from 0 to 1.| + +**Example** + +```js +audioRenderer.getMaxStreamVolume().then((value) => { + console.info(`Get max stream volume Success! ${value}`); +}).catch((err) => { + console.error(`Get max stream volume Fail: ${err}`); +}); +``` + +### getUnderflowCount10+ + +getUnderflowCount(callback: AsyncCallback<number>): void + +Obtains the number of underflow audio frames in the audio stream that is being played. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | -----------| ------ | ------------------- | +|callback | AsyncCallback<number> | Yes |Callback used to return the number of underflow audio frames.| + +**Example** + +```js +audioRenderer.getUnderflowCount((err, underflowCount) => { + if (err) { + console.error(`getUnderflowCount Fail: ${err}`); + } else { + console.info(`getUnderflowCount Success! ${underflowCount}`); + } +}); +``` +### getUnderflowCount10+ + +getUnderflowCount(): Promise<number> + +Obtains the number of underflow audio frames in the audio stream that is being played. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Return value** + +| Type | Description | +| ------------------- | ----------------------------- | +| Promise<number>| Promise used to return the number of underflow audio frames.| + +**Example** + +```js +audioRenderer.getUnderflowCount().then((value) => { + console.info(`Get underflow count Success! ${value}`); +}).catch((err) => { + console.error(`Get underflow count Fail: ${err}`); +}); +``` + +### getCurrentOutputDevices10+ + +getCurrentOutputDevices(callback: AsyncCallback<AudioDeviceDescriptors>): void + +Obtains the output device descriptors of the audio streams. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Device + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | -----------| ------ | ------------------- | +|callback | AsyncCallback<AudioDeviceDescriptors> | Yes |Callback used to return the output device descriptors.| + +**Example** + +```js +audioRenderer.getCurrentOutputDevices((err, deviceInfo) => { + if (err) { + console.error(`getCurrentOutputDevices Fail: ${err}`); + } else { + console.info(`DeviceInfo id: ${deviceInfo.id}`); + console.info(`DeviceInfo type: ${descriptor.deviceType}`); + console.info(`DeviceInfo role: ${descriptor.deviceRole}`); + console.info(`DeviceInfo name: ${descriptor.name}`); + console.info(`DeviceInfo address: ${descriptor.address}`); + console.info(`DeviceInfo samplerates: ${descriptor.sampleRates[0]}`); + console.info(`DeviceInfo channelcounts: ${descriptor.channelCounts[0]}`); + console.info(`DeviceInfo channelmask: ${descriptor.channelMasks}`); + } +}); +``` +### getCurrentOutputDevices10+ + +getCurrentOutputDevices(): Promise<AudioDeviceDescriptors> + +Obtains the output device descriptors of the audio streams. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Device + +**Return value** + +| Type | Description | +| ------------------- | ----------------------------- | +| Promise<AudioDeviceDescriptors>| Promise used to return the output device descriptors.| + +**Example** + +```js +audioRenderer.getCurrentOutputDevices().then((deviceInfo) => { + console.info(`DeviceInfo id: ${deviceInfo.id}`); + console.info(`DeviceInfo type: ${descriptor.deviceType}`); + console.info(`DeviceInfo role: ${descriptor.deviceRole}`); + console.info(`DeviceInfo name: ${descriptor.name}`); + console.info(`DeviceInfo address: ${descriptor.address}`); + console.info(`DeviceInfo samplerates: ${descriptor.sampleRates[0]}`); + console.info(`DeviceInfo channelcounts: ${descriptor.channelCounts[0]}`); + console.info(`DeviceInfo channelmask: ${descriptor.channelMasks}`); +}).catch((err) => { + console.error(`Get current output devices Fail: ${err}`); +}); +``` + ### on('audioInterrupt')9+ on(type: 'audioInterrupt', callback: Callback\): void @@ -5375,7 +5930,7 @@ async function onAudioInterrupt(){ ### on('markReach')8+ -on(type: "markReach", frame: number, callback: Callback<number>): void +on(type: 'markReach', frame: number, callback: Callback<number>): void Subscribes to mark reached events. When the number of frames rendered reaches the value of the **frame** parameter, a callback is invoked. @@ -5422,7 +5977,7 @@ audioRenderer.off('markReach'); ### on('periodReach') 8+ -on(type: "periodReach", frame: number, callback: Callback<number>): void +on(type: 'periodReach', frame: number, callback: Callback<number>): void Subscribes to period reached events. When the number of frames rendered reaches the value of the **frame** parameter, a callback is triggered and the specified value is returned. @@ -5494,6 +6049,71 @@ audioRenderer.on('stateChange', (state) => { }); ``` +### on('outputDeviceChange') 10+ + +on(type: 'outputDeviceChange', callback: Callback\): void; + +Subscribes to audio output device change events. + +**System capability**: SystemCapability.Multimedia.Audio.Device + +**Parameters** + +| Name | Type | Mandatory| Description | +| :------- | :------------------------- | :--- | :------------------------------------------ | +| type | string | Yes | Event type. The value **'outputDeviceChange'** means the audio output device change event, which is triggered when the audio output device changes.| +| callback | Callback\<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the audio output device change. | + +**Error codes** + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | + +**Example** + +```js +audioRenderer.on('outputDeviceChange', (deviceChangeInfo) => { + if (err) { + console.error(`Subscribes output device change event callback Fail: ${err}`); + } else { + console.info(`Subscribes output device change event callback Success!`); + } +}); +``` +### off('outputDeviceChange') 10+ + +off(type: 'outputDeviceChange', callback?: Callback\): void; + +Unsubscribes from audio output device event changes. + +**System capability**: SystemCapability.Multimedia.Audio.Device + +**Parameters** + +| Name | Type | Mandatory| Description | +| :------- | :------------------------- | :--- | :------------------------------------------ | +| type | string | Yes | Event type. The value **'outputDeviceChange'** means the audio output device change event, which is triggered when the audio output device changes.| +| callback | Callback\<[AudioDeviceDescriptors](#audiodevicedescriptors)> | No | Callback used for unsubscription. | + +**Error codes** + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | + +**Example** + +```js +audioRenderer.off('outputDeviceChange', (deviceChangeInfo) => { + if (err) { + console.error(`Unsubscribes output device change event callback Fail: ${err}`); + } else { + console.info(`Unsubscribes output device change event callback Success!`); + } +}); +``` + ## AudioCapturer8+ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, you must use [createAudioCapturer](#audiocreateaudiocapturer8) to create an **AudioCapturer** instance. @@ -6092,10 +6712,38 @@ async function onAudioInterrupt(){ } ``` +### off('audioInterrupt')10+ + +off(type: 'audioInterrupt'): void + +Unsubscribes from audio interruption events. + +**System capability**: SystemCapability.Multimedia.Audio.Interrupt + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio capturing is interrupted.| + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error | + +**Example** + +```js +audioCapturer.off('audioInterrupt'); +``` + ### on('markReach')8+ -on(type: "markReach", frame: number, callback: Callback<number>): void +on(type: 'markReach', frame: number, callback: Callback<number>): void Subscribes to mark reached events. When the number of frames captured reaches the value of the **frame** parameter, a callback is invoked. @@ -6141,7 +6789,7 @@ audioCapturer.off('markReach'); ### on('periodReach')8+ -on(type: "periodReach", frame: number, callback: Callback<number>): void +on(type: 'periodReach', frame: number, callback: Callback<number>): void Subscribes to period reached events. When the number of frames captured reaches the value of the **frame** parameter, a callback is triggered and the specified value is returned. diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md index ae4decd405..771385a1b7 100644 --- a/en/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md @@ -1585,7 +1585,7 @@ Provides the usage duration information of an application. **System API**: This is a system API. -| Name | Type | Mandatory | Description | +|Name | Type | Mandatory | Description | | ------------------------------ | ---------------------------------------- | ---- | -------------- | | [key: string] | [BundleStatsInfo](#bundlestatsinfo) | Yes | Usage duration information by application.| diff --git a/en/application-dev/windowmanager/application-window-fa.md b/en/application-dev/windowmanager/application-window-fa.md index 89337707dc..6844fedd55 100644 --- a/en/application-dev/windowmanager/application-window-fa.md +++ b/en/application-dev/windowmanager/application-window-fa.md @@ -3,6 +3,7 @@ ## Basic Concepts Immersive window: System windows such as the status bar and navigation bar are controlled in such a way that they are unobtrusive and natural looking in the entire screen, thereby engaging users more deeply with the content displayed. + The immersive window feature is valid only when the main window of an application is displayed in full-screen mode. It does not apply to a main window in free window mode or a subwindow (for example, a dialog box or a floating window). ## When to Use @@ -164,7 +165,7 @@ To create a better video watching and gaming experience, you can use the immersi 2. Implement the immersive effect. You can use either of the following methods: - Method 1: When the main window of the application is a full-screen window, call **setWindowSystemBarEnable** to hide the status bar and navigation bar. - - Method 2: Call **setWindowLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setSystemProperties** to set the opacity, background color, text color, and highlighted icon of the status bar and navigation bar to ensure that their display effect is consistent with that of the main window. + - Method 2: Call **setWindowLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setWindowSystemBarProperties** to set the opacity, background color, text color, and highlighted icon of the status bar and navigation bar to ensure that their display effect is consistent with that of the main window. ```js -- GitLab