12

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

Alfie Hanssen
  • 16,964
  • 12
  • 68
  • 74
Rao's
  • 1,087
  • 8
  • 24
  • 45

3 Answers3

9

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")
AnsonChen
  • 268
  • 3
  • 7
  • I checked your library its good. But can we change aspect ratio programmatically at runtime. For Example first time i will go with 1.334 and then in fullscreen listener i wana change it back to default 1.778. But there is not method setAspectRatio (); – Paranoid Mar 22 '20 at 11:38
  • Unfortunately this great library does not work unless you are using an old version of Glide. – Fattie Apr 09 '21 at 17:17
  • is there any way to use vimeo videos in android java , this is not working with the latest version of glide – JIL Android dev Dec 27 '22 at 08:19
5

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.

Dashron
  • 3,968
  • 2
  • 14
  • 21
  • 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 Feb 22 '16 at 17:39
  • 1
    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 Feb 22 '16 at 17:50
  • 1
    Finally i got one solution is this right way http://player.vimeo.com/video/123891946/config -- Get method. In response i will get .mp4 format – Rao's Feb 22 '16 at 18:27
  • 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 https://api.vimeo.com/me/videos – Dashron Feb 23 '16 at 03:07
  • I am getting this error when i call above api { "error": "You must provide a valid authenticated access token." } – Rao's Feb 23 '16 at 05:43
  • What is this?? Where i have to valid authenticated User – Rao's Feb 23 '16 at 05:48
  • 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??? – Rao's Feb 23 '16 at 05:58
  • @Rao's pls help me i am also getting same issue .... as i have used the link https://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 ? – Erum Jul 25 '16 at 05:36
  • @Erum u have to authenticate. ask server side people sent url. For them it easy to fetch and authenticate – Rao's Aug 27 '16 at 08:41
  • 3
    can anyone post a sample or clear tutorial to embed VIMEO video to android native application.!!! Thanks – Arnold Brown Feb 21 '18 at 06:29
2

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.