Reputation: 21934
I have a vimeo video that loads when the user clicks on a div.
<div class="vimeobox" ID="vimeo-ID-goes-here"></div>
Here is my javascript:
$(".vimeobox").click(function() {
var iframe = "<iframe />";
var id = $(this).attr('id'); //
var url = "http://player.vimeo.com/video/" + id + "?title=0&byline=0&portrait=0&autoplay=1";
var width = 700;
var height = 394;
var frameborder = 0;
$(iframe, {
name: 'videoframe',
id: 'videoframe',
src: url,
width: width,
height: height,
frameborder: frameborder,
type: 'text/html',
allowfullscreen: true,
webkitAllowFullScreen: true,
mozallowfullscreen: true
}).css({'position': 'absolute', 'top': '0', 'left': '0'}).appendTo(this);
$(this).find('img').fadeOut(function() { $(this).remove();
});
});
The vimeo player appears when the div is clicked on (removing the preview image)...but the video does not autoplay.
I don't know what the issue is. I am using near-identical code for a youtube player (minus the url variable) and it autoplays?
Upvotes: 4
Views: 3534
Reputation: 11
You can also do this manually by adding the following parameters into your embed code: loop=1 autoplay=1 If you have more than one video autoplaying on a particular page, you will also need to include this parameter: autopause=0
Upvotes: 1
Reputation: 343
The other answers here are indeed correct BUT if your experiencing problems getting autoplay to function on mobile devices your out of luck as default AutoPlay functionality as described here will NOT WORK on mobile devices (Android/iOS and probably Windows Mobile) as of the time of this writing.
If anyone has figured out a hack to force autoplay to function please post.
Upvotes: 0