Closed AlphaDev-Fr closed 8 years ago
Aside from including your audio files as assets instead of classpath files, I'm not sure there is a better way given the limitations of the MediaPlayer.
This is unfixable using Android's APIs. Putting your assets into classpath is also bad, as that prevents storage on external storage
Hello, I put some of my music and sound in my classpath and i need to play them in a android phone.
But i notice the methode
com.badlogic.gdx.backends.android.AndroidAudio.newMusic(FileHandle)
build the player with :mediaPlayer.setDataSource(aHandle.file().getPath());
which is not working for file in classpath. I have this error :So i try with
URL input = FileHandle.class.getResource("/" + aHandle.file().getPath().replace('\\', '/'));
mediaPlayer.setDataSource(context, Uri.parse(input.toURI().toString()));
but it does not working i have this error :Finally i make this crappy code :
I build a cache file with file in classpath and i intialise the datesource of the mediaplayer with a fileDescriptor. I must use the fileDescriptor because the file is not readable by the mediaplayer see this.
I have the same issue for the sound and i fix it same way.
Sorry for my bad english it isn't my native language.
Thank the reading and i hope you solve this issue with a better solution than i found.