mirror of
https://github.com/anas-elgarhy/Ayah-intellij.git
synced 2024-08-15 00:43:43 +00:00
😆 Fix sound level 🔊
This commit is contained in:
parent
6abefb4682
commit
c37c282aa2
2 changed files with 4 additions and 7 deletions
|
@ -15,7 +15,6 @@ dependencies {
|
|||
implementation("com.github.anas-elgarhy:alquran-cloud-api:0.4.0-v1")
|
||||
implementation("com.miglayout:miglayout-swing:11.0")
|
||||
implementation("com.github.goxr3plus:java-stream-player:10.0.2")
|
||||
implementation("com.googlecode.soundlibs:jlayer:1.0.1.4")
|
||||
}
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
|
|
|
@ -17,12 +17,13 @@ import java.util.logging.Logger;
|
|||
public class AudioPlayer {
|
||||
private final StreamPlayer streamPlayer;
|
||||
private final String audioUrl;
|
||||
private final float volume;
|
||||
private static final Logger LOGGER = Logger.getLogger(AudioPlayer.class.getName());
|
||||
|
||||
public AudioPlayer(final int volume, final String audioUrl) {
|
||||
streamPlayer = new StreamPlayer();
|
||||
this.audioUrl = audioUrl;
|
||||
streamPlayer.setGain(volume / 100.0);
|
||||
this.volume = volume / 100f;
|
||||
}
|
||||
|
||||
private void loadAndOpen() {
|
||||
|
@ -45,6 +46,8 @@ public class AudioPlayer {
|
|||
LOGGER.severe(e.getMessage());
|
||||
}
|
||||
}).start();
|
||||
streamPlayer.setGain(volume);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,9 +56,4 @@ public class AudioPlayer {
|
|||
final var inputStream = url.openStream();
|
||||
return new BufferedInputStream(inputStream);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
loadAndOpen();
|
||||
play();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue