【问题标题】:Play DailyMotion Video in webView Android在 webView Android 中播放 DailyMotion 视频
【发布时间】:2013-02-05 17:16:55
【问题描述】:

我尝试在 web 视图中嵌入 dailyMotion 视频,我得到了预览,但是当我尝试播放它时,它不起作用。

我一直在网上寻找解决方案,但没有找到任何可行的示例。

这是代码

String data_html = "<!DOCTYPE HTML> <html>"
            + "<head>"
            + "<style>"
            + "body"
            + "{"
            + "margin:0;"
            + "padding:0;"
            + "height: 100%;"
            + "width: 100%;"
            + "background-color: #000;"
            + "color: #fff;"
            + "font-family: sans-serif;"
            + "overflow: hidden;"
            + "-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" /* Disable ugly Android highlight */
            + "}"
            + "</style>"
            + "</head>"
            + "<body>"
            + "<iframe src=\"http://www.dailymotion.com/embed/video/xu4vre\" width=\"300\" height=\"160\" frameborder=\"0\"></iframe>"
            + "</body>" + "</html>";

    webView.loadData(data_html, "text/html", null); 

【问题讨论】:

    标签: android webview


    【解决方案1】:

    在 Dailymotion 中获取视频的嵌入代码,并像这样为其分配 videoHtml;

        webView = (WebView) findViewById(R.id.webView1);
        videoHtml = "<iframe frameborder=\"0\" width=\"480\" height=\"270\" src=\"http://www.dailymotion.com/embed/video/xznb64\"></iframe><br /><a href=\"http://www.dailymotion.com/video/xznb64_leyla-ile-mecnun-dan-evlilik-programlarina-gonderme_news\" target=\"_blank\">Leyla İle Mecnun&#039;dan Evlilik Programlarına...</a> <i>ile  <a href=\"http://www.dailymotion.com/trthaber\" target=\"_blank\">trthaber</a></i>";
        webView.loadData(videoHtml, "text/html", "UTF-8");
        webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setPluginsEnabled(true);
    

    【讨论】:

      猜你喜欢
      • 2014-07-22
      • 1970-01-01
      • 2012-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-16
      • 1970-01-01
      • 2012-12-14
      相关资源
      最近更新 更多