Service managing audio playback for the application.
More...
|
| synchronized boolean | isMuted () |
| | Checks if audio is currently muted.
|
| |
| synchronized void | muteAll () |
| | Mutes all audio (song and effects).
|
| |
| synchronized void | playEffect (@Nullable File effectFile, String key) |
| | Plays a short sound effect.
|
| |
| synchronized void | playSong (@Nullable File songFile) |
| | Plays a song in a loop.
|
| |
| synchronized void | setEffectVolume (String key, double volume) |
| | Sets the volume for a specific effect (when not muted).
|
| |
| synchronized void | setMuted (boolean isMuted) |
| | Sets the muted state.
|
| |
| synchronized void | setSongVolume (double volume) |
| | Sets the volume for the song (when not muted).
|
| |
| synchronized void | stopAll () |
| | Stops and disposes all audio resources.
|
| |
| synchronized void | stopSong () |
| | Stops and disposes the song player.
|
| |
| synchronized void | unmuteAll () |
| | Unmutes all audio and restores original volumes.
|
| |
|
| static final Logger | LOG = LoggerFactory.getLogger(AudioService.class) |
| |
| static final Set< String > | VALID_EFFECT_KEYS = Set.of("button_click", "case_click") |
| |
Service managing audio playback for the application.
Supports song and short sound effects, with automatic disposal of MediaPlayer instances to prevent memory leaks.
◆ isMuted()
| synchronized boolean fr.softsf.sudokufx.service.ui.AudioService.isMuted |
( |
| ) |
|
Checks if audio is currently muted.
- Returns
- true if all audio is muted
◆ muteAll()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.muteAll |
( |
| ) |
|
Mutes all audio (song and effects).
◆ playEffect()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.playEffect |
( |
@Nullable File | effectFile, |
|
|
String | key ) |
Plays a short sound effect.
Reuses an existing MediaPlayer for the given key if present. Automatically disposes the MediaPlayer after playback.
- Parameters
-
| effectFile | the sound effect file |
| key | a unique identifier for the effect |
- Exceptions
-
| IllegalArgumentException | if effectFile is null |
| IllegalArgumentException | if key is null, empty, or blank |
| IllegalArgumentException | if key is not in the valid effect keys set |
| IllegalArgumentException | if the file URI is invalid |
| RuntimeException | if the media file cannot be loaded or played |
◆ playSong()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.playSong |
( |
@Nullable File | songFile | ) |
|
Plays a song in a loop.
Stops and disposes any existing song player.
- Parameters
-
| songFile | the song audio file |
- Exceptions
-
| IllegalArgumentException | if songFile is null |
| IllegalArgumentException | if the file URI is invalid |
| RuntimeException | if the media file cannot be loaded or played |
◆ setEffectVolume()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.setEffectVolume |
( |
String | key, |
|
|
double | volume ) |
Sets the volume for a specific effect (when not muted).
- Parameters
-
| key | the effect key |
| volume | volume level (0.0 to 1.0) |
- Exceptions
-
| IllegalArgumentException | if key is null, empty, or blank |
| IllegalArgumentException | if key is not in the valid effect keys set |
◆ setMuted()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.setMuted |
( |
boolean | isMuted | ) |
|
Sets the muted state.
Used for initialization from database.
- Parameters
-
| isMuted | true to mute all audio, false to unmute |
◆ setSongVolume()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.setSongVolume |
( |
double | volume | ) |
|
Sets the volume for the song (when not muted).
- Parameters
-
| volume | volume level (0.0 to 1.0) |
◆ stopAll()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.stopAll |
( |
| ) |
|
Stops and disposes all audio resources.
◆ stopSong()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.stopSong |
( |
| ) |
|
Stops and disposes the song player.
◆ unmuteAll()
| synchronized void fr.softsf.sudokufx.service.ui.AudioService.unmuteAll |
( |
| ) |
|
Unmutes all audio and restores original volumes.
◆ effectsPlayers
| final Map<String, MediaPlayer>
fr.softsf.sudokufx.service.ui.AudioService.effectsPlayers = new HashMap<>() |
|
private |
◆ isMuted
| boolean fr.softsf.sudokufx.service.ui.AudioService.isMuted = false |
|
private |
◆ LOG
| final Logger fr.softsf.sudokufx.service.ui.AudioService.LOG =
LoggerFactory.getLogger(AudioService.class) |
|
staticprivate |
◆ originalEffectVolumes
| final Map<String, Double>
fr.softsf.sudokufx.service.ui.AudioService.originalEffectVolumes = new HashMap<>() |
|
private |
◆ originalSongVolume
| double fr.softsf.sudokufx.service.ui.AudioService.originalSongVolume = 1.0 |
|
private |
◆ songPlayer
| MediaPlayer fr.softsf.sudokufx.service.ui.AudioService.songPlayer |
|
private |
◆ VALID_EFFECT_KEYS
| final Set<String> fr.softsf.sudokufx.service.ui.AudioService.VALID_EFFECT_KEYS =
Set.of("button_click", "case_click") |
|
staticprivate |
The documentation for this class was generated from the following file: