I'd like to play a video file in the assets
directory in the MediaPlayer class on Android. What should I do?
setDataSource
with FileDescriptor
to play.
mMediaPlayer=newMediaPlayer();
AssetFileDescriptor fd=getAsset().openFd("video.mp4");
mMediaPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.start();
© 2024 OneMinuteCode. All rights reserved.