Skip to content

dwrstc/FrameVideoView

 
 

Repository files navigation

FrameVideoView

VideoView is the most straightforward way to show video content in layout.
It took a few lines of code to setup and show for example mp4 file.
It's fine when you don't care about UX too much, but when you do, things are going to be annoying.

Read more:
"How to avoid flickering and black screen issues when using VideoView?"

FrameVideoView will solve issues with VideoView.

How to use it?

Add FrameVideoView to layout:

  <mateuszklimek.framevideoview.FrameVideoView
    android:id="@+id/frame_video_view"
    android:layout_width="@dimen/video_width"
    android:layout_height="@dimen/video_height"
  />

find its instance in Activity and call corresponding methods in onResume and onPause:

public class SampleActivity extends Activity {

  private FrameVideoView videoView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple);

    String uriString = "android.resource://" + getPackageName() + "/" + R.raw.movie;
    videoView = (FrameVideoView) findViewById(R.id.frame_video_view);
    videoView.setup(Uri.parse(uriString), Color.GREEN);
  }

    @Override
    protected void onResume() {
      super.onResume();
      videoView.onResume();
    }

    @Override
    protected void onPause() {
      videoView.onPause();
      super.onPause();
    }
  }

If you want to execute method for particular implementation eg. seekTo() from VideoView, you can call it like that:

frameVideoView.asVideoView().seekTo(x);

but before, it's better to check what type of implementation is used:

if(videoView.getImplType() == TEXTURE_VIEW){
    frameVideoView.asVideoView().seekTo(x);
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%