HTML5 video in WebView on Samsung S4 (Android 4.4.2) issue -


On my Samsung S4 + Android 4.4.2, my phonegap 3.3 app has a strange eagerness to play embedded video games in video tags. there is a problem.

I have the following HTML code:

  & lt; Video id = 'myvideo' autoplay = 1 preload = 'auto' & gt; & Lt; / Video & gt;  

Videos begin with Javascript (with jQuery):

  $ ('# myvideo'). Attr ('src', 'http: // ... jpg'); $ ('#myvideo') Attri ('Poster', 'http: //...mp4'); $ ('# MyVideo') [0] .play ();  

The video does not start as expected.

The problem appears only after upgrading from Android 4.2 to Android 4.4.2. This problem does not exist on other smartphones running Android 4.4.2 (like Nexus 4, 5).

Add this setting to your webview settings

  webSettings.setMediaPlaybackRequiresUserGesture (wrong);  

Here is my JS code and loop to play video automatically (You can remove this part if you want to play it only once

 < Code> // Here my video tag is my code for my myvideo = document.getElementsByTagName ('video') [0]; // if there is a video tag (this JS is in a different JS file) We play the video (Typef MyVideo! == "undefined") {// setInterval allows me to monitor every 40 milliseconds if weed Whether it's ending or not, if we loop the truthful video and set it back to interval (function () (if (myVideo.readyState! = 0) {if (myVideoPaused) {myVideo.currentTime = 0 ; MyVideo.play ();}}}, 40)}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -