我有一个在webview中播放自适应流媒体视频的应用。问题是当试图注入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!');");
答案 0 :(得分:0)
当我尝试在网络视图中播放视频时,这段小代码对我有用:
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");
您可以在字符串
中为宽度和高度赋予任何值