Android: Play sound or Mp3 file from Assets


Hi,

I spend lots of time to play sound in Android Application.
Basically I wanted to play a sound file from android Assets, rather than from SDCard!

it was a small code like this:

MediaPlayer m = new MediaPlayer();
   try{
	   AssetFileDescriptor descriptor = AmbeMaAartiActivity.this.getAssets().openFd("myfile.mp3");
	   m.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength() );
	   descriptor.close();
	   m.prepare();
	   m.start();
   } catch(Exception e){
	   // handle error here.. 
   }

Cheers!!