I am developing an android application using Cordova. I used HTML <video> Tag for a background video. The Video works like a charm for Lollipop OS. But it doesn't work for Kitkat 4.4.4. I have tried all formats of video(mp4, webm, ogg). It gives me a black screen background. The poster which I am setting just in case video doesn't work is not getting displayed either.

<video autoplay loop poster="images/landing.jpg" id="bgvid">
    <source src="videos/small.ogg" type="video/ogg">
    <source src="videos/small.webm" type="video/webm">
    <source src="videos/small.mp4" type="video/mp4">
</video>

Is there any alternative to this? How to make the video work as background for majority of Android OS.

1

There are 1 answers

0
Elena Flecha On

You can use the plugin Html5Video

cordova plugin add https://github.com/jaeger25/Html5Video.git

HTML:

    <video id="videoID" loop>
    </video>

JAVASCRIPT (When cordova is initialized):

    window.plugins.html5Video.initialize({
          "videoID" : "video.mp4"
      }, function () {
      window.plugins.html5Video.play("videoID")
    });

ANDROID PROJECT:

    Created a folder called raw on platforms\android\res\raw
    Moved the video to platforms\android\res\raw\video.mp4