summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/audio
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-11-10 20:45:32 +0500
committerilotterytea <iltsu@alright.party>2024-11-10 20:45:32 +0500
commit0a29485586012ae00548997c262ea16f3820a823 (patch)
treec1abed64ee34a53e8e119219a6278a03733b0754 /core/src/kz/ilotterytea/maxon/audio
parentc5493df746e8f3915d86d8ebe85346dc1690ee4f (diff)
upd: kotlin has been a disaster for maxon source code
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/audio')
-rw-r--r--core/src/kz/ilotterytea/maxon/audio/Playlist.java57
-rw-r--r--core/src/kz/ilotterytea/maxon/audio/Playlist.kt40
2 files changed, 57 insertions, 40 deletions
diff --git a/core/src/kz/ilotterytea/maxon/audio/Playlist.java b/core/src/kz/ilotterytea/maxon/audio/Playlist.java
new file mode 100644
index 0000000..62e8d14
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/audio/Playlist.java
@@ -0,0 +1,57 @@
+package kz.ilotterytea.maxon.audio;
+
+import com.badlogic.gdx.audio.Music;
+import kz.ilotterytea.maxon.utils.math.Math;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class Playlist {
+ private List<Music> music;
+ private Music playingNow;
+ private int index;
+
+ private boolean shuffleMode;
+ private float volume;
+
+ public Playlist(Music... music) {
+ this.music = Arrays.asList(music);
+
+ this.playingNow = this.music.get(0);
+ this.index = 0;
+ this.shuffleMode = false;
+ this.volume = 1f;
+
+ this.playingNow.setVolume(this.volume);
+ }
+
+ public void next() {
+ if (playingNow.isPlaying()) playingNow.stop();
+
+ if (shuffleMode) {
+ index = Math.getRandomNumber(0, music.size() - 1);
+ playingNow = music.get(index);
+ } else {
+ index++;
+ if (index > music.size() - 1) index = 0;
+
+ playingNow = music.get(index);
+ }
+
+ playingNow.setVolume(volume);
+ playingNow.play();
+ }
+
+ public void setVolume(float volume) {
+ this.volume = volume;
+ playingNow.setVolume(volume);
+ }
+
+ public void setShuffleMode(boolean shuffleMode) {
+ this.shuffleMode = shuffleMode;
+ }
+
+ public Music getPlayingNow() {
+ return playingNow;
+ }
+}
diff --git a/core/src/kz/ilotterytea/maxon/audio/Playlist.kt b/core/src/kz/ilotterytea/maxon/audio/Playlist.kt
deleted file mode 100644
index 2e79f37..0000000
--- a/core/src/kz/ilotterytea/maxon/audio/Playlist.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-package kz.ilotterytea.maxon.audio
-
-import com.badlogic.gdx.audio.Music
-import kz.ilotterytea.maxon.utils.math.Math
-
-/**
- * Playlist.
- */
-class Playlist(vararg musics: Music) {
- private val playlist: Array<out Music> = musics
- var playingNow: Music = playlist[0]
- private var index = 0
-
- var shuffleMode = false
- var volume = 1f
- set(value) {
- playingNow.volume = value
- field = value
- }
-
- /**
- * Play next music.
- */
- fun next() {
- if (playingNow.isPlaying) playingNow.stop()
-
- if (shuffleMode) {
- index = Math.getRandomNumber(0, playlist.size - 1)
- playingNow = playlist[index]
- } else {
- index++
- if (index > playlist.size - 1) index = 0
-
- playingNow = playlist[index]
- }
-
- playingNow.volume = volume
- playingNow.play()
- }
-} \ No newline at end of file