No more issues with VideoView.
Read more:
"How to avoid flickering and black screen issues when using VideoView?"
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.mklimek:frame-video-view:1.2.0'
}
See example for more details.
FrameVideoView solved flickering and black screen issues by showing placeholder in proper time.
If your device is running API level 14 or higher it will use TextureView to increase video playback performance, otherwise VideoView will be used.
Call setFrameVideoViewListener
method to get instance of MediaPlayer
by call:
frameVideoView.setFrameVideoViewListener(new FrameVideoViewListener() {
@Override
public void mediaPlayerPrepared(final MediaPlayer mediaPlayer) {
MainActivity.this.mediaPlayer = mediaPlayer;
}
});
after that you can call pause, resume, looping and other methods available in MediaPlayer
.