Vimeo API Video.getPlay always returns null
Asked Answered
A

2

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!

Apia answered 26/10, 2017 at 8:36 Comment(8)
anyone who can help?Apia
please help huhu T__TApia
anyone? please?Apia
Same issue here, you found any solutions?Chronologist
Actually the only way i've found to play the video in a VideoView is getting the video URI from: video.files.get(0).getLink())Chronologist
sorry long time no reply. Nah, workaround was the same with LinkOut's comment. But anyway, the project is paused so haven't checked yet if they've already fixed it.Apia
Check if this helps. You need to make sure the requirements are correct in order to get a valid Play.Draff
Look at this issue. Apparently, video.getPlay() is not available yet.Draff
D
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();
Draff answered 26/10, 2018 at 12:45 Comment(0)
D
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://mcmap.net/q/1009335/-getting-video-files-value-null-while-integrating-with-vimeo-networking-java-library-to-play-the-video-by-uri

Diphenylamine answered 20/1, 2023 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.