Video won't play in Android web browser

I am uploading html page to assets folder on android website, there is video in html pages. But the video doesn't play, here I am sharing the code.

   <!doctype html>
   <head>
   <title></title>
   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
   <script type="text/javascript" charset="utf-8" src="video.js"></script> 
   <script>
    function en(){
video1.play();
   }
   </script>
   </head>
   <body>
   <div id="t2" width ="1024" height="768" style="background-     image:url(images/L6_P007.jpg); background-repeat:no-repeat;">
    <video id="video1" width="1024" height="768" poster="images/L6_P007.jpg" controls  autoplay onended="en();" >
    <source src="videos/L6_P007.mp4" type="video/mp4">
    <source src="videos/L6_P007.ogv" type="video/ogg">
    <source src="videos/L6_P007.webm" type="video/webm">

    </video>
    </div>
    </body>
    </html>

      

This is my java code

    WebView webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setPluginState(WebSettings.PluginState.ON_DEMAND);
    webview.loadUrl("file:///android_asset/videosamp/videosamp.html");

      

+3


source to share


1 answer


this question has been discussed many times on SO. check answers to similar question here get VideoPlayer Plugin for Android.

The video player allows you to display videos from the PhoneGap app.

This command triggers an intent for your device's video devices to show video.

Adding a Plugin to Your Project This plugin requires Android PhoneGap.

To install the plugin, move www / video to your www project folder and include a link to it in your html file after phonegap.js.

Create a directory in your project called "src / com / phonegap / plugins / video" and move VideoPlayer.java into it.



In your file res/xml/plugins.xml

add the following line:

<plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>

      

Using a plugin The plugin creates a window.plugins.videoPlayer object. To use, call the play () method:

/ ** * Display the video playback intent. * * @param url url of the game * / play (url) Example usage:

window.plugins.videoPlayer.play("http://path.to.my/video.mp4");
window.plugins.videoPlayer.play("file:///path/to/my/video.mp4");
window.plugins.videoPlayer.play("file:///android_asset/www/path/to/my/video.mp4");
window.plugins.videoPlayer.play("https://www.youtube.com/watch?v=en_sVVjWFKk");

      

Note. When playing a video from a folder with assets, the video is first copied to internal storage using MODE_WORLD_READABLE.

+2


source







All Articles