0

我有一个应用程序可以在 web 视图中播放自适应流媒体视频。问题是在尝试注入 javascript 时,视频会冻结。

HTML:

<video src="http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8" autoplay="autoplay" controls="controls" height="720" width="1280" />

安卓:

webView.loadUrl("javascript:alert('Hello World!');");
4

1 回答 1

0

因此,当我尝试在 webview 中播放视频时,这段小代码对我有用:

      String videoPoP = "http://www.youtube.com/v/A6kCkkLo6Rw?";
      webview.getSettings().setJavaScriptEnabled(true);
      String widthAndHeight = "width=\"" + widthdp + "\" height=\"" + height_new + "\"";            

            String temp = "<object "
                + widthAndHeight
                + ">"
                + "<body style='margin:0;padding:0;'>"
                + "<param name='allowFullScreen' value='false'>"
                + "</param><param name='allowscriptaccess' value='always'>"
                + "</param><embed src='"
                + videoPoP
                + "'"
                + " type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true'"
                + widthAndHeight + "></embed></object>";


        webview.loadData(temp, "text/html", "utf-8");

您可以为字符串中的宽度和高度赋予任何值

于 2012-08-23T16:17:51.907 回答