Hey,
I’m trying, once again, to do something that requires me to use a file within the jar; and as usual I can’t get my code to find the file.
I’ve tried all of the (modifiers?) such as internal, absolute, classpath, etc… along with a few variations of the path such as “res/audio/tavern.ogg”, “/audio/tavern.ogg”, “tavern.ogg”, etc…
After all of those attempts failed I tried giving the exact path to the audio file would work but it didn’t.
Now I’m back here again to find out how to get my code working.
The method that’s messing up is below, the line that messed up is the first statement:
public static void newMusic(String path, boolean loop)
{
music = Gdx.audio.newMusic(Gdx.files.internal(path));
music.setVolume(1.0f); //Sets volume to 100%
music.setLooping(loop);
}
The statement that uses the newMusic method is:
Audio.newMusic("/audio/tavern.ogg", true);
My folder structure is…
[tr][td]bin[/td][td]res[/td][td]src[/td][/tr]
…within the res folder it looks like…
[tr][td]audio[/td][td]levels[/td][td]textures[/td][/tr]
…and within the audio folder is “tavern.ogg”. So to get to tavern.ogg you would do “/res/audio/tavern.ogg”.