Get direct Vimeo video url Android

后端 未结 5 1945
梦毁少年i
梦毁少年i 2020-12-14 05:11

I need to play Vimeo viodes in my app having only video id. For example 83342420. How can I get vimeo video url? Or is there any other way to play video in android?

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 06:00

    Going off of what Andrew F had commented, I wrote this simple Javascript to handle this process:

    function loadVimeoVideo(id) {
        'use strict';
        var req, json, url;
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            req = new XMLHttpRequest();
        } else { // code for IE6, IE5
            req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        req.onreadystatechange = function () {
            if (req.readyState === 4 && req.status === 200) {
                json = JSON.parse(req.responseText);
                url = json.request.files.h264.sd.url;
                document.getElementById(id).getElementsByTagName("source")[0].setAttribute("src",url);
            }
        };
        req.open("GET", ("https://player.vimeo.com/video/").concat(id, "/config"), true);
        req.send();
    }
    

    The setup in Html looks like this:

    
    

    Edit: I'm just going to say it, remember to replace YOURVIMEOIDHERE with your Vimeo video's id.

提交回复
热议问题