I was trying to follow the steps in the reference but media player is not showing in the activity. So, how can I get rid of this issue?
onCreate
Method:
In here I've tried to add MediaController
after getting the VideoView
id
mVideoView = findViewById(R.id.video_view);
if (savedInstanceState != null) {
mCurrentPosition = savedInstanceState.getInt(PLAYBACK_TIME);
}
MediaController mediaController = new MediaController(this);
mediaController.setMediaPlayer(mVideoView);
playing video:
(In here, a method for initializing video, Using corresponded Uri)
private void initializePlayer() {
Uri videoUri = getMedia(VIDEO_SAMPLE);
mVideoView.setVideoURI(videoUri);
if (mCurrentPosition > 0) {
mVideoView.seekTo(mCurrentPosition);
} else {
// Skipping to 1 shows the first frame of the video.
mVideoView.seekTo(1);
}
mVideoView.start();
}
private Uri getMedia(String mediaName) {
return Uri.parse("android.resource://" + getPackageName() +
"/raw/" + mediaName);
}