3

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.

Mercy
  • 1,862
  • 9
  • 39
  • 75
  • http://www.broken-links.com/2010/07/08/making-html5-video-work-on-android-phones/ – ghostCoder Mar 15 '12 at 09:15
  • see http://stackoverflow.com/questions/9094848/how-to-pass-the-value-to-html5-video-tag-src-attribute-in-android-phonegap-using – gmh04 Mar 15 '12 at 09:56
  • I use this link videojs.com for creating videoplayer in android phonegap. video player is created successfully.but video is not played.It;s work fine in browser,but not in emulator. how to solve this problem.please guide me.it's urgent.thanks in advance .Iwant to play youtube video using that player – Mercy Mar 15 '12 at 10:04

6 Answers6

0

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.

0

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.

Ian Devlin
  • 18,534
  • 6
  • 55
  • 73
0

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>
Ramanan
  • 159
  • 1
  • 11
0

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

Fostah
  • 2,947
  • 4
  • 56
  • 78
Neji
  • 6,591
  • 5
  • 43
  • 66
  • The repository you linked above has been deprecated. How was this plugin different from the HTML5 tag? – Fostah May 01 '14 at 16:35
-1

try something like this

var video = document.getElementById('video');
video.addEventListener('click',function(){
  video.play();
},false);
ghostCoder
  • 1
  • 9
  • 49
  • 72
-2

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

Tarun
  • 1,888
  • 3
  • 18
  • 30
  • thanks for your reply.I want to play you tube video using html5 video player under the Android phonegap – Mercy Mar 15 '12 at 09:45
  • Buddy i don't have Android for testing and RND, But I really interested in your question. Can you please test it after remove OGV from your video tag? Test it with only MP4 one time or try http://banzodesign.com/angela/reel.html It's a website where I implement before HTML5 videos before. You can find code in javascript. And if you still not find any solution then let me know i'll find something tomorrow. – Tarun Mar 16 '12 at 04:57
  • @Tarun i have the same issue. not getting play in android –  May 03 '18 at 06:01