6

I'm using the official Vimeo Android Library.

Here's how I add it: compile 'com.vimeo.networking:vimeo-networking:1.1.1'

And here's how I use it:

// where mUri is in the following format: /videos/<videoId>
VimeoClient.getInstance().fetchNetworkContent(mUri, new ModelCallback<Video>(Video.class) {
            @Override
            public void success(Video video) {
                if (!video.getStatus().equals(Video.Status.AVAILABLE)) {
                    // still processing
                } else {
                    // code goes here because its status is already available
                    Log.e("main", "play: " + video.getPlay());
                    // this logs -- play: null
                }
            }
            @Override
            public void failure(VimeoError error) {
                Log.e("main", error.getErrorMessage());
            }
        });

video.getDownload() works and gives me an array of 3. I use the same access token that I used to upload the video. I also have a PRO account. I tried it in postman, using exactly the same access token and video ID and it works. The result contains a files section w/c looks something like this:

"files": [
        {
            "quality": "sd",
            "type": "video/mp4",
            "width": 480,
            "height": 640,
            "link": "<working string link here, I just replaced it for security>",
            "created_time": "2017-10-26T06:58:09+00:00",
            "fps": 23.980000000000000426325641456060111522674560546875,
            "size": 867030,
            "md5": "<md5 value here, I just replaced it for security>",
            "link_secure": "<working string link here, I just replaced it for security>"
        },
        {
            "quality": "sd",
            ...
        },
        {
            "quality": "hls",
            ...
        }
    ]

Those are 3 videos w/ working links. So I don't know why they're not being retrieved by the library :(

Please help, thanks!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mon
  • 1,010
  • 1
  • 11
  • 19

2 Answers2

1

As this github issue points out you should check this branch on github.

video.getPlay() is still not public available. You should use this instead. From documentation.

Video video = ...; // obtain a video you own as described above
ArrayList<VideoFile> videoFiles = video.files;
if(videoFiles != null && !videoFiles.isEmpty()) {
     VideoFile videoFile = videoFiles.get(0); // you could sort these files by size, fps, width/height
     String link = videoFile.getLink();
     // load link
}

If you attend all the requesites you should be able to get all the array of video files. The array will contain the mp4sd, mp4hd and hls link.

Hls link is the last one in the array, so you can get it by using.

VideoFile videoFile = videoFiles.get(videoFiles.size() - 1);
String hlsLink = videoFile.getLink();
Soon Santos
  • 2,107
  • 22
  • 43
0

Here are some important points to keep in mind to get the data successfully :-

  1. 
url to fetch the video should be like "https://api.vimeo.com/videos/{video_id}"
  2. In a succesful response from fetch API, Play data will be there iff the video is created by the same user whose access token you are using. In other words, Only those videos will have Play data whose user is same as video creator/member on vimeo account as your access token owner.
    This is mentioned in the official document here https://developer.vimeo.com/api/authentication (Understanding the authentication process)
  1. The access token (not cliendId or secret) needs to have all the three access to be check at the time of building it - "public", "private", "video file"

For a more detailed answer with code pls check my answer here :- https://stackoverflow.com/a/75175407/9747826

Damanpreet Singh
  • 678
  • 10
  • 15