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/mp4AssetFileDescriptor 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 SurfaceViewmediaPlayer.setDisplay(surfaceHolder);mediaPlayer.prepare();mediaPlayer.start();
Comments
Post a Comment