获取直接Vimeo视频网址Android

时间:2014-04-13 12:11:07

标签: android video vimeo

我需要在我的应用中播放Vimeo viodes,只有视频ID。例如83342420。 我怎样才能获得vimeo视频网址?或者还有其他方法可以在Android中播放视频吗?

我尝试过WebView解决方案但不适合。 我也试过像http://vimeo.com/moogaloop/play/clip:7926539/5cd4f7989ee0cb5018c131260aa1fc8c/1309860388/这样的网址,但我找不到404。 也许我需要某种api密钥或令牌?

感谢。

5 个答案:

答案 0 :(得分:33)

确定。要获得Vimeo视频的直接网址,只需将GET请求发送到网址:

old url - http://player.vimeo.com/v2/video/<video_id>/config
**UPD**: new url - http://player.vimeo.com/video/<video_id>/config

结果你会得到这样的回应:

{
  "cdn_url": "http://f.vimeocdn.com",
  "view": 1,
  "request": {
    "files": {
      "h264": {
        "mobile": {
          "profile": 116,
          "origin": "ns3.pdl",
          "url": "http://pdl.vimeocdn.com/84730/904/216566897.mp4?token2=1397407519_8b323701fa08b3531612d6160be9cc5e&aksessionid=01788ff54890a9b2",
          "height": 270,
          "width": 480,
          "id": 216566897,
          "bitrate": 547,
          "availability": 60
        },
        "hd": {
          "profile": 113,
          "origin": "ns3.pdl",
          "url": "http://pdl.vimeocdn.com/87179/143/216566895.mp4?token2=1397407519_1d0ef28841fb628c423f9dbeb93168d4&aksessionid=2a0b480300c82ef7",
          "height": 720,
          "width": 1280,
          "id": 216566895,
          "bitrate": 3142,
          "availability": 60
        },
        "sd": {
          "profile": 112,
          "origin": "ns3.pdl",
          "url": "http://pdl.vimeocdn.com/57248/568/216566886.mp4?token2=1397407519_395f6cf4e80b98826424e21c8de508d1&aksessionid=598e59776ed0979a",
          "height": 360,
          "width": 640,
          "id": 216566886,
          "bitrate": 1198,
          "availability": 60
        }
      },
      "hls": {
        "all": "http://av20.hls.vimeocdn.com/i/,57248/568/216566886,87179/143/216566895,84730/904/216566897,.mp4.csmil/master.m3u8?primaryToken=1397407519_93cf5d54b3482e3a1e716cf28b9550a7",
        "hd": "http://av20.hls.vimeocdn.com/i/,87179/143/216566895,.mp4.csmil/master.m3u8?primaryToken=1397407519_a84194ace821175f0ee0ff9ab8d9241f"
      },
      "codecs": [
        "h264"
      ]
    },
    "ga_account": "UA-76641-35",
    "timestamp": 1397406594,
    "expires": 925,
    "prefix": "/v2",
    "session": "d85291b3aa5b3e5fbf3ea82d81d7d5e849aa50e5",
    "cookie": {
      "scaling": 1,
      "volume": 1.0,
      "hd": null,
      "captions": null
    },
    "cookie_domain": ".vimeo.com",
    "referrer": null,
    "conviva_account": "c3.Vimeo",
    "flags": {
      "login": 1,
      "preload_video": 1,
      "plays": 1,
      "partials": 1,
      "conviva": 1
    },
    "build": {
      "player": "a30ff35f",
      "js": "2.4.7"
    },
    "urls": {
      "zeroclip_swf": "http://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard.swf",
      "js": "http://f.vimeocdn.com/p/2.4.7/js/player.js",
      "proxy": "https://f.vimeocdn.com/p/2.4.7/proxy.html",
      "conviva": "http://livepassdl.conviva.com/ver/2.72.0.13589/LivePass.js",
      "flideo": "http://f.vimeocdn.com/p/flash/flideo/1.0.3b10/flideo.swf",
      "canvas_js": "http://f.vimeocdn.com/p/2.4.7/js/player.canvas.js",
      "moog": "http://f.vimeocdn.com/p/flash/moogaloop/6.0.9/moogaloop.swf?clip_id=83342420",
      "conviva_service": "http://livepass.conviva.com",
      "moog_js": "http://f.vimeocdn.com/p/2.4.7/js/moogaloop.js",
      "zeroclip_js": "http://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard-patch.js",
      "css": "http://f.vimeocdn.com/p/2.4.7/css/player.css"
    },
    "signature": "09c6bc41e6a7d343748ed3e00420a108"
  },
  "player_url": "player.vimeo.com",
  "video": {
    "allow_hd": 1,
    "height": 720,
    "owner": {
      "account_type": "pro",
      "name": "Sabian",
      "img": "http://i.vimeocdn.com/portrait/2511583_75x75.jpg",
      "url": "http://vimeo.com/sabian",
      "img_2x": "http://i.vimeocdn.com/portrait/2511583_150x150.jpg",
      "id": 8487062
    },
    "thumbs": {
      "1280": "http://i.vimeocdn.com/video/459788805_1280.jpg",
      "960": "http://i.vimeocdn.com/video/459788805_960.jpg",
      "640": "http://i.vimeocdn.com/video/459788805_640.jpg"
    },
    "duration": 25,
    "id": 83342420,
    "hd": 1,
    "embed_code": "<iframe src=\"//player.vimeo.com/video/83342420\" width=\"500\" height=\"281\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>",
    "default_to_hd": 0,
    "title": "Mike Portnoy",
    "url": "https://vimeo.com/83342420",
    "privacy": "anybody",
    "share_url": "http://vimeo.com/83342420",
    "width": 1280,
    "embed_permission": "public",
    "fps": 24.0
  },
  "build": {
    "player": "a30ff35f",
    "rpc": "dev"
  },
  "embed": {
    "player_id": null,
    "outro": "videos",
    "api": 2,
    "context": "embed.main",
    "time": 0,
    "color": "00adef",
    "settings": {
      "fullscreen": 1,
      "byline_badge": {
        "url": "http://vimeo.com/sabian",
        "type": "pro"
      },
      "byline": 1,
      "like": 1,
      "playbar": 1,
      "title": 1,
      "color": 0,
      "branding": 1,
      "share": 1,
      "scaling": 1,
      "logo": 1,
      "info_on_pause": 0,
      "watch_later": 1,
      "portrait": 1,
      "embed": 1,
      "badge": 0,
      "volume": 1
    },
    "on_site": 0,
    "loop": 0,
    "autoplay": 0
  },
  "vimeo_url": "vimeo.com",
  "user": {
    "liked": 0,
    "account_type": "basic",
    "logged_in": 1,
    "owner": 0,
    "watch_later": 0,
    "id": 26896968,
    "mod": false
  }
}

