Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 video on iPad

Tags:

html

video

ipad

I have a dynamic video gallery and it works great on a computer. When moving to an iPad, the video starts loading and it shows the cannot play icon. Instead of this I'd rather the video not show until it's ready to play. I have tried to add events listeners for "canplaythrough" and "canplay" and when they occur for the video to fade in then play. Does the iPad not support these events?

new_video = document.createElement('video');
new_video.setAttribute('class', 'none');
new_video.setAttribute('width', '568');
new_video.setAttribute('height', '269');
new_video.setAttribute('id', 'video'+video_num);
current_video.insertBefore(new_video, video_controls);
new_video.load();
new_video.addEventListener('canplaythrough', function() {
     $('#video'+video_num').fadeIn(100);
     new_video.play();
});
like image 828
mrollinsiv Avatar asked May 25 '10 21:05

mrollinsiv


People also ask

Does HTML5 work on iOS?

iOS 5 also performed well in terms of HTML5 compatibility compared to desktop browsers, running slightly behind Mozilla's Firefox 7.1 and just ahead of Apple's desktop Safari 5.1.

Does Safari support HTML5 video?

Safari supports HTML5. If YouTube video doesn't play, try either disabling or uninstalling extensions like ClickToFlash.


1 Answers

The way to solve this visual problem is to hide the video element until it is ready to be played. Note that you cannot set display:none (video won't load if you do that) and visibility:hidden won't solve the issue either.

To fix it, wrap the video element on a DIV with overflow:hidden and set -webkit-transform:translateX(1024px) (a number high enough to push the video outside the screen).

Than you have to listen for the canplay or canplaythrough or load events (based on your need) and set the translateX to zero after that.

like image 138
Miller Medeiros Avatar answered Sep 21 '22 11:09

Miller Medeiros