androidhtmlvideowebviewandroid-studio-2.0

Android WebView crashes trying to play .mp4 video via <video> tag


We have Android Studio 2.0 installed. Using android studio 2.0 we have created new application. Inside that application we added WebView. We try to open our webpage inside webview. Our webpage contains following video tag:

<video id="my_video" width="100%" height="100%" autoplay loop controls>
  <source src="http://img-9gag-fun.9cache.com/photo/a2mgB41_460sv.mp4" type="video/mp4"> 
  Your browser does not support the video tag.
</video>

<script type="text/javascript">  
  var video = document.getElementById("my_video");  
  video.loop = false; 
  video.addEventListener('ended', function() { 
      video.currentTime=0.00001; 
      video.play(); 
    }, false); 
</script>

If we run our application on emulator, load webpage in webview and start video via mouse click - it plays without any problem. But if we install our application on device, run it and then we click on video to play - whole application crashes. Also if we open our webpage via native device browser - it plays without any problem.

Our device is Rikomagic android mini pc, that runs Android KitKat-4.4.2.

What could be the cause of application crash on device after video click/start?

EDIT: The exact same .apk works on Galaxy Note 3 without any problem.


Solution

  • We contacted Rikomagic, they identified case as firmware dependent issue. We upgraded device from Android KitKat-4.4.2. to Android Lollipop 5.1.1 And the problem went away.