Android的web视图不打在同一个页面MP4视频 [英] Android webview doesn't playing mp4 video in same page

查看:150
本文介绍了Android的web视图不打在同一个页面MP4视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图展现一个本地的HTML文件中包含code播放视频,并尝试以显示Android的WebView中的HTML文件。

I'm trying to show one local html file contains code for playing video and try to show that html file in android webview.

我用下面的code为播放视频:

I've used following code to for playing video:

WebViewLoadVideoActivity.java

 //DECLARE webview variable outside of onCreate function so we can access it in other functions (menu)
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 WebView webView = (WebView) findViewById(R.id.webView1);
 WebSettings webSettings = webView.getSettings(); // Fetches the
 // WebSettings
 // import
 WebViewClient webViewClient = new WebViewClient();
 webView.setWebViewClient(webViewClient); // Enabling mp4
 webSettings.setPluginsEnabled(true); // Allows plugins to run which are
 // normally disabled in webView
 webView.getSettings().setBuiltInZoomControls(true); // Allows the
 // Android built in
 // zoom control
 webView.getSettings().setSaveFormData(true);
 webView.getSettings().setLoadsImagesAutomatically(true);
 webView.getSettings().setPluginsEnabled(true);
 webView.getSettings().setLoadsImagesAutomatically(true);
 webView.getSettings().setSupportMultipleWindows(true);
 webView.getSettings().setPluginsEnabled(true);
 webView.getSettings().setLightTouchEnabled(true);
 webView.getSettings().setAllowFileAccess(true); // To allow file
 // downloads/streams
 // such as mp4, mpeg,
 // and 3gp files
 webView.getSettings().setJavaScriptEnabled(true); // Enables HTML
 // Javascript to run
 // in webview
 webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
 webView.getSettings().setSupportZoom(true); // Support the zoom feature
 webView.getSettings().setSavePassword(true); // Allow users to save passwords in forms
  webView.setWebViewClient(new  WebViewClient() { // Opens web links clicked by user in the webview
  @Override
  public void onReceivedError(WebView view, int errorCode,
  String description, String failingUrl) { // Handle the error
  }

  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
  view.loadUrl(url);
  return true;
  }
  });
 webView.loadUrl("file:///android_asset/test.html"); // test.html file from assets folder
  //... Rest of activity code...

的test.html

<!DOCTYPE html>
<html>
<body>

<video width="320" height="240" controls="controls">
  <source src="http://www.w3schools.com/html/movie.mp4" type="video/mp4" />
  Your browser does not support the video tag.
</video>

</body>
</html>

问题区域:

Android的web视图或Android默认浏览器显示在另一个视频观看视频内容时,我们点击播放按钮,我的要求是,视频应该在同一个HTML网页内嵌被打开,因此用户可以将视频中浏览网页的其他网页播放或缓冲。

Problem Area :
Android webview or Android Default Browser shows the video content in another video view when we click play button, My requirement is that video should be opened in same html page inline, so user can navigate to other page of webpage during video is playing or buffering.

研究领域:

我试过很多其他方法一样,
HTML5的视频标签
HTML嵌入的标签
HTML的对象标记

Research Area :
I tried many other ways like, video tag of HTML5 embed tag of HTML object tag of HTML

的视频播放器整合其他的方式我检查所以在我的要求远但不工作的,

耀斑视频

jplayer

Other way of video player integration i checked so far but not worked in my requirement,
Flare Video
jplayer

请给我建议任何方式能适合我的要求,我的要求很简单,我想打在HTML文件中的视频在Android系统的WebView小部件的内联。

Please suggest me any way that can be suitable for my requirement, And my requirement is very simple as, I want to play video in html file as inline in webview widget of android.

先谢谢了。

推荐答案

您必须使用web视图Custome类播放MP4视频

You must have to use webView Custome class for playing mp4 video

这篇关于Android的web视图不打在同一个页面MP4视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