davatron5000 / FitVids.js

A lightweight, easy-to-use jQuery plugin for fluid width video embeds.
http://fitvidsjs.com
4.77k stars 986 forks source link

Vimeo player API .on(seeked) and .on(timeupdate) give CORS error #255

Open verygoodplugins opened 6 years ago

verygoodplugins commented 6 years ago

After Fitvids is initialized on a Vimeo player, setting .on('seeked') or .on('timeupdate') gives a CORS error.

I'm assuming this is because if the player is initialized on a #video-container element, and iframe is inserted, then future attempts to access the player fail because the immediate child of #video-container is no longer the iframe, but the .fluid-with-video-wrapper element.

I fixed this by changing line 77 to:

$this.parent().addClass('fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');

This probably can't be included in fitvids.js as it only works if the video container doesn't already have additional styling applied, but if anyone is getting errors trying to use the Vimeo player API with FitVids, this fix might help.