- code cleanup

- Verbeteringen in stoppen van audio
-- Simpelere afhandeling
-- Thread stopt wanneer (clip != null) ipv .stop()
This commit is contained in:
Bilel Bghiel
2015-06-19 19:40:35 +02:00
parent c019fdeea3
commit b86ce91755
11 changed files with 77 additions and 135 deletions
+4 -7
View File
@@ -35,17 +35,15 @@ public class AudioPlayer{
} catch (JavaLayerException | FileNotFoundException e1) {
e1.printStackTrace();
}
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if(clip != null){
Thread thread = new Thread(() -> {
while (clip != null){
try {
clip.play();
} catch (JavaLayerException e) {
e.printStackTrace();
}
}
}});
});
thread.start();
}
@@ -54,14 +52,13 @@ public class AudioPlayer{
{
clip.close();
clip = null;
try {
if(fis != null)
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
if(thread != null && thread.isAlive())
thread.stop();
}
}