1

I have tried playing vimeo video using webview. But it doesn't look good, it makes the screen scrollable. Vimeo has suggested one more way to play using native playback, but it has specific requirements to use

The basic requirements for native playback are:

  1. User must be logged in.
  2. User must be the owner of the video.
  3. User must be PRO or higher (or the app must have the "can access owner's video files" capability).
  4. Token must have the video_files scope. User must be the owner of the API app making the request

I don't have PRO account. How can i use native playback just to test, if all goes well then i will go for vimeo PRO

THIS IS CODE WHICH I AM USING FOR PLAYING USING WEBVIEW

 VimeoClient.getInstance().fetchNetworkContent(uri, new ModelCallback<Video>(Video.class) {
            @Override
            public void success(Video video) {
                String html = video.embed != null ? video.embed.html : null;
                if(html != null) {
                    WebView webView = (WebView) findViewById(R.id.webView);
                    WebSettings webSettings = webView.getSettings();
                    webSettings.setJavaScriptEnabled(true);
                    webView.loadData(html, "text/html", "utf-8");
                }
            }

            @Override
            public void failure(VimeoError error) {

                Log.d(TAG, "failure: ");
            }
        });
    }

Is there any other way to play the video?

Tcurran
  • 11
  • 1

1 Answers1

1

In my case I used Exoplayer. Exoplayer is more customizable. All you need is to extract the url link from the 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();
           

Now you can play using this url . Don't forget to initiate Exoplayer first.

  • Thanks for replying, what do i need to provide in "config" ? – Tcurran Oct 25 '20 at 16:11
  • To get the video JSON you will need to hit the link . Example "https://player.vimeo.com/video/video_id/config" . You just need to pass the video_id only. Your video id could be 123455678..etc – Robiul Hossain Shah Oct 26 '20 at 11:14
  • here, we need both id and config. **@GET("{id}/{config}") CallgetVideoLink(@Path("id") String id, @Path("config") String config);** suppose the video link is https://vimeo.com/1234567 i know id = 1234567 but config = ? from where do i get config ? – Tcurran Oct 26 '20 at 16:07
  • config =config If your link is vimeo.com/1234567 then you will use this link : player.vimeo.com/video/1234567/config for retrofit. – Robiul Hossain Shah Oct 27 '20 at 04:29
  • thanks, it works. but i am wondering when would i need to use scope for accessing my private as mentioned in vimeo documentations – Tcurran Oct 29 '20 at 17:37
  • The cdn link changes. So this will get you the latest link all the time if you use this code. – Robiul Hossain Shah Oct 31 '20 at 05:07