Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vimeo video play in Android native

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

like image 636
Rao's Avatar asked Feb 20 '16 08:02

Rao's


3 Answers

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")
like image 72
AnsonChen Avatar answered Sep 21 '22 01:09

AnsonChen


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.

like image 42
Dashron Avatar answered Sep 23 '22 01:09

Dashron


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.

like image 42
Robiul Hossain Shah Imran Avatar answered Sep 23 '22 01:09

Robiul Hossain Shah Imran