From b9050a21c0bcb988ac90a1d0082ab03277e490da Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 29 Oct 2024 09:13:31 +0500 Subject: feat: controllable sfx and music --- core/src/kz/ilotterytea/maxon/audio/Playlist.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core/src/kz/ilotterytea/maxon/audio') diff --git a/core/src/kz/ilotterytea/maxon/audio/Playlist.kt b/core/src/kz/ilotterytea/maxon/audio/Playlist.kt index 10363a5..2e79f37 100644 --- a/core/src/kz/ilotterytea/maxon/audio/Playlist.kt +++ b/core/src/kz/ilotterytea/maxon/audio/Playlist.kt @@ -12,6 +12,11 @@ class Playlist(vararg musics: Music) { private var index = 0 var shuffleMode = false + var volume = 1f + set(value) { + playingNow.volume = value + field = value + } /** * Play next music. @@ -22,13 +27,14 @@ class Playlist(vararg musics: Music) { if (shuffleMode) { index = Math.getRandomNumber(0, playlist.size - 1) playingNow = playlist[index] - playingNow.play() } else { index++ if (index > playlist.size - 1) index = 0 playingNow = playlist[index] - playingNow.play() } + + playingNow.volume = volume + playingNow.play() } } \ No newline at end of file -- cgit v1.2.3