nida
nida

Reputation: 656

html5 video tag failed to play .mp4 videos in phonegap android with cordova 2.9.0 and jquery1.9.0 ?

i am trying to play local video files already added in my project path : ASSETS/WWW/VIDEOS/xyz.mp4 now using tag but getting alert: errror on playing video

i have added code in HTML:

<!DOCTYPE html>
   <html>
    <head>
    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <body>
    <div data-role="page" data-theme="a" class="my-page" id="video">
                <video id="video_player" src="#" controls="controls"></video>
           </div>
    </body>
</html>
**in js:**


 $(document).on('pagebeforeshow',"#video", function () {
            xyz = document.getElementById('video_player');
            alert("values xyz:" + xyz);
            xyz.src = data[curYear].video.url;
           alert("xyz after src:" +  xyz.src);
            xyz.play();
            });

image of 1st alert

 image of 2nd alert

Upvotes: 1

Views: 4333

Answers (1)

Amit Prajapati
Amit Prajapati

Reputation: 14315

Try this..

<video class="video" poster="/assets/video/posters/example.jpg" controls width="768" height="432" preload="none">
    <source src="/assets/video/example.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
    <source src="/assets/video/example.ogv" type='video/ogg; codecs="theora, vorbis"' />
</video>

Upvotes: 1

Related Questions