I'm working on a website that contains two the same vimeo video's. One is for the larger screen resolutions for the < 1000px resolutions I want the video in another place. So I placed two of them in there, and with some CSS I controlled which of them is visible..
However, the videos need to get an autoplay on page load. While the display:none;
css tag it will only hide the vids and not pause/disable the video.
Is there a good way to control this? At the moment I'm trying to do this with jQuery and Froogaloops but have not been able to get it working yet. This is what I got so far:
jQuery(document).ready(function($) {
var player = $("#82625501");
froogaloop = $f(player[0].id);
// Optimalisation: Store the references outside the event handler:
var $window = $(window);
function checkWidth() {
var windowsize = $window.width();
if (windowsize < 1000) {
froogaloop.api('pause');
}
else {
froogaloop.api('play');
}
}
// Execute on load
checkWidth();
// Bind event listener
$(window).resize(checkWidth);
});
This works only if you resize the screen, not on first load. How to do this? Or maybe there is an easier way? Thanks in advance!