Video not playing in android webview -
i loading html page in asset folder android webview, html pages has video. video not playing, here share 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 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");
this issue discussed many times on so. check answers similar question here videoplayer plugin android here.
the video player allows display videos phonegap application.
this command fires intent have devices video player show video.
adding plugin project using plugin requires android phonegap.
to install plugin, move www/video project's www folder , include reference in html file after phonegap.js.
create directory within project called "src/com/phonegap/plugins/video" , move videoplayer.java it.
in res/xml/plugins.xml
file add together next line:
<plugin name="videoplayer" value="com.phonegap.plugins.video.videoplayer"/>
using plugin plugin creates object window.plugins.videoplayer. use, phone call play() method:
/** * display intent play video. * * @param url url play */ play(url) sample use:
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 video assets folder, video first copied internal storage mode_world_readable.
android android-webview
No comments:
Post a Comment