javajlayer

JLayer exception when trying to play audio file


I've been testing a Java library that works in both PC and Android platforms, a few time ago someone here told me to use JLayer. Today I was happily coding and then this exception showed up:

java.lang.ExceptionInInitializerError
at javazoom.jl.decoder.SynthesisFilter.load_d(Unknown Source)
at javazoom.jl.decoder.SynthesisFilter.<init>(Unknown Source)
at javazoom.jl.decoder.Decoder.initialize(Unknown Source)
at javazoom.jl.decoder.Decoder.decodeFrame(Unknown Source)
at javazoom.jl.player.Player.decodeFrame(Unknown Source)
at javazoom.jl.player.Player.play(Unknown Source)
at javazoom.jl.player.Player.play(Unknown Source)
at Main.Play(Main.java:23)
at Main.main(Main.java:164)
Caused by: java.io.IOException: unable to load resource 'sfd.ser'
at javazoom.jl.decoder.JavaLayerUtils.deserializeArrayResource(Unknown Source)
... 9 more

I've tried to google the cause for this exception with no results, so I come here begging for your help.

This is the function where I'm trying to play the audio file:

public static void Play()
{
    try
    {
        InputStream fis = new FileInputStream("L://POO//MyWS//WakeUp!//Back in black.mp3");
        Player p = new Player(fis);

        p.play();

    }
    catch(FileNotFoundException e)
    {
        e.printStackTrace();
    }
    catch (JavaLayerException e)
    {
        e.printStackTrace();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    catch(ExceptionInInitializerError e)
    {
        e.printStackTrace();
    }
}

Thank you in advance! :D


Solution

  • Finally I'm using JLayer 1.0 and it works like a charm, you can get it from here. This is a sample code I found here.

    EDIT: in Eclipse, if the error keeps showing up, change your workspace to a new one.