我觉得有点傻,因为这看起来很简单,但我有这样嵌入的vimeo视频:
<iframe id="video" src="https://player.vimeo.com/video/139326546?api=1" width="500" height="375" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
页面上没有其他视频或iframe。我尝试以这种方式启动视频:
document.addEventListener("DOMContentLoaded", function(event) {
var iframe = document.getElementById('video');
var player = $f(iframe);
player.api("play");
});
什么都没发生。当然,我在页面的头部引用了froogaloop。我没有使用jquery。据我所知,froogaloop应该独立工作。
答案 0 :(得分:3)
您似乎尝试在视频准备就绪之前播放视频。我建议您在致电ready
之前先听取player.api()
事件:
var player = $f(iframe);
// Play the video as soon as it's ready
player.addEvent('ready', function() {
player.api('play');
});