Reputation: 5317
I feel a bit silly, because this seems so simple, but I have a vimeo video embedded this way:
<iframe id="video" src="https://player.vimeo.com/video/139326546?api=1" width="500" height="375" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
There are no other videos or iframes on the page. I try to start the video this way:
document.addEventListener("DOMContentLoaded", function(event) {
var iframe = document.getElementById('video');
var player = $f(iframe);
player.api("play");
});
Nothing happens. Of course I referenced froogaloop in the head of the page. I don't use jquery. As far as I understood, froogaloop should work on its own.
Upvotes: 0
Views: 137
Reputation: 2786
It appears that you are attempting to play the video before it is ready. I would suggest that you listen for the ready
event before calling player.api()
:
var player = $f(iframe);
// Play the video as soon as it's ready
player.addEvent('ready', function() {
player.api('play');
});
Upvotes: 3