@@ -21,38 +21,49 @@ This following figure shows the audio capturer state transitions.
...
@@ -21,38 +21,49 @@ This following figure shows the audio capturer state transitions.
## Constraints
## Constraints
Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md).
Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
## How to Develop
## How to Develop
For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8).
For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8).
1. Use **createAudioCapturer()** to create an**AudioCapturer** instance.
1. Use **createAudioCapturer()** to create a global**AudioCapturer** instance.
Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording state, and register a callback for notification.
Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording state, and register a callback for notification.
```js
```js
importaudiofrom'@ohos.multimedia.audio';
importaudiofrom'@ohos.multimedia.audio';
importfsfrom'@ohos.file.fs';// It will be used for the call of the read function in step 3.
// Perform a self-test on APIs related to audio rendering.
@Entry
@Component
structAudioRenderer{
@Statemessage:string='Hello World'
privateaudioCapturer:audio.AudioCapturer;// It will be called globally.
7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
...
@@ -202,12 +202,13 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
...
@@ -202,12 +202,13 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
After the mark reached event is subscribed to, when the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
After the mark reached event is subscribed to, when the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
audioCapturer.off('markReach');// Unsubscribe from the mark reached event. This event will no longer be listened for.
this.audioCapturer.off('markReach');// Unsubscribe from the mark reached event. This event will no longer be listened for.
}
```
```
8. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
8. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
...
@@ -215,40 +216,43 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
...
@@ -215,40 +216,43 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
After the period reached event is subscribed to, each time the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
After the period reached event is subscribed to, each time the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
console.info(`In this period, the Capturer reached frame: ${reachNumber}`);
console.info('Period reach event Received');
});
console.info(`In this period, the Capturer reached frame: ${reachNumber}`);
});
audioCapturer.off('periodReach');// Unsubscribe from the period reached event. This event will no longer be listened for.
this.audioCapturer.off('periodReach');// Unsubscribe from the period reached event. This event will no longer be listened for.
}
```
```
9. If your application needs to perform some operations when the audio capturer state is updated, it can subscribe to the state change event. When the audio capturer state is updated, the application receives a callback containing the event type.
9. If your application needs to perform some operations when the audio capturer state is updated, it can subscribe to the state change event. When the audio capturer state is updated, the application receives a callback containing the event type.
```js
```js
audioCapturer.on('stateChange', (state) => {
async stateChange(){
console.info(`AudioCapturerLog: Changed State to : ${state}`)
this.audioCapturer.on('stateChange', (state) => {
switch (state) {
console.info(`AudioCapturerLog: Changed State to : ${state}`)
case audio.AudioState.STATE_PREPARED:
switch (state) {
console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------');
case audio.AudioState.STATE_PREPARED:
console.info('Audio State is : Prepared');
console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------');
break;
console.info('Audio State is : Prepared');
case audio.AudioState.STATE_RUNNING:
break;
console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------');
case audio.AudioState.STATE_RUNNING:
console.info('Audio State is : Running');
console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------');
break;
console.info('Audio State is : Running');
case audio.AudioState.STATE_STOPPED:
break;
console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------');
case audio.AudioState.STATE_STOPPED:
console.info('Audio State is : stopped');
console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------');
break;
console.info('Audio State is : stopped');
case audio.AudioState.STATE_RELEASED:
break;
console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------');
case audio.AudioState.STATE_RELEASED:
console.info('Audio State is : released');
console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------');
break;
console.info('Audio State is : released');
default:
break;
console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------');
default:
console.info('Audio State is : invalid');
console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------');
-**PREPARED**: The audio renderer enters this state by calling **create()**.
-**PREPARED**: The audio renderer enters this state by calling **create()**.
-**RUNNING**: The audio renderer enters this state by calling **start()** when it is in the **PREPARED** state or by calling **start()** when it is in the **STOPPED** state.
-**RUNNING**: The audio renderer enters this state by calling **start()** when it is in the **PREPARED** state or by calling **start()** when it is in the **STOPPED** state.
-**PAUSED**: The audio renderer enters this state by calling **pause()** when it is in the **RUNNING** state. When the audio playback is paused, it can call **start()** to resume the playback.
-**PAUSED**: The audio renderer enters this state by calling **pause()** when it is in the **RUNNING** state. When the audio playback is paused, it can call **start()** to resume the playback.
-**STOPPED**: The audio renderer enters this state by calling **stop()** when it is in the **PAUSED** or **RUNNING** state.
-**STOPPED**: The audio renderer enters this state by calling **stop()** when it is in the **PAUSED** or **RUNNING** state.
-**RELEASED**: The audio renderer enters this state by calling **release()** when it is in the **PREPARED**, **PAUSED**, or **STOPPED** state. In this state, the audio renderer releases all occupied hardware and software resources and will not transit to any other state.
-**RELEASED**: The audio renderer enters this state by calling **release()** when it is in the **PREPARED**, **PAUSED**, or **STOPPED** state. In this state, the audio renderer releases all occupied hardware and software resources and will not transit to any other state.
## How to Develop
## How to Develop
For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8).
For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8).
1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.
1. Use **createAudioRenderer()** to create a global **AudioRenderer** instance.
Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.
Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.
```js
```js
importaudiofrom'@ohos.multimedia.audio';
importaudiofrom'@ohos.multimedia.audio';
importfsfrom'@ohos.file.fs';
// Perform a self-test on APIs related to audio rendering.
@Entry
@Component
structAudioRenderer1129{
privateaudioRenderer:audio.AudioRenderer;
privatebufferSize;// It will be used for the call of the write function in step 3.
privateaudioRenderer1:audio.AudioRenderer;// It will be used for the call in the complete example in step 14.
privateaudioRenderer2:audio.AudioRenderer;// It will be used for the call in the complete example in step 14.
console.info('Renderer is not in a correct state to start');
console.info('Renderer is not in a correct state to start');
return;
return;
}
}
awaitaudioRenderer.start();
awaitthis.audioRenderer.start();
state=audioRenderer.state;
state=this.audioRenderer.state;
if(state==audio.AudioState.STATE_RUNNING){
if(state==audio.AudioState.STATE_RUNNING){
console.info('Renderer started');
console.info('Renderer started');
}else{
}else{
...
@@ -81,117 +88,102 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
...
@@ -81,117 +88,102 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
}
}
}
}
```
```
The renderer state will be **STATE_RUNNING** once the audio renderer is started. The application can then begin reading buffers.
The renderer state will be **STATE_RUNNING** once the audio renderer is started. The application can then begin reading buffers.
3. Call **write()** to write data to the buffer.
3. Call **write()** to write data to the buffer.
Read the audio data to be played to the buffer. Call **write()** repeatedly to write the data to the buffer.
Read the audio data to be played to the buffer. Call **write()** repeatedly to write the data to the buffer. Import fs from '@ohos.file.fs'; as step 1.
```js
```js
importfsfrom'@ohos.file.fs';
asyncwriteData(){
importaudiofrom'@ohos.multimedia.audio';
// Set a proper buffer size for the audio renderer. You can also select a buffer of another size.
letdir=globalThis.fileDir;// You must use the sandbox path.
// The write operation can be performed only when the state is STATE_RUNNING.
constfilePath=dir+'/file_example_WAV_2MG.wav';// The file to render is in the following path: /data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav
letstat=awaitfs.stat(filePath);// Music file information.
letdir=globalThis.fileDir;// You must use the sandbox path.
letbuf=newArrayBuffer(this.bufferSize);
constfilePath=dir+'/file_example_WAV_2MG.wav';// The file to render is in the following path: /data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav
9. (Optional) Use **on('audioInterrupt')** to subscribe to the audio interruption event, and use **off('audioInterrupt')** to unsubscribe from the event.
9. (Optional) Use **on('audioInterrupt')** to subscribe to the audio interruption event, and use **off('audioInterrupt')** to unsubscribe from the event.
...
@@ -272,110 +259,116 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
...
@@ -272,110 +259,116 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
In the case of audio interruption, the application may encounter write failures. To avoid such failures, interruption-unaware applications can use **audioRenderer.state** to check the audio renderer state before writing audio data. The applications can obtain more details by subscribing to the audio interruption events. For details, see [InterruptEvent](../reference/apis/js-apis-audio.md#interruptevent9).
In the case of audio interruption, the application may encounter write failures. To avoid such failures, interruption-unaware applications can use **audioRenderer.state** to check the audio renderer state before writing audio data. The applications can obtain more details by subscribing to the audio interruption events. For details, see [InterruptEvent](../reference/apis/js-apis-audio.md#interruptevent9).
It should be noted that the audio interruption event subscription of the **AudioRenderer** module is slightly different from **on('interrupt')** in [AudioManager](../reference/apis/js-apis-audio.md#audiomanager). The **on('interrupt')** and **off('interrupt')** APIs are deprecated since API version 9. In the **AudioRenderer** module, you only need to call **on('audioInterrupt')** to listen for focus change events. When the **AudioRenderer** instance created by the application performs actions such as start, stop, and pause, it requests the focus, which triggers focus transfer and in return enables the related **AudioRenderer** instance to receive a notification through the callback. For instances other than **AudioRenderer**, such as frequency modulation (FM) and voice wakeup, the application does not create an instance. In this case, the application can call **on('interrupt')** in **AudioManager** to receive a focus change notification.
It should be noted that the audio interruption event subscription of the **AudioRenderer** module is slightly different from **on('interrupt')** in [AudioManager](../reference/apis/js-apis-audio.md#audiomanager). The **on('interrupt')** and **off('interrupt')** APIs are deprecated since API version 9. In the **AudioRenderer** module, you only need to call **on('audioInterrupt')** to listen for focus change events. When the **AudioRenderer** instance created by the application performs actions such as start, stop, and pause, it requests the focus, which triggers focus transfer and in return enables the related **AudioRenderer** instance to receive a notification through the callback. For instances other than **AudioRenderer**, such as frequency modulation (FM) and voice wakeup, the application does not create an instance. In this case, the application can call **on('interrupt')** in **AudioManager** to receive a focus change notification.
// Notify the application that the rendering starts.
// Notify the application that the rendering starts.
caseaudio.InterruptHint.INTERRUPT_HINT_RESUME:
caseaudio.InterruptHint.INTERRUPT_HINT_RESUME:
startRenderer();
this.startRenderer();
break;
break;
// Notify the application that the audio stream is interrupted. The application then determines whether to continue. (In this example, the application pauses the rendering.)
// Notify the application that the audio stream is interrupted. The application then determines whether to continue. (In this example, the application pauses the rendering.)
caseaudio.InterruptHint.INTERRUPT_HINT_PAUSE:
caseaudio.InterruptHint.INTERRUPT_HINT_PAUSE:
isPlay=false;
console.info('isPlay is false');
pauseRenderer();
this.pauseRenderer();
break;
break;
}
}
}
}
});
});
}
audioRenderer.off('audioInterrupt');// Unsubscribe from the audio interruption event. This event will no longer be listened for.
```
```
10. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
10. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
After the mark reached event is subscribed to, when the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned.
After the mark reached event is subscribed to, when the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned.
this.audioRenderer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for.
}
```
```
11. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
11. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
After the period reached event is subscribed to, each time the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned.
After the period reached event is subscribed to, each time the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned.
```js
audioRenderer.on('periodReach',(reachNumber)=>{
console.info('Period reach event Received');
console.info(`In this period, the renderer reached frame: ${reachNumber} `);
});
audioRenderer.off('periodReach');// Unsubscribe from the period reached event. This event will no longer be listened for.
console.info(`In this period, the renderer reached frame: ${reachNumber} `);
});
this.audioRenderer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for.
}
```
```
12. (Optional) Use **on('stateChange')** to subscribe to audio renderer state changes.
12. (Optional) Use **on('stateChange')** to subscribe to audio renderer state changes.
After the **stateChange** event is subscribed to, when the audio renderer state changes, a callback is triggered and the audio renderer state is returned.
After the **stateChange** event is subscribed to, when the audio renderer state changes, a callback is triggered and the audio renderer state is returned.
console.info(`Current renderer state is: ${audioState}`);
console.info('State change event Received');
});
console.info(`Current renderer state is: ${audioState}`);
});
}
```
```
13. (Optional) Handle exceptions of **on()**.
13. (Optional) Handle exceptions of **on()**.
If the string or the parameter type passed in **on()** is incorrect , the application throws an exception. In this case, you can use **try catch** to capture the exception.
If the string or the parameter type passed in **on()** is incorrect , the application throws an exception. In this case, you can use **try catch** to capture the exception.
```js
```js
try{
async errorCall(){
audioRenderer.on('invalidInput',()=>{// The string is invalid.
try {
})
this.audioRenderer.on('invalidInput', () => { // The string is invalid.
}catch(err){
})
console.info(`Call on function error, ${err}`);// The application throws exception 401.
} catch (err) {
}
console.info(`Call on function error, ${err}`); // The application throws exception 401.
try{
}
audioRenderer.on(1,()=>{// The type of the input parameter is incorrect.
try {
})
this.audioRenderer.on(1, () => { // The type of the input parameter is incorrect.
}catch(err){
})
console.info(`Call on function error, ${err}`);// The application throws exception 6800101.
} catch (err) {
console.info(`Call on function error, ${err}`); // The application throws exception 6800101.
}
}
}
```
```
14. (Optional) Refer to the complete example of **on('audioInterrupt')**.
14. (Optional) Refer to the complete example of **on('audioInterrupt')**.
Declare audioRenderer1 and audioRenderer2 first. For details, see step 1.
Create **AudioRender1** and **AudioRender2** in an application, configure the independent interruption mode, and call **on('audioInterrupt')** to subscribe to audio interruption events. At the beginning, **AudioRender1** has the focus. When **AudioRender2** attempts to obtain the focus, **AudioRender1** receives a focus transfer notification and the related log information is printed. If the shared mode is used, the log information will not be printed during application running.
Create **AudioRender1** and **AudioRender2** in an application, configure the independent interruption mode, and call **on('audioInterrupt')** to subscribe to audio interruption events. At the beginning, **AudioRender1** has the focus. When **AudioRender2** attempts to obtain the focus, **AudioRender1** receives a focus transfer notification and the related log information is printed. If the shared mode is used, the log information will not be printed during application running.
letdir=globalThis.fileDir;// You must use the sandbox path.
letdir=globalThis.fileDir;// You must use the sandbox path.
constpath1=dir+'/music001_48000_32_1.wav';// The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music001_48000_32_1.wav
constpath1=dir+'/music001_48000_32_1.wav';// The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music001_48000_32_1.wav
...
@@ -425,14 +418,14 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
...
@@ -425,14 +418,14 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
letstat=awaitfs.stat(path1);// Music file information.
letstat=awaitfs.stat(path1);// Music file information.
letdir=globalThis.fileDir;// You must use the sandbox path.
letdir=globalThis.fileDir;// You must use the sandbox path.
constpath2=dir+'/music002_48000_32_1.wav';// The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music002_48000_32_1.wav
constpath2=dir+'/music002_48000_32_1.wav';// The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music002_48000_32_1.wav
...
@@ -497,14 +490,14 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
...
@@ -497,14 +490,14 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
letstat=awaitfs.stat(path2);// Music file information.
letstat=awaitfs.stat(path2);// Music file information.
letpathDir="/data/storage/el2/base/haps/entry/files"// The path used here is an example. Obtain the path based on project requirements.
// Use getRawFileDescriptor of the resource management module to obtain the media assets in the application, and use the fdSrc attribute of the AVPlayer to initialize the media asset.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command.
// For details on the fd/offset/length parameter, see the Media API. The globalThis.abilityContext parameter is a system environment variable and is saved as a global variable on the main page during the system boost.
- Session metadata. In addition to the current media asset ID (mandatory), you can set the title, album, author, duration, and previous/next media asset ID. For details about the session metadata, see **AVMetadata** in the API document.
- Session metadata. In addition to the current media asset ID (mandatory), you can set the title, album, author, duration, and previous/next media asset ID. For details about the session metadata, see **AVMetadata** in the API document.
- Launcher ability, which is implemented by calling an API of **WantAgent**. Generally, **WantAgent** is used to encapsulate want information. For more information, see [wantAgent](../reference/apis/js-apis-wantAgent.md).
- Launcher ability, which is implemented by calling an API of [WantAgent](../reference/apis/js-apis-wantAgent.md). Generally, **WantAgent** is used to encapsulate want information.
- Playback state information.
- Playback state information.
```js
// Set the session metadata.
```js
letmetadata={
// Set the session metadata.
assetId:"121278",
letmetadata={
title:"lose yourself",
assetId:"121278",
artist:"Eminem",
title:"lose yourself",
author:"ST",
artist:"Eminem",
album:"Slim shady",
author:"ST",
writer:"ST",
album:"Slim shady",
composer:"ST",
writer:"ST",
duration:2222,
composer:"ST",
mediaImage:"https://www.example.com/example.jpg",// Set it based on your project requirements.
duration:2222,
subtitle:"8 Mile",
mediaImage:"https://www.example.com/example.jpg",// Set it based on your project requirements.
description:"Rap",
subtitle:"8 Mile",
lyric:"https://www.example.com/example.lrc",// Set it based on your project requirements.
description:"Rap",
previousAssetId:"121277",
lyric:"https://www.example.com/example.lrc",// Set it based on your project requirements.
> All APIs of the **AVSession** module are system APIs and can be called only by system applications.
## Overview
## Overview
AVSession, short for audio and video session, is also known as media session.
AVSession, short for audio and video session, is also known as media session.
...
@@ -49,4 +53,4 @@ The **AVSession** module provides two classes: **AVSession** and **AVSessionCont
...
@@ -49,4 +53,4 @@ The **AVSession** module provides two classes: **AVSession** and **AVSessionCont
- AVSession can transmit media playback information and control commands. It does not display information or execute control commands.
- AVSession can transmit media playback information and control commands. It does not display information or execute control commands.
- Do not develop Media Controller for common applications. For common audio and video applications running on OpenHarmony, the default control end is Media Controller, which is a system application. You do not need to carry out additional development for Media Controller.
- Do not develop Media Controller for common applications. For common audio and video applications running on OpenHarmony, the default control end is Media Controller, which is a system application. You do not need to carry out additional development for Media Controller.
- If you want to develop your own system running OpenHarmony, you can develop your own Media Controller.
- If you want to develop your own system running OpenHarmony, you can develop your own Media Controller.
- For better background management of audio and video applications, the **AVSession** module enforces background control for third-party applications. Only third-party applications that have accessed AVSession can play audio in the background. Otherwise, the system forcibly pauses the playback when a third-party application switches to the background.
- For better background management of audio and video applications, the **AVSession** module enforces background control for applications. Only applications that have accessed AVSession can play audio in the background. Otherwise, the system forcibly pauses the playback when an application switches to the background.
| LOCAL_NETWORK_ID<sup>9+</sup> | string | Yes | No | Network ID of the local device.<br>This is a system API.<br>**System capability**: SystemCapability.Multimedia.Audio.Device |
| LOCAL_NETWORK_ID<sup>9+</sup> | string | Yes | No | Network ID of the local device.<br>This is a system API.<br>**System capability**: SystemCapability.Multimedia.Audio.Device |
| DEFAULT_VOLUME_GROUP_ID<sup>9+</sup> | number | Yes | No | Default volume group ID.<br>**System capability**: SystemCapability.Multimedia.Audio.Volume |
| DEFAULT_VOLUME_GROUP_ID<sup>9+</sup> | number | Yes | No | Default volume group ID.<br>**System capability**: SystemCapability.Multimedia.Audio.Volume |
| DEFAULT_INTERRUPT_GROUP_ID<sup>9+</sup> | number | Yes | No | Default audio interruption group ID.<br>**System capability**: SystemCapability.Multimedia.Audio.Interrupt |
| DEFAULT_INTERRUPT_GROUP_ID<sup>9+</sup> | number | Yes | No | Default audio interruption group ID.<br>**System capability**: SystemCapability.Multimedia.Audio.Interrupt |
**Example**
**Example**
...
@@ -349,7 +349,10 @@ Enumerates the audio stream types.
...
@@ -349,7 +349,10 @@ Enumerates the audio stream types.
| VOICE_CALL<sup>8+</sup> | 0 | Audio stream for voice calls.|
| VOICE_CALL<sup>8+</sup> | 0 | Audio stream for voice calls.|
| RINGTONE | 2 | Audio stream for ringtones. |
| RINGTONE | 2 | Audio stream for ringtones. |
| MEDIA | 3 | Audio stream for media purpose. |
| MEDIA | 3 | Audio stream for media purpose. |
| ALARM<sup>10+</sup> | 4 | Audio stream for alarming. |
| ACCESSIBILITY<sup>10+</sup> | 5 | Audio stream for accessibility. |
| VOICE_ASSISTANT<sup>8+</sup> | 9 | Audio stream for voice assistant.|
| VOICE_ASSISTANT<sup>8+</sup> | 9 | Audio stream for voice assistant.|
| ULTRASONIC<sup>10+</sup> | 10 | Audio stream for ultrasonic.<br>This is a system API.|
| ALL<sup>9+</sup> | 100 | All public audio streams.<br>This is a system API.|
| ALL<sup>9+</sup> | 100 | All public audio streams.<br>This is a system API.|
## InterruptRequestResultType<sup>9+</sup>
## InterruptRequestResultType<sup>9+</sup>
...
@@ -531,7 +534,7 @@ Enumerates the audio content types.
...
@@ -531,7 +534,7 @@ Enumerates the audio content types.
> The APIs of this module are supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
> - This API is deprecated since API version 9 and will be retained until API version 13.
> - Certain functionalities are changed as system APIs and can be used only by system applications. To use these functionalities, call [@ohos.filemanagement.userFileManager](js-apis-userFileManager.md).
> - The functionalities for selecting and storing media assets are still open to common applications. To use these functionalities, call [@ohos.file.picker](js-apis-file-picker.md).
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
> **NOTE**
> **NOTE**
>
> This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
> **NOTE**
> **NOTE**
>
> This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result.
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result.
> **NOTE**
> **NOTE**
>
> This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets.
Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets.
> **NOTE**
> **NOTE**
>
> This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
> You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the list of URIs (starting with **datashare://**) that store the selected media assets.|
| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the list of URIs (starting with **datashare://**) that store the selected media assets.|
Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets.
Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets.
> **NOTE**
> **NOTE**
>
> This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
> You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
| option | [MediaSelectOption](#mediaselectoptiondeprecated) | Yes | Media selection option.|
| option | [MediaSelectOption](#mediaselectoption) | Yes | Media selection option.|
**Return value**
**Return value**
...
@@ -1041,7 +1036,6 @@ async function example() {
...
@@ -1041,7 +1036,6 @@ async function example() {
Provides APIs for encapsulating file asset attributes.
Provides APIs for encapsulating file asset attributes.
> **NOTE**
> **NOTE**
>
> 1. The system attempts to parse the file content if the file is an audio or video file. The actual field values will be restored from the passed values during scanning on some devices.
> 1. The system attempts to parse the file content if the file is an audio or video file. The actual field values will be restored from the passed values during scanning on some devices.
> 2. Some devices may not support the modification of **orientation**. You are advised to use [ModifyImageProperty](js-apis-image.md#modifyimageproperty9) of the **image** module.
> 2. Some devices may not support the modification of **orientation**. You are advised to use [ModifyImageProperty](js-apis-image.md#modifyimageproperty9) of the **image** module.
@@ -2658,17 +2647,13 @@ Implements the media asset option.
...
@@ -2658,17 +2647,13 @@ Implements the media asset option.
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
| relativePath | string | Yes | Yes | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: 'Pictures/'<br> Default path of videos: 'Videos/'<br> Default path of audios: 'Audios/'<br> Default path of files: 'Documents/'|
| relativePath | string | Yes | Yes | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: 'Pictures/'<br> Default path of videos: 'Videos/'<br> Default path of audios: 'Audios/'<br> Default path of files: 'Documents/'|
| type | 'image' | 'video' | 'media' | Yes | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
| type | 'image' | 'video' | 'media' | Yes | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
| count | number | Yes | Yes | Number of media assets selected. The value starts from 1, which indicates that one media asset can be selected. |
| count | number | Yes | Yes | Maximum number of media assets that can be selected. The value starts from 1, which indicates that one media asset can be selected. |