commit 10/04/2025
This commit is contained in:
@@ -3,6 +3,8 @@ package BASS;
|
||||
import lombok.Getter;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
import static Config.SomeCodes.Wait;
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class AudioPlayer {
|
||||
@@ -13,10 +15,7 @@ public class AudioPlayer {
|
||||
|
||||
public void WaitUntilFinished(){
|
||||
while(currentFileHandle!=0){
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
Wait(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +108,7 @@ public class AudioPlayer {
|
||||
if (bass.BASS_ChannelStart(filehandle)){
|
||||
currentFile = filename;
|
||||
currentFileHandle = filehandle;
|
||||
new Thread(()->{
|
||||
Thread pl = new Thread(() -> {
|
||||
if (playbackstatus!=null) playbackstatus.onPlaybackStarted(filename);
|
||||
boolean iscontinue = true;
|
||||
while(iscontinue){
|
||||
@@ -122,18 +121,17 @@ public class AudioPlayer {
|
||||
iscontinue = false;
|
||||
break;
|
||||
default : {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
iscontinue = false;
|
||||
}
|
||||
Wait(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (playbackstatus!=null) playbackstatus.onPlaybackFinished(filename);
|
||||
currentFile = "";
|
||||
currentFileHandle = 0;
|
||||
}).start();
|
||||
});
|
||||
pl.setDaemon(true);
|
||||
pl.start();
|
||||
|
||||
} else {
|
||||
Logger.error("AudioPlayer PlayFile failed, BASS_ChannelStart failed, error code: "+bass.BASS_ErrorGetCode());
|
||||
if (playbackstatus!=null) playbackstatus.onPlaybackFailure(filename);
|
||||
|
||||
Reference in New Issue
Block a user