答案 1 :(得分:3)

Vimeo不支持任何视频播放网址。 Vimeo仅提供2种在移动设备上播放视频的方法。

  1. 嵌入式视频适用于多种Android网络视图。
  2. PRO会员可以访问直接视频文件链接(包括HLS),并可以在自己的移动应用中使用这些链接。

答案 2 :(得分:1)

使用此网址-http://player.vimeo.com/video/video_id/config和GET方法,并传递您的video_id,您将获得以下结果。这是来自Vimeo的最新响应,因为更改响应。

{
  "cdn_url": "https://f.vimeocdn.com",
  "vimeo_api_url": "api.vimeo.com",
  "request": {
    "files": {
      "dash": {
        "separate_av": true,
        "streams": [
          {
            "profile": 164,
            "quality": "360p",
            "id": 1047687609,
            "fps": 30
          },
          {
            "profile": 175,
            "quality": "1080p",
            "id": 1047687611,
            "fps": 30
          },
          {
            "profile": 165,
            "quality": "540p",
            "id": 1047687607,
            "fps": 30
          },
          {
            "profile": 174,
            "quality": "720p",
            "id": 1047687604,
            "fps": 30
          }
        ],
        "cdns": {
          "akfire_interconnect_quic": {
            "url": "https://112skyfiregce-vimeo.akamaized.net/exp=1531572843~acl=%2F279620511%2F%2A~hmac=fc67765d21d06ae32cd69b0fa7a9f229ba5c492a6ea14d14cfee32fce9afb1a2/279620511/sep/video/1047687609,1047687611,1047687607,1047687604/master.json?base64_init=1",
            "origin": "gcs"
          },
          "fastly_skyfire": {
            "url": "https://skyfire.vimeocdn.com/1531572843-0xb2b233940673f62145704b412d1469ea2f179a4c/279620511/sep/video/1047687609,1047687611,1047687607,1047687604/master.json?base64_init=1",
            "origin": "gcs"
          }
        },
        "default_cdn": "akfire_interconnect_quic"
      },
      "hls": {
        "separate_av": false,
        "default_cdn": "akfire_interconnect_quic",
        "cdns": {
          "akfire_interconnect_quic": {
            "url": "https://112skyfiregce-vimeo.akamaized.net/exp=1531572843~acl=%2F279620511%2F%2A~hmac=fc67765d21d06ae32cd69b0fa7a9f229ba5c492a6ea14d14cfee32fce9afb1a2/279620511/video/1047687609,1047687611,1047687607,1047687604/master.m3u8",
            "origin": "gcs"
          },
          "fastly_skyfire": {
            "url": "https://skyfire.vimeocdn.com/1531572843-0xb2b233940673f62145704b412d1469ea2f179a4c/279620511/video/1047687609,1047687611,1047687607,1047687604/master.m3u8",
            "origin": "gcs"
          }
        }
      },
      "progressive": [
        {
          "profile": 175,
          "width": 1920,
          "mime": "video/mp4",
          "fps": 30,
          "url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687611.mp4%2A~hmac=90eacf4c4956f322393ac1b5e4d0df91694c5e5af36eabccd2a28780e4364148/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687611.mp4",
          "cdn": "akamai_interconnect",
          "quality": "1080p",
          "id": 1047687611,
          "origin": "gcs",
          "height": 1080
        },
        {
          "profile": 164,
          "width": 640,
          "mime": "video/mp4",
          "fps": 30,
          "url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687609.mp4%2A~hmac=4c90608f99044633906efb33f04e314569cd865266529b96977ee7eeecce4f80/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687609.mp4",
          "cdn": "akamai_interconnect",
          "quality": "360p",
          "id": 1047687609,
          "origin": "gcs",
          "height": 360
        },
        {
          "profile": 165,
          "width": 960,
          "mime": "video/mp4",
          "fps": 30,
          "url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687607.mp4%2A~hmac=a0f28428ec2da33b5501936f32a3bc17aee0446dfbb5f0597c5b51f743cebc65/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687607.mp4",
          "cdn": "akamai_interconnect",
          "quality": "540p",
          "id": 1047687607,
          "origin": "gcs",
          "height": 540
        },
        {
          "profile": 174,
          "width": 1280,
          "mime": "video/mp4",
          "fps": 30,
          "url": "https://gcs-vimeo.akamaized.net/exp=1531572843~acl=%2A%2F1047687604.mp4%2A~hmac=6a3da45344051eb54196967bebebbd34841f09c049ca377b7f664786f24dfb95/vimeo-prod-skyfire-std-us/01/924/11/279620511/1047687604.mp4",
          "cdn": "akamai_interconnect",
          "quality": "720p",
          "id": 1047687604,
          "origin": "gcs",
          "height": 720
        }
      ]
    },
    "lang": "en",
    "sentry": {
      "url": "https://9e9ab33f1870463393a4a1e85a1280c2@sentry.cloud.vimeo.com/2",
      "enabled": false,
      "debug_enabled": true,
      "debug_intent": 0
    },
    "ab_tests": {},
    "referrer": null,
    "cookie_domain": ".vimeo.com",
    "timestamp": 1531568943,
    "gc_debug": {
      "bucket": "vimeo-player-debug"
    },
    "expires": 3600,
    "currency": "USD",
    "session": "d2a0f4ba2c4a97b7e59e349e54ee5e4d212a78b01531568943",
    "cookie": {
      "scaling": 1,
      "volume": 1,
      "quality": null,
      "hd": 0,
      "captions": null
    },
    "build": {
      "player": "",
      "js": "2.75.6"
    },
    "urls": {
      "zeroclip_swf": "https://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard.swf",
      "fresnel": "https://fresnel.vimeocdn.com/add/player-stats",
      "js": "https://f.vimeocdn.com/p/2.75.6/js/player.js",
      "proxy": "https://player.vimeo.com/static/proxy.html",
      "chromeless_css": "https://f.vimeocdn.com/p/2.75.6/css/chromeless.css",
      "flideo": "https://f.vimeocdn.com/p/flash/flideo/1.0.6/flideo.swf",
      "moog": "https://f.vimeocdn.com/p/flash/moogaloop/6.4.5/moogaloop.swf?clip_id=279620511",
      "three_js": "https://f.vimeocdn.com/p/external/three.rvimeo.min.js",
      "mux_url": "https://f.vimeocdn.com/p/external/mux.js",
      "vuid_js": "https://f.vimeocdn.com/js_opt/modules/utils/vuid.min.js",
      "chromeless_js": "https://f.vimeocdn.com/p/2.75.6/js/chromeless.js",
      "moog_js": "https://f.vimeocdn.com/p/2.75.6/js/moogaloop.js",
      "zeroclip_js": "https://f.vimeocdn.com/p/external/zeroclipboard/ZeroClipboard-patch.js",
      "css": "https://f.vimeocdn.com/p/2.75.6/css/player.css"
    },
    "signature": "8544b7e2ca11afdca19cef76f57fed72",
    "flags": {
      "dnt": 0,
      "preload_video": "metadata_on_hover",
      "plays": 1,
      "webp": 0,
      "flash_hls": 1,
      "log_to_es": 0,
      "partials": 1,
      "autohide_controls": 0
    },
    "country": "IN"
  },
  "player_url": "player.vimeo.com",
  "video": {
    "version": {
      "current": null,
      "available": [
        {
          "is_current": 1,
          "id": 20743507,
          "file_id": 1047687416
        }
      ]
    },
    "height": 1080,
    "duration": 543,
    "thumbs": {
      "640": "https://i.vimeocdn.com/video/712935666_640.jpg",
      "960": "https://i.vimeocdn.com/video/712935666_960.jpg",
      "1280": "https://i.vimeocdn.com/video/712935666_1280.jpg",
      "base": "https://i.vimeocdn.com/video/712935666"
    },
    "owner": {
      "account_type": "pro",
      "name": "You Are a CEO",
      "img": "https://i.vimeocdn.com/portrait/26028985_60x60.jpg",
      "url": "https://vimeo.com/user19222589",
      "img_2x": "https://i.vimeocdn.com/portrait/26028985_120x120.jpg",
      "id": 19222589
    },
    "file_codecs": {
      "hevc": {
        "hdr": [],
        "sdr": []
      },
      "avc": [
        1047687611,
        1047687609,
        1047687607,
        1047687604
      ]
    },
    "id": 279620511,
    "embed_code": "<iframe src=\"https://player.vimeo.com/video/279620511\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen></iframe>",
    "title": "DRAFT- MINTSHOW TO UPLIFT",
    "share_url": "https://vimeo.com/279620511",
    "width": 1920,
    "embed_permission": "public",
    "fps": 30,
    "spatial": 0,
    "live_event": null,
    "allow_hd": 1,
    "hd": 1,
    "lang": null,
    "default_to_hd": 0,
    "url": null,
    "privacy": "unlisted",
    "unlisted_hash": "1795b097a5"
  },
  "user": {
    "vimeo_api_interaction_tokens": null,
    "liked": 0,
    "account_type": "none",
    "vimeo_api_client_token": null,
    "progress": 0,
    "owner": 0,
    "watch_later": 0,
    "logged_in": 0,
    "id": 0,
    "mod": 0
  },
  "embed": {
    "autopause": 1,
    "playsinline": 1,
    "settings": {
      "fullscreen": 1,
      "byline": 1,
      "like": 1,
      "playbar": 1,
      "title": 1,
      "color": 0,
      "branding": 1,
      "watch_later": 1,
      "share": 0,
      "scaling": 1,
      "spatial_compass": 1,
      "collections": 0,
      "info_on_pause": 0,
      "portrait": 1,
      "logo": 1,
      "embed": 1,
      "badge": 0,
      "spatial_label": 1,
      "speed": 0,
      "volume": 1
    },
    "color": "00adef",
    "on_site": 0,
    "app_id": "",
    "muted": 0,
    "dnt": 0,
    "player_id": "",
    "api": 3,
    "editor": false,
    "context": "embed.main",
    "time": 0,
    "outro": "videos",
    "log_plays": 1,
    "quality": null,
    "transparent": 1,
    "loop": 0,
    "autoplay": 0
  },
  "view": 1,
  "vimeo_url": "vimeo.com"
}

