Hi All,
I have been struggling with playing a WAV file "music.wav" under
"assets" folder of my APK file. The WAV file has been proven good by
using Android SDK's media sample code.
I tried the following methods, all of them generates
"java.io.IOException: Prepare failed.: status=0xFFFFFFFC".
Method 1 - mediaplayer.setDataSource("file:///android_asset/
music.wav");
Method 2 - mediaplayer.setDataSource(myActivity.getAssets().openFd
("music.wav").getFileDescriptor());
Method3 - First, write a temporary wav file under "data/data/myAppName/
files/" by opening an InputStream / OutputStream with AssetManager,
then use mediaplayer.setDataSource("data/data/myAppName/files/
music.wav"); From Adroid file explorer I can even see that the
temporary wav file is created successfully, but prepare() still
generates IOException.
The only way I can play this wav file is I manually push this wav file
onto the emulator, say "data/data/myApp", then I use a hard-coded
string to call setDataSource(), but sadly we can not use a hard-coded
string to play sound effect.
Can anyone help me out to play sound files (wav, mp3) under APK
"assets" folder? Or is there a way to set the data source by an
InputStream directly?
Many thanks for any suggestions!
Hongkun
www.omnigsoft.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---