Giter Site home page Giter Site logo

mina-mikhail / android-vimeoplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ct7ct7ct7/android-vimeoplayer

0.0 1.0 0.0 38.31 MB

Unofficial Vimeo video player library for Android.

Home Page: https://ct7ct7ct7.github.io/Android-VimeoPlayer

License: MIT License

Java 91.65% HTML 8.35%

android-vimeoplayer's Introduction

Android-VimeoPlayer

Unofficial Vimeo video player library for Android.

Inspired by android-youtube-player.

website

screenshot

Gradle

dependencies {
    implementation 'com.ct7ct7ct7.androidvimeoplayer:library:{latest version}'
}

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/vimeoPlayer"
            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(vimeoPlayer)
vimeoPlayer.initialize(true, 59777392)

//If video is open. but limit playing at embedded.
vimeoPlayer.initialize(true, {YourPrivateVideoId}, "SettingsEmbeddedUrl")

//If video is pirvate.
vimeoPlayer.initialize(true, {YourPrivateVideoId},"VideoHashKey", "SettingsEmbeddedUrl")


Properties

  • app:topicColor (default : 00adef) Specify the color of the video controls.
  • app:backgroundColor (default : 000000) Specify the color of the video background.
  • app:autoPlay (default : false) Automatically start playback of the video.
  • app:loop (default : false) Play the video again when it reaches the end.
  • app:muted (default : false) Mute this video on load.
  • app:showTitle (default : true) Show the title on the video.
  • app:showOriginalControls (default : false) Show vimeo js original controls.
  • app:showFullscreenOption (default : false) Show the fullscreen button on the native controls.
  • app:showMenuOption (default : false) Show the menu button on the native controls.
  • app:aspectRatio (default : 1.777..) Assign aspect ratio. default is 16/9.
  • app:quality (default : "auto") Vimeo Plus, PRO, and Business members can set this config. Possible values:Auto, 4K, 2K, 1080p, 720p, 540p, 360p

Menu options

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

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

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

Fullscreen options

//show the fullscreen option
vimeoPlayer.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, vimeoPlayer), 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)
        vimeoPlayer.seekTo(playAt)

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

Methods

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

Listeners

  • VimeoPlayerReadyListener
  • VimeoPlayerStateListener
  • VimeoPlayerTimeListener
  • VimeoPlayerTextTrackListener
  • VimeoPlayerVolumeListener
  • VimeoPlayerErrorListener
vimeoPlayer.addReadyListener(object : VimeoPlayerReadyListener {
    override fun onReady(title: String?, duration: Float, textTrackArray: Array<TextTrack>) {
        //TODO
    }

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

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

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

android-vimeoplayer's People

Contributors

ct7ct7ct7 avatar sokarcreative avatar

Watchers

 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.