答案 3 :(得分:0)

关于Andrew F评论的内容,我编写了这个简单的Javascript来处理这个过程:

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();
}

Html中的设置如下所示:

<video id="YOURVIMEOIDHERE" controls loop muted preload="auto" autoplay="false" onloadeddata="loadVimeoVideo('YOURVIMEOIDHERE')">
    <source src="" type="video/mp4" />
    Your browser does not support the video tag, which was introduced in html5.
</video>

编辑:我只想说出来,记得用您的Vimeo视频ID替换YOURVIMEOIDHERE。

答案 4 :(得分:0)

要从iframe网址播放Vimeo视频,请使用该代码。它工作正常。

  1. 使用带有Web视图和框架布局的布局
  2. 为ChromeClient和WebViewClient创建自定义WebViewClient 并使用Loadurl或LoadBaseUrl播放视频。

    {
    
    enter code here
    
        webView = (WebView) findViewById(R.id.web_details);
        mWebViewClient = new myWebViewClient();
        webView.setWebViewClient(mWebViewClient);
        mWebChromeClient = new myWebChromeClient();
        webView.setWebChromeClient(mWebChromeClient);     
        WebSetting settings = webView.getSetting();
        settings.setJavaScriptEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setMinimumFontSize(10);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        settings.setBuiltInZoomControls(true);
        settings.setDisplayZoomControls(false);
        webView.setVerticalScrollBarEnabled(false);
        vUrl = changedHeaderHtml(getIntent().getStringExtra("videoUrl"));
        webView.loadDataWithBaseURL(null, vUrl, "text/html", "UTF-8", null);
    }
    public static String changedHeaderHtml(String strUrl) {
        return "<head><meta name=\"viewport\" content=\"width=device-width, user-scalable=yes\" /></head>" + strUrl + "</body></html>";
    }
    public boolean inCustomView() {
        return (mCustomView != null);
    }
    
    public void hideCustomView() {
        mWebChromeClient.onHideCustomView();
    }
    
    @Override
    protected void onPause() {
        super.onPause();    //To change body of overridden methods use File | Settings | File Templates.
        webView.onPause();
    }
    
    @Override
    protected void onResume() {
        super.onResume();    //To change body of overridden methods use File | Settings | File Templates.
        webView.onResume();
    }
    
    @Override
    protected void onStop() {
        super.onStop();    //To change body of overridden methods use File | Settings | File Templates.
        if (inCustomView()) {
            hideCustomView();
        }
    }
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
    
            if (inCustomView()) {
                hideCustomView();
                return true;
            }
    
            if ((mCustomView == null) && webView.canGoBack()) {
                webView.goBack();
                return true;
            }
        }
        return super.onKeyDown(keyCode, event);
     }
    
    class myWebChromeClient extends WebChromeClient {
        private Bitmap mDefaultVideoPoster;
        private View mVideoProgressView;
    
        @Override
     public void onShowCustomView(View view, int requestedOrientation,CustomViewCallback callback) {
            onShowCustomView(view, callback); //To change body of overridden methods use File | Settings | File Templates.
        }
    
        @Override
        public void onShowCustomView(View view,CustomViewCallback callback) {
    
        // if a view already exists then immediately terminate the new one
            if (mCustomView != null) {
                callback.onCustomViewHidden();
                return;
            }
            mCustomView = view;
            webView.setVisibility(View.GONE);
            customViewContainer.setVisibility(View.VISIBLE);
            customViewContainer.addView(view);
            customViewCallback = callback;
        }
    
        @Override
        public View getVideoLoadingProgressView() {
    
            if (mVideoProgressView == null) {
                LayoutInflater inflater = LayoutInflater.from(WebMainActivity.this);
                mVideoProgressView = inflater.inflate(R.layout.video_progress, null);
            }
            return mVideoProgressView;
        }
    
        @Override
        public void onHideCustomView() {
            super.onHideCustomView();    //To change body of overridden methods use File | Settings | File Templates.
            if (mCustomView == null)
                return;
    
            webView.setVisibility(View.VISIBLE);
            customViewContainer.setVisibility(View.GONE);
    
            // Hide the custom view.
            mCustomView.setVisibility(View.GONE);
    
            // Remove the custom view from its container.
            customViewContainer.removeView(mCustomView);
            customViewCallback.onCustomViewHidden();
    
            mCustomView = null;
        }
    }
    
    class myWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            url =vUrl;
    
            return super.shouldOverrideUrlLoading(view, url);  
        }
    }
    
    }