Skip to the content.

Android-VimeoPlayer

Unofficial Vimeo video player library for Android.

Inspired by android-youtube-player.

website

screenshot

Gradle

AndroidX
repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.ct7ct7ct7.androidvimeoplayer:library:2.2'
}


android.useAndroidX=true
android.enableJetifier=true
Android Support Library
dependencies {
    implementation 'com.ct7ct7ct7.androidvimeoplayer:library:1.2.2'
}

Usage

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    
        <com.ct7ct7ct7.androidvimeoplayer.view.VimeoPlayerView
            android:id="@+id/vimeoPlayerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:autoPlay="false"
            app:loop="false"
            app:muted="false"
            app:showFullscreenOption="false"
            app:showMenuOption="false"
            app:showOriginalControls="false"
            app:showTitle="true"
            app:topicColor="#FFFF00"
            app:aspectRatio="1.778"
            app:backgroundColor="#00FFFF"
            />
</LinearLayout>
lifecycle.addObserver(vimeoPlayerView)
vimeoPlayerView.initialize(true, 59777392)

// video background settings is OPEN and limit playing at embedded.
vimeoPlayerView.initialize(true, {YourPrivateVideoId}, "SettingsEmbeddedUrl")

//video background settings is PRIVATE.
vimeoPlayerView.initialize(true, {YourPrivateVideoId},"VideoHashKey", "SettingsEmbeddedUrl")


Properties

//show the menu option
vimeoPlayerView.setMenuVisibility(true)

//add item
vimeoPlayerView.addMenuItem(ViemoMenuItem("Item 1",R.drawable.icon, View.OnClickListener {
    //TODO
    vimeoPlayerView.dismissMenuItem()
}))

//override menu click listener
vimeoPlayerView.setMenuClickListener { 
    //TODO
}

Fullscreen options

//show the fullscreen option
vimeoPlayerView.setFullscreenVisibility(true)



var REQUEST_CODE = 1234
.
.
.
//go to fullscreen page
vimeoPlayer.setFullscreenClickListener {

    //define the orientation
    var requestOrientation = VimeoPlayerActivity.REQUEST_ORIENTATION_AUTO
    
    startActivityForResult(VimeoPlayerActivity.createIntent(this, requestOrientation, vimeoPlayerView), REQUEST_CODE)
}
.
.
.
//handle return behavior
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
        var playAt = data!!.getFloatExtra(VimeoPlayerActivity.RESULT_STATE_VIDEO_PLAY_AT, 0f)
        vimeoPlayerView.seekTo(playAt)

        var playerState = PlayerState.valueOf(data!!.getStringExtra(VimeoPlayerActivity.RESULT_STATE_PLAYER_STATE))
        when (playerState) {
            PlayerState.PLAYING -> vimeoPlayerView.play()
            PlayerState.PAUSED -> vimeoPlayerView.pause()
        }
    }
}

Methods

val videoId: Int = vimeoPlayerView.videoId
val baseUrl: String? = vimeoPlayerView.baseUrl
val hashKey: String? = vimeoPlayerView.hashKey
val playerState: PlayerState = vimeoPlayerView.playerState
val currentTime: Float = vimeoPlayerView.currentTimeSeconds
vimeoPlayerView.setCaptions("en") //only supported original controls.
vimeoPlayerView.disableCaptions() //only supported original controls.
vimeoPlayerView.seekTo(0.0f)
vimeoPlayerView.loop = true
vimeoPlayerView.topicColor = Color.RED
vimeoPlayerView.setVolume(0.5f)
vimeoPlayerView.setPlaybackRate(0.5f)
vimeoPlayerView.play()
vimeoPlayerView.pause()
vimeoPlayerView.loadVideo(19231868)
vimeoPlayerView.recycle()
vimeoPlayerView.clearCache()

Listeners

vimeoPlayerView.addReadyListener(object : VimeoPlayerReadyListener {
    override fun onReady(title: String?, duration: Float, textTrackArray: Array<TextTrack>) {
        //TODO
    }

    override fun onInitFailed() {
        //TODO
    }
})
vimeoPlayerView.addStateListener(object : VimeoPlayerStateListener {
    override fun onPlaying(duration: Float) {
        //TODO
    }

    override fun onPaused(seconds: Float) {
        //TODO
    }

    override fun onEnded(duration: Float) {
        //TODO
    }
})
vimeoPlayerView.addTimeListener { second: Float ->
    //TODO
}
vimeoPlayerView.addTextTrackListener { kind: String, label: String, language: String ->
    //TODO
}
vimeoPlayerView.addVolumeListener { volume: Float ->
    //TODO
}
vimeoPlayerView.addErrorListener { message: String, method: String, name: String ->
    //TODO
}