获取直接 Vimeo 视频 url Android

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23042573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:42:58  来源:igfitidea点击:

Get direct Vimeo video url Android

androidvideovimeo

提问by Andrew F

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?

我需要在只有视频 ID 的应用中播放 Vimeo viode。例如 83342420。如何获取 vimeo 视频 url?或者有没有其他方法可以在android中播放视频?

I tried WebView solution but it doesn't suit. I also tried the urls like http://vimeo.com/moogaloop/play/clip:7926539/5cd4f7989ee0cb5018c131260aa1fc8c/1309860388/but I'm getting 404 Not found. Maybe I need some kind of api key or token?

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

Thanks.

谢谢。

回答by Andrew F

Ok. For getting direct url for Vimeo video just need to send GET Request to url:

好的。要获取 Vimeo 视频的直接 url,只需将 GET 请求发送到 url:

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

In result you will get such response:

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

{
  "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
  }
}

回答by Dashron

Vimeo does not offer support for any videos play urls. Vimeo only offers 2 methods for playing videos on mobile.

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

  1. Embeddable videos work in many Android web views.
  2. PRO members have access to direct video file links (including HLS) and can use these in their own mobile apps.
  1. 可嵌入视频适用于许多 Android 网页视图。
  2. PRO 会员可以访问直接的视频文件链接(包括 HLS),并且可以在他们自己的移动应用程序中使用这些链接。

回答by Lovekush Vishwakarma

use this url - http://player.vimeo.com/video/video_id/configwith GET method, and pass your video_id, you will get the below result. this is latest response is coming from Vimeo, because the change response.

使用此 url - 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://[email protected]/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"
}

回答by Lovekush Vishwakarma

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

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

The setup in Html looks like this:

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>

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

编辑:我只想说,记得用你的 Vimeo 视频的 id 替换 YOURVIMEOIDHERE。

回答by Darshan Singh

To Play Vimeo Video from the iframeurl, use that code. It's working fine.

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

  1. Use layout with Web view and frame Layout
  2. Create a custom WebViewClient for Both ChromeClient and WebViewClient and Play video either using Loadurl or 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);  
        }
    }
    
    }
    
  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);  
        }
    }
    
    }