cdy51223
cdy51223

Reputation: 1

How to use Html5's video tag in Android with PhoneGap framework

According:

HTML5 <video> element on Android

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var video = document.getElementById('video');
video.addEventListener('click',function(){
 video.play();
},false);
</script>
</head>
<body>
<video id="video" autobuffer height="240" width="360">
<source src="BigBuck.m4v">
<source src="BigBuck.webm" type="video/webm">
<source src="BigBuck.theora.ogv" type="video/ogg">
</video>
</body>
</html>

Is this right, Can you give me a full sample?

Upvotes: 0

Views: 4339

Answers (2)

dearwish
dearwish

Reputation: 181

The HTML5 video tag is not supported on Android devices, because it doesn't work in Android's WebView. On my Android 3.2 tablet device, the video tag is working well in a regular Chrome browser, but gives the folowing error when I try to run the same application wrapped by PhoneGap and I can hear only the sound (Video is not diplayed):

call to OpenGL ES API with no current context

You can find a discussion about this problem here: http://comments.gmane.org/gmane.comp.handhelds.phonegap/19275

The current solution for this issue is to play the video using native Android media player (through VideoView). There are several open source PhoneGap plugins that can help you with this.

Please let me know if you need more information about this.

Upvotes: 2

Stu Thompson
Stu Thompson

Reputation: 38908

Three things to check:

  • Does it work on your PC's browser? (And are you sure the browser supports HTML5?)
  • Is the source video in the same directory as the .html file? Your references are relative so this is important.
  • Do the videos themselves play correctly? The encoding of media files can be tricky.

Upvotes: 0

Related Questions