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();

Comments

Popular posts from this blog

FFMPEG - Creating timelapse with FFMPEG with JPEG

MP4 File Format Part 1

RTSP - RTP over TCP