Giter Club home page Giter Club logo

frame-video-view's Introduction

frame-viedo-view

Have you got any display issues using VideoView?
I had too. I wrote a blog post where you can find more details about these issues and how I solved them.

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(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.

frame-video-view's People

Contributors

mklimek avatar alouanemed avatar sharpmobilecode avatar m-kubis avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.