The problem
I'm having difficulty loading a song for a little android game practice I'm trying to create. All the graphics and rendering works perfectly, and downloading that to my android tablet works great and displays great. However, when I try to add some background music, the app freezes with a black screen when it attempts to start, and then simply closes with a, "Unfortunately, appname has stopped" dialog error.
I have tried..
So far I have tried almost every way of loading resources. I have used:
Attempt 1
public class MyGame extends ApplicationAdapter {
Music song;
...
@Override
public void create() {
song = Gdx.audio.newMusic(Gdx.files.internal("song.mp3"));
song.play();
...
}
}
Attempt 2
public class Audio {
Music song;
public Audio() {
song = Gdx.audio.newMusic(Gdx.files.internal("song.mp3"));
song.play();
}
}
public class MyGame extends ApplicationAdapter {
Audio Song; //Custom Class
...
@Override
public void create() {
song = new Audio()
}
}
Attempt 3
public class MyGame extends ApplicationAdapter {
AssetManager manager;
...
@override
public void create() {
manager = new AssetManager();
manager.load("song.mp3", Music.class);
...
manager.finishLoading();
Music song = manager.get("snd/Of the Airship Academy.mp3", Music.class);
song.play();
}
}
All of these work perfectly when running the desktop version, but when downloading to my android device, the app fails and stops.
Other things of note:
- I am trying to load a song that is a little more than 3MB.
- I tried having the song in the
assets
folder, as well as in aassets/snd
folder - Is it possible to get a live debugger for debugging on android, or see some sort of traceback for any possible errors?
Thanks