Vimeo播放器现在即使具有allow =“ autoplay”属性也可以播放,请检查jsfiddle控制台错误,单击小图标播放按钮:
https://jsfiddle.net/0vfLtdm8/
var player = document.getElementById('video-player');
var vimeoPlayer = new Vimeo.Player(player);
playbtn.onclick = function() {
vimeoPlayer.play();
}
vimeoPlayer.on('error', function(error) {
console.log(error);
});
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<script src="https://player.vimeo.com/api/player.js"></script>
<div id="video-outer-full">
<div id="video-inner">
<i class="far fa-play-circle" id="playbtn"></i>
<iframe id="video-player" class="video" width="560" height="315" src="https://player.vimeo.com/video/309741585" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen allow="autoplay"></iframe>
</div>
</div>
答案 0 :(得分:1)
@Toniq,这是特定于jsfiddle和类似于Codepen的服务的问题。
在这些测试页上,他们将用户定义的测试内容包装在iframe中,该iframe没有allow =“ autoplay”来阻止play()动作的发生。
Vimeo播放器iframe还必须具有allow =“ autoplay”属性。
您可以在api演示页面上看到,如果按右上角的自定义播放按钮,则不会出现此问题。