So, I gave up on this problem and did the work to load the mp3 files from the "res/raw" directory. Frustrating that mp3 files in assets folder don't seem to work right though.
Based on that, I have a couple small suggestions about the file:
MusicFactory.javaWhile converting to using "res/raw", I had a problem with createMusicFromResource() failing due to .prepare() being called on twice. Once in MediaPlayer.create() and once with mediaPlayer.prepare().
Using java Syntax Highlighting
public static Music createMusicFromResource(final MusicManager pMusicManager, final Context pContext, final int pMusicResID) throws IOException {
final MediaPlayer mediaPlayer = MediaPlayer.create(pContext, pMusicResID);
//comment out this---------------------------------
//http://groups.google.com/group/android-developers/browse_thread/thread/260f2951d4a23445?fwc=1
//mediaPlayer.prepare();
//comment out this---------------------------------
final Music music = new Music(pMusicManager, mediaPlayer);
pMusicManager.add(music);
return music;
}
Parsed in 0.032 seconds, using
GeSHi 1.0.8.4
One other thing -- in createMusicFromAsset(), I'm not sure if assetFileDescriptor.close() should be explicitly called?
Using java Syntax Highlighting
public static Music createMusicFromAsset(final MusicManager pMusicManager, final Context pContext, final String pAssetPath) throws IOException {
final MediaPlayer mediaPlayer = new MediaPlayer();
final AssetFileDescriptor assetFileDescritor = pContext.getAssets().openFd(MusicFactory.sAssetBasePath + pAssetPath);
mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), assetFileDescritor.getStartOffset(), assetFileDescritor.getLength());
//add this ? ---------------------------------------
//close the descriptor
assetFileDescritor.close();
//add this ? ---------------------------------------
mediaPlayer.prepare();
final Music music = new Music(pMusicManager, mediaPlayer);
pMusicManager.add(music);
return music;
}
Parsed in 0.032 seconds, using
GeSHi 1.0.8.4