Reputation: 1860
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.
Upvotes: 3
Views: 12957
Reputation: 331
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.
Upvotes: 0
Reputation: 159
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>
Upvotes: 0
Reputation: 6839
When you use Video tag for playing video in phonegap app,it works well on iphone but not on android.
Upvotes: 0
Reputation: 18880
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.
Upvotes: 0
Reputation: 7655
try something like this
var video = document.getElementById('video');
video.addEventListener('click',function(){
video.play();
},false);
Upvotes: -1
Reputation: 1898
Are you sure you video stream is 'H.264' and audio stream id 'AAC' for MP4. Because I guess Android support MP4
Upvotes: -2