Un peu de ménage dans le git
This commit is contained in:
23
src/fr/monkhanny/dorfromantik/utils/SoundLoader.java
Normal file
23
src/fr/monkhanny/dorfromantik/utils/SoundLoader.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package fr.monkhanny.dorfromantik.utils;
|
||||
|
||||
import javax.sound.sampled.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SoundLoader {
|
||||
|
||||
public static Clip loadMusic(String filePath) {
|
||||
try {
|
||||
File soundFile = new File(filePath);
|
||||
AudioInputStream audioStream = AudioSystem.getAudioInputStream(soundFile);
|
||||
Clip clip = AudioSystem.getClip();
|
||||
clip.open(audioStream);
|
||||
return clip;
|
||||
} catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Failed to load sound at path: " + filePath);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user