由网友(锁骨上的诱惑ゝ)分享简介:我有问题,我不能在web视图通过这里HTML5播放视频,我的code web视图=(的WebView)findViewById(R.id.web); //新的WebView(本); webView.setBackgroundColor(android.R.color.transparent); webView.ge...
我有问题,我不能在web视图通过这里HTML5播放视频,我的code
web视图=(的WebView)findViewById(R.id.web); //新的WebView(本); webView.setBackgroundColor(android.R.color.transparent); webView.getSettings()setJavaScriptEnabled(真)。 webView.getSettings()setPluginsEnabled(真)。 。webView.getSettings()setAllowFileAccess(真); webView.getSettings()setDefaultZoom(WebSettings.ZoomDensity.FAR)。 。webView.getSettings()setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); webView.loadUrl(文件:///android_asset/index.html);
和我在这里code HTML
< HTML LANG =ENGT&; < HEAD><间的charset =UTF-8><标题>< /标题> < /头> <身体GT; <视频自动播放=自动播放控制=控制的风格=对齐:中心;自动缓冲的onclick =this.play();> <信源SRC =birtday2527.theora.ogvTYPE =视频/ OGGcodeCS =Theora格式,Vorbis格式/> <信源SRC =birtday2527.mp4TYPE =视频/ MP4/> < /视频> < /身体GT;
我通过考试有Nexus S的。
解决方案 网页视图=(的WebView)findViewById(R.id.VWebview);vWebview.getSettings()setJavaScriptEnabled(真)。vWebview.getSettings()setPluginsEnabled(真)。ViewContent(生);InputStream的FILESTREAM = getResources()openRawResource(R.raw.test)。INT fileLen = fileStream.available();字节[] = fileBuffer新的字节[fileLen]fileStream.read(fileBuffer);fileStream.close();字符串displayText =新的String(fileBuffer);vWebview.loadDataWithBaseURL(假货://没有/需要,displayText,text / html的,UTF-8,);
这是
<!DOCTYPE HTML>< HTML的xmlns =http://www.w3.org/1999/xhtml>< HEAD>< META HTTP-EQUIV =Content-Type的CONTENT =text / html的;字符集= ISO-8859-1/><标题>的Hello World< /标题><身体GT;< DIV>&所述p为H.;<视频SRC =文件:///android_asset/test.m4v海报=文件:///android_asset/test.jpg的onclick =this.play();/>&所述; / P>< / DIV>< /身体GT;< / HTML>
I have problem, i can't play video in webview by html5 here,my code
webView = (WebView) findViewById(R.id.web);//new WebView(this);
webView.setBackgroundColor(android.R.color.transparent);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webView.loadUrl("file:///android_asset/index.html");
and here mycode html
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<video autoplay="autoplay" controls="controls" style="align:center;" autobuffer onclick="this.play();">
<source src="birtday2527.theora.ogv" type="video/ogg" codecs="theora, vorbis"/>
<source src="birtday2527.mp4" type="video/mp4"/>
</video>
</body>
i have nexus s by test.
解决方案Webview = (WebView)findViewById(R.id.VWebview);
vWebview.getSettings().setJavaScriptEnabled(true);
vWebview.getSettings().setPluginsEnabled(true);
ViewContent(raw);
InputStream fileStream = getResources().openRawResource(R.raw.test);
int fileLen = fileStream.available();
byte[] fileBuffer = new byte[fileLen];
fileStream.read(fileBuffer);
fileStream.close();
String displayText = new String(fileBuffer);
vWebview.loadDataWithBaseURL("fake://not/needed", displayText, "text/html", "utf-8", "");
and this is
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Hello World</title>
<body>
<div>
<p>
<video src="file:///android_asset/test.m4v" poster="file:///android_asset/test.jpg" onclick="this.play();"/>
</p>
</div>
</body>
</html>
相关推荐
最新文章