Better Video Player


2.0.0-alpha01 (Dec 6, 2018)
Sep 16, 2016
Jul 27, 2020
Halil Ozercan (halilozercan)
Aidan Follestad (afollestad)
Francisco Franco (franciscofranco)
Kelvin Bulwinkel (bulwinkel)
Halil Ozercan (halilozercan)
Márton Braun (zsmb13)
Source code
APK file

Show card

DEPRECATED - This project is deprecated. I suggest you to look for alternatives like ExoPlayer.

Better Video Player

  • Completely written in Kotlin.
  • Based on the stock MediaPlayer API It will work on all devices and all CPUs, and it works with both local and remote sources.
  • Simple Much less code is required than alternative options to get up and running.
  • Very configurable There are lots of options available to make the player behave exactly how you want it to behave.
  • Swipe Gestures Supports the common on-screen scroll behavior which is used by MXPlayer, VLC and other Android video players.
  • Tap Gestures Double tap on right or left side of the screen to jump back and forward like Youtube and Netflix players.

Add this in your module's build.gradle file:

dependencies {
    // ... other dependencies
    compile 'com.github.halilozercan:BetterVideoPlayer:kotlin-SNAPSHOT'

Getting Started

Configuring a Player Activity

You will need an Activity in your app that will hold the BetterVideoPlayer view and playback content. There's only a bit of configuration required. However, BetterVideoPlayer offers great 'customizability'.

Host Activity should disable recreation on orientation changes. This allows playback to continue when the device orientation changes. The player will adapt the aspect ratio accordingly. You just need to set android:configChanges values to your Activity in AndroidManifest.xml:

    android:configChanges="orientation|keyboardHidden|screenLayout|screenSize" /> 

The layout for your player Activity can be very simple. You only need a BetterVideoPlayer view, all the controls and everything else are created by the player itself.

    android:layout_height="match_parent" />

Notable Features

BetterVideoPlayer is capable of almost all functionality that you expect from a VideoPlayer. However, it is important to repeat that BetterVideoPlayer uses Android MediaPlayer API. Thus, it does not provide every codec in the world. In the future, there is a plan for moving underlying player to ExoPlayer.


BetterVideoPlayer supports captions in 2 formats; SRT and WEBVTT. Support for more formats through pull requests will be appreciated.

Captions can be obtained both online and from resource directory. BetterVideoPlayer currently does not support captions from local file storage.

// Online SUBRIP subtitle
bvp.setCaptions("", CaptionsView.SubMime.SUBRIP)

// res/raw SUBRIP subtitle
bvp.setCaptions(R.raw.sub, CaptionsView.SubMime.SUBRIP)

BetterVideoPlayer also lets you define the text size(in sp) and color of captions inside XML view.



BetterVideoPlayer deploys a common toolbar at the top of the player. Toolbar is useful in a video player in two different ways.

  • It offers a highly customizable Title area.
  • You can inflate a menu on the toolbar and define as many actions as you need.

To access toolbar, just use getToolbar() method. You can also show and hide the toolbar by using showToolbar() and hideToolbar(). Besides these methods, it is not recommended to alter Toolbar's visibility.

Swipe Gestures

Swipe Gestures on a video player are proved to be very useful by MX, VLC and others. Swiping left and right to seek to any point in video or swipe up and down to control volume and brightness. BetterVideoPlayer comes with built-in support for these gestures. This feature enables developers to have a player that their users are familiar with.

You can enable or disable gestures by enableSwipeGestures() and disableSwipeGestures() methods.

Important point: You need to use enableSwipeGestures(Window) method to also enable brightness control. Brightness setting needs a reference window.

Code Setup

Initializing the player is very simple. You just set a callback listener and a source.

class MyPlayerActivity : AppCompatActivity , BetterVideoCallback {

    lateinit var player: BetterVideoPlayer

    override fun onCreate(savedInstanceState: Bundle) {

        // Grab a reference to the player view
        player = findViewById(

        // Set the source to the HTTP URL held in the TEST_URL variable.
        // To play files, you can use Uri.fromFile(new File("..."))

        // From here, the player view will show a progress indicator until the player is prepared.
        // Once it's prepared, the progress indicator goes away and the controls become enabled for the user to begin playback.

    override fun onPause() {
        // Make sure the player stops playing if the user presses the home button.
    companion object {
        const val TEST_URL = ""

You can see the almost identical code in action in the sample project.