Saturday, August 13, 2011

Android - Read Multimedia File from Assets folder

To read a multimedia file from assets folder via MediaPlayer, you could use the following code

AssetManager am = getAssets();
//Imagine you have a folder assets/mp4
AssetFileDescriptor afd = am.openFd("mp4/test.mp4")
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
//I am assuming that you have knowledge in getting a surfaceHolder from SurfaceView
mediaPlayer.setDisplay(surfaceHolder);
mediaPlayer.prepare();
mediaPlayer.start();

No comments:

Post a Comment

Tomcat - removing server info

Below are the steps to remove Tomcat Server Information 1. Make sure Tomcat is not running 2. Navigate to "Tomcat Installation"...