'html5 video tag not working in android phonegap

I have created application in android phonegap.I want to play video using html5 video player. My code is:

<!DOCTYPE html>
<html>
    <head>
      <title>Video.js | HTML5 Video Player</title>
      <link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet" type="text/css"> 
      <script src="http://vjs.zencdn.net/c/video.js"></script>
    </head>
    <body>
      <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264" poster="http://video-js.zencoder.com/oceans-clip.png" data-setup='{"controls":true}'>
        <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
        <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
        <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
      </video>
    </body>
</html> 

This code show the videoplayer .but video is not playing while clicking play button.what's wrong? please guide me. thanks in advance.



Solution 1:[1]

In addition to what ghostCoder says below (adding a click handler to play the video which you need to do for Android) also try removing type='video/mp4' as this sometimes confuses Android.

Solution 2:[2]

When you use Video tag for playing video in phonegap app,it works well on iphone but not on android.

Solution 3:[3]

Add android:hardwareAccelerated="true" as a child in your activity manifest file. It plays html5 video inside webviews without any workaround.

eg

<activity
    android:name="com.example.MainActivity"
    android:hardwareAccelerated="true"
    android:configChanges="keyboardHidden|orientation|screenSize" >
    ...
</activity>

Solution 4:[4]

You said it didn't worked on emulator, right? Don't you think video isn't being reproduced mainly because on Android SDK emulator you probably don't have any hardware acceleration for it? Some things don't work properly (sometimes don't work at all) if you don't have HW acceleration and a device powerful enough for that.

If that's the case, a workaround is using videos in 3GP format. That should work Android SDK emulator, and on older Android-powered cellphones with weak hardware. I used that on a project of mine.

Solution 5:[5]

try something like this

var video = document.getElementById('video');
video.addEventListener('click',function(){
  video.play();
},false);

Solution 6:[6]

Are you sure you video stream is 'H.264' and audio stream id 'AAC' for MP4. Because I guess Android support MP4

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ian Devlin
Solution 2 Fostah
Solution 3 Ramanan
Solution 4
Solution 5 ghostCoder
Solution 6 Tarun