Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vimeo API Video.getPlay always returns null

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!

like image 267
Mon Avatar asked Nov 08 '22 15:11

Mon


1 Answers

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();
like image 109
Soon Santos Avatar answered Nov 15 '22 11:11

Soon Santos