I am trying to use youtube video within a fancybox with responsive features such that it can adjust its dimensions according to the device for that i had used jquery.fancybox-media.js and it works well on desktop but video doesn't play on iPad .
Visit http://fancyapps.com/fancybox/ then clicking on Youtube(iframe) it only plays on desktop but not on iPad.
It uses jquery.fancybox-media.js
Since fancybox version 2.1.0 there is an
iframe
API option that allows you to preload the contents of an iframe; the default value istrue
.Unfortunately, since jQuery v1.9+ I have seen that this option somehow creates issues while trying to display
iframe
content, specifically with streamed media or PDF documents.As a workaround, I have been disabling the
iframe
preload and that has fixed many of the issues reported.Fancybox uses
iframe
type for youtube videos, but their homepage still uses the default value (true
), however in your own web pages, you should disable this option and your youtube videos will work in iPhone/iPad with no issue :This hrml for instance
... with this script
... should work just fine.
NOTE that the
autoplay=1
parameter doesn't work in mobile devices, so you still need toclick
on the video to start (which make sense to me since you may not want to waste your data plan unintentionally)See JSFIDDLE in iPad ;)
EDIT : if you don't want to have a fixed
iframe
size (responsiveness), then just get rid of the size options like :See updated JSFIDDLE in iPad