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;
        }
    }

}