Clone or download
Latest commit 93d9046 Oct 4, 2018

README.md

logo

Download Build Status Codacy Badge

FullscreenVideoView is a custom VideoView Android library which makes loading, setting up and going fullscreen for video views easy.

Download

You can use Gradle:

compile 'bg.devlabs.fullscreenvideoview:library:1.0.0'

or Maven:

<dependency>
  <groupId>bg.devlabs.fullscreenvideoview</groupId>
  <artifactId>library</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

How to use FullscreenVideoView?

Declare the FullscreenVideoView in the XML layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <bg.devlabs.fullscreenvideoview.FullscreenVideoView
        android:id="@+id/fullscreenVideoView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

The Activity where the FullscreenVideoView is declared should handle configuration changes, which imposes this change in the AndroidManifest.xml file

<activity
    android:name="your_activity_name"
    android:configChanges="orientation|screenSize" />

Basic video loading (from URL or from a file)

// Loading from URL
override fun onCreate(savedInstanceState: Bundle?) {
	...
	val fullscreenVideoView = findViewById(R.id.fullscreenVideoView)
	val videoUrl = "https://clips.vorwaerts-gmbh.de/VfE_html5.mp4"
	fullscreenVideoView.videoUrl(videoUrl)
}

// Loading from file
override fun onCreate(savedInstanceState: Bundle?) {
	...
	val fullscreenVideoView = findViewById(R.id.fullscreenVideoView)
	val videoFile = new File("file_path")
	fullscreenVideoView.videoFile(videoFile)
}

Change controls drawable resources

Java or Kotlin

fullscreenVideoView.videoUrl(videoUrl)
        .playDrawable(R.drawable.ic_play)
        .pauseDrawable(R.drawable.ic_pause)
        .fastForwardDrawable(R.drawable.ic_fast_forward)
        .rewindDrawable(R.drawable.ic_rewind)
        .enterFullscreenDrawable(R.drawable.ic_fullscreen)
        .exitFullscreenDrawable(R.drawable.ic_fullscreen_exit)

XML

<bg.devlabs.fullscreenvideoview.FullscreenVideoView
        android:id="@+id/fullscreenVideoView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:play_drawable="@drawable/ic_play"
        app:pause_drawable="@drawable/ic_pause"
        app:ffwd_drawable="@drawable/ic_fast_forward"
        app:rew_drawable="@drawable/ic_rewind"
        app:enter_fullscreen_drawable="@drawable/ic_fullscreen"
        app:exit_fullscreen_drawable="@drawable/ic_fullscreen_exit"/>

Enable/disable controls

fullscreenVideoView.videoUrl(videoUrl)
        .disablePause()
        .addSeekBackwardButton()
        .addSeekForwardButton()

Enable video auto-start

fullscreenVideoView.videoUrl(videoUrl)
        .enableAutoStart()

Customize fast-forward and/or rewind seconds

fullscreenVideoView.videoUrl(videoUrl)
        .fastForwardSeconds(5)
        .rewindSeconds(5)

Change the playback speed (only for API 23 and above)

There are 7 playback speed values which are added by default, but they can be changed with custom ones when playbackSpeedOptions is used.

val playbackOptions = PlaybackSpeedOptions().addSpeeds(0.25f, 0.5f, 0.75f, 1f)

fullscreenVideoView.videoUrl(videoUrl)
        .addPlaybackSpeedButton()
        .playbackSpeedOptions(playbackOptions)

Compatibility

  • Minimum Android SDK: API level 19
  • Compile Android SDK: API level 28

Known issues

There is a memory leak in Android 7 (API levels 24 and 25), which is known and listed in the LeakCanary repository issues.

License

Apache 2.0. See the LICENSE file for details.