Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.


Repository files navigation

Build Status Coverage Status License

Clappr for Android - Beta Version

Following events were changed to be compatible with clappr for WEB and iOS.

Name before 0.10.0 version New Name

Using the Player


Clappr is a Kotlin library. If your app is too, be sure Kotlin version is 1.3.50 or bigger, and Android Support version is 28.0.0 or bigger.

The minimal API level supported is 16 (4.1).

It is possible to incorporate clappr into your project in two ways:

Local Reference

After cloning Clappr project, add following lines to dependencies in project/build.gradle:

dependencies {
    implementation project(':clappr')
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.50"

Remote Reference

It is possible to reference any release from Clappr on JCenter. Add following lines to repositories sections in build.gradle:

buildscript {
    repositories {

allprojects {
    repositories {

Following, add following lines to dependencies section in project/build.gradle:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.50"
    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation ''

    implementation "io.clappr.player:clappr:0.12.0"

Clappr supports Java 8 resources, so it is necessary to add Java 8 compatibility in project/build.gradle.

android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8

For both local and remote reference, you can see how Sample app works.


Before instantiating a io.clappr.player.Player, it needs to be initialized with the Application context:

// Add to onCreate of the Application class


Player is a Fragment and must be embedded in a container view of the activity in order to start playing.

First define a container frame to player on layout:

        android:layout_height="@dimen/player_portrait_height" />

Following, instanciate a Player and attach it to container:

val player = Player()

val fragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.add(, player)


After instantiating, Player needs to be configured before it can be used to play any video.

🔴 Attention: Remember to always call the stop() method before calling the load() again

Event binding

Player implements the EventInterface interface for event binding. Client application associate any event to an object following the Callback interface.

The on or once Player methods can be used for binding. The only difference is that once bindings are only called a single time. These methods return a String id that can be used to cancel the binding with the off method.

The Player events are described by Event class and the data returned by EventData class.

For example, to listen the event when the video starts playing, and the event when the video ends successfully:

player.on(Event.PLAYING.value) {"App","Playing") }
player.on(Event.DID_COMPLETE.value) {"App", "Completed") }


Options class presents the main options (source and mime-type) followed by a hashmap of optional parameters. An Options is the only parameter to Player configure method. Player optional parameters are described by ClapprOption class.

val optionMap = hashMapOf(ClapprOption.START_AT.value to 50)

player.configure(Options(source = "", options = optionMap))

Error Handling

All errors are reported through the Event.Error event. This event includes an ErrorInfo in its Bundle.

player.on(Event.ERROR.value) { bundle: Bundle? ->
            bundle?.getParcelable<ErrorInfo>(Event.ERROR.value)?.let {
                Logger.error("App","Error: ${it.code} ${it.message}", (it.extras?.getSerializable(ErrorInfoData.EXCEPTION.value) as? Exception))

Generic error codes (UNKNOWN_ERROR and PLAYBACK_ERROR) are also provided in ErrorCode class:

The data returned by the errors are described on ErrorInfoData.



Application must handle all fullscreen transitions and behavior.

Player provides two events to indicate that the user has requested fullscreen transition:

player.on(Event.REQUEST_FULLSCREEN.value) { enterFullscreen() }
player.on(Event.EXIT_FULLSCREEN.value) { exitFullscreen() }