vimeo video play in Android native

17,641

Solution 1

I made a native player for vimeo, base by WebView. Support public and private video.

Try it : https://github.com/ct7ct7ct7/Android-VimeoPlayer

<com.ct7ct7ct7.androidvimeoplayer.view.VimeoPlayerView
    android:id="@+id/vimeoPlayer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>



VimeoPlayerView vimeoPlayer = findViewById(R.id.vimeoPlayer);
getLifecycle().addObserver(vimeoPlayer);

//public video
vimeoPlayer.initialize(59777392);

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

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

Solution 2

Vimeo's embed codes should work inside an Android WebView. Vimeo only offers .mp4 links to PRO users on those users own videos.

Another option is to use the official Deep Link library for the android application. This will let you open any vimeo video in the Android app.

Solution 3

You can use Exoplayer to play vimeo Videos. Exoplayer is more customizable. All you need is to extract the url link from the video config link. You may use retrofit to extract the video url.

BASE_URL = "https://player.vimeo.com/video/"

You will need to use a get method like below:

@GET("{id}/{config}")
Call<JsonObject>getVideoLink(@Path("id") String id, @Path("config") String config);

You will get the id from video link. Example: "https://vimeo.com/123456789/" Here the id is: 123456789 .

 JsonObject jsonObject = response.body();
            JsonObject req = jsonObject.getAsJsonObject("request");
            JsonObject file = req.getAsJsonObject("files");
            JsonArray arr = file.getAsJsonArray("progressive");
            String url = arr.get(0).getAsJsonObject().get("url").getAsString();

           // Build the media item.
            MediaItem mediaItem = MediaItem.fromUri(url);
            // Set the media item to be played.
            player.setMediaItem(mediaItem);
            // Prepare the player.
            player.prepare();
            // Start the playback.
            player.play();

Don't forget to initiate Exoplayer first.

Share:
17,641

Related videos on Youtube

Rao's
Author by

Rao's

Updated on July 14, 2022

Comments

  • Rao's
    Rao's almost 2 years

    I am developing vimeo video app in native android. But it is not supported in VideoView. May I know any samples or related query for Android. I want final output to be in .mp3/.mp4 format.

    I have tried iframe in Android WebView, It works well in Android WebView but I am not able to get seek bar. And OnPause() not able to Pause the video. Here I am able to get Pause and Play button Only

    enter image description here

    Example: player.vimeo.com/video/49462103

    I want play this video in android native

     <VideoView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/videoView"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
    

    Update link in : Vimeo site Thread-1 Vimeo site Thread-2

    enter image description here

    I am getting above error

    • Bhavik Mehta
      Bhavik Mehta about 8 years
      can you please share your code of webview, i am unable to even embed the vimeo video player
  • Rao's
    Rao's about 8 years
    1. i have tried in webview but i am not getting access to seekbar bar to move forward or backword in mobile. you can see screeen shot above. Only pause and play is available 2. i am pro user but i am getting (player.vimeo.com/video/49462103) url from our server side. My question is how to authenticate this in android and i have to get .mp4 format to play in Android native Video view. Is there any Api to call this.
  • Rao's
    Rao's about 8 years
    As you mention *Vimeo only offers .mp4 links to PRO users on those users own videos. How to Access this.. can i get sample or example to get .Mp4 format in android. Currently i am getting 49462103 Number to play video.
  • Rao's
    Rao's about 8 years
    Finally i got one solution is this right way player.vimeo.com/video/123891946/config -- Get method. In response i will get .mp4 format
  • Dashron
    Dashron about 8 years
    That endpoint is not supported by Vimeo, and may break at any moment. The only supported method is through the Vimeo API, for PRO users to access their own videos. The video files are exposed via the api, in any video endpoint such as api.vimeo.com/me/videos
  • Rao's
    Rao's about 8 years
    I am getting this error when i call above api { "error": "You must provide a valid authenticated access token." }
  • Rao's
    Rao's about 8 years
    What is this?? Where i have to valid authenticated User
  • Rao's
    Rao's about 8 years
    I am not using Pro user account currently. But our client as taken Proaccount. If i Use Pro account user then i am getting Vaild Ouput???
  • Erum
    Erum almost 8 years
    @Rao's pls help me i am also getting same issue .... as i have used the link player.vimeo.com/video/69311033/config but how to play this link in android native ? so that i can get access of videos fullscreen button or fwd , back buttons ?
  • Rao's
    Rao's over 7 years
    @Erum u have to authenticate. ask server side people sent url. For them it easy to fetch and authenticate
  • Arnold Brown
    Arnold Brown about 6 years
    can anyone post a sample or clear tutorial to embed VIMEO video to android native application.!!! Thanks