Possible to disable autoplay of iframe YouTube video with @media?

Kevin

Well-known member
The lengthy title sums up what I am trying to do but, to clarify a bit, I have a template mod' that adds a YouTube video to an XF sidebar on a particular page. The video is set to autoplay. Using the @media definitions it is possible to turn off the display of the video but it still plays (because it is only suppressing the display of the content, not the inclusion of it).

Any thoughts on being able to disabling the auto-play when the content is suppressed and/or disabling the inclusion of the content altogether based upon the browser size? I've been searching around but finding a viable solution.
 
Have you tried setting an explicit width and height of 0 for the iframe?

<style type="text/css">
.iframe {
width: 800px;
}

<xen:if is="@enableResponsive">
@media (max-width:910px) {
.iframe {
width: 0px;
height: 0px
}
}
</xen:if>
</style>
 
Have you tried setting an explicit width and height of 0 for the iframe?
Thanks for the suggestion. I just gave it a try and while the 0-by-0 size suppresses the display it is still playing. I've got a funny feeling that to stop it the video from playing, or to completely disable the inclusion, I'll need some JS.
 
Oh, you actually want to stop it from playing too.
I misunderstood.

Presumably you've tried display:none ?

Failing that, xen:comment would work but I don't think that's available in the css templates.
 
Top Bottom