The **ringtonePlayer** module provides APIs for playing, configuring, and obtaining system ringtones.
This module must work with [@ohos.multimedia.systemSoundManager](js-apis-systemSoundManager.md) to manage system ringtones.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
| volume | number | Yes | Relative volume. The value ranges from 0.00 to 1.00. The value **1.00** indicates the maximum volume (100%).|
| loop | boolean | Yes | Whether to enable loop playback. The value **true** means to enable loop playback, and **false** means the opposite.|
## RingtonePlayer
Provides APIs for setting and obtaining system ringtone parameters as well as playing and stopping system ringtones. Before calling any API in **RingtonePlayer**, you must use [getSystemRingtonePlayer](js-apis-systemSoundManager.md#getsystemringtoneplayer) to create a **RingtonePlayer** instance.
| callback | AsyncCallback<[audio.AudioRendererInfo](js-apis-audio.md#audiorendererinfo8)> | Yes| Callback used to return the audio renderer information obtained.|
| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio rendering is interrupted.|
| callback | Callback<[audio.InterruptEvent](js-apis-audio.md#interruptevent9)> | Yes | Callback used to return the audio interruption event. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
// The system forcibly interrupts audio rendering. The application must update the status and displayed content accordingly.
switch(interruptEvent.hintType){
caseaudio.InterruptHint.INTERRUPT_HINT_PAUSE:
// The audio stream has been paused and temporarily loses the focus. It will receive the interruptEvent corresponding to resume when it is able to regain the focus.
console.info('Force paused. Update playing status and stop writing');
isPlaying=false;// A simplified processing indicating several operations for switching the application to the paused state.
break;
caseaudio.InterruptHint.INTERRUPT_HINT_STOP:
// The audio stream has been stopped and permanently loses the focus. The user must manually trigger the operation to resume rendering.
console.info('Force stopped. Update playing status and stop writing');
isPlaying=false;// A simplified processing indicating several operations for switching the application to the paused state.
break;
caseaudio.InterruptHint.INTERRUPT_HINT_DUCK:
// The audio stream is rendered at a reduced volume.
// The application can choose to take action or ignore.
switch(interruptEvent.hintType){
caseaudio.InterruptHint.INTERRUPT_HINT_RESUME:
// It is recommended that the application continue rendering. (The audio stream has been forcibly paused and temporarily lost the focus. It can resume rendering now.)
console.info('Resume force paused renderer or ignore');
// To continue rendering, the application must perform the required operations.
The **systemSoundManager** module provides basic capabilities for managing system sounds, including setting and obtaining system ringtones and obtaining a player to play the system ringtone.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
Provides APIs to manage system sounds. Before calling any API in **SystemSoundManager**, you must use [getSystemSoundManager](#systemsoundmanagergetsystemsoundmanager) to create a **SystemSoundManager** instance.
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone.|
| callback | AsyncCallback<[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer.md#ringtoneplayer)> | Yes| Callback used to return the ringtone player obtained.|