SharpMobileCode / frame-video-view

Definetely less issues with VideoView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

frame-viedo-view

Do you have any display issues when using VideoView?
Read more in blog post I wrote.

How it works?

FrameVideoView solves flickering and black screen issues by showing placeholder in the proper time.
Placeholder is a simple View on top of the VideoView. Placeholder is visisble just after onPause is called and invisible when onResume is called.
It allows to hide VideoView during screen transitions which causes strange issues. If your device is running API level 14 or higher it will use TextureView to increase video playback performance, otherwise VideoView will be used.

How to use it?

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:$RELEASE_VERSION'
	}

Current $RELEASE_VERSION is

Step 3. Add view in xml:

<com.mklimek.frameviedoview.FrameVideoView
    android:id="@+id/frame_video_view"
    android:layout_width="@dimen/video_width"
    android:layout_height="@dimen/video_height"
  />

Step 4. Setup resource and FrameVideoViewListener:

frameVideoView = (FrameVideoView) findViewById(R.id.frameVideoView);
frameVideoView.setup(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.fb));
frameVideoView.setFrameVideoViewListener(new FrameVideoViewListener() {
      @Override
      public void mediaPlayerPrepared(final MediaPlayer mediaPlayer) {
          mediaPlayer.start();
      }
      
      @Override
      void mediaPlayerPrepareFailed( MediaPlayer mediaPlayer, String error ){
      }
});

you can call pause, resume, looping and other methods available in MediaPlayer.

See example for more details.

About

Definetely less issues with VideoView

License:Other


Languages

Language:Java 100.0%