Vimeo player pause another video when you play any video

喜夏-厌秋 提交于 2019-12-13 02:38:05

问题


I have 2 Vimeo players in my page when I play the first video then play second video first one gets paused.

var vid1=new Vimeo.Player($('.one'));
var vid2=new Vimeo.Player($('.two'));
$('.btnonePlay').on('click',function(){
    vid1.play();
})
$('.btnonePause').on('click',function(){
    vid1.pause();
})
$('.btntwoPlay').on('click',function(){
    vid2.play();
})
$('.btntwoPause').on('click',function(){
    vid2.pause();
})

Steps on how to reproduce the issue:

  1. Click on play video one
  2. Click on play video two

Player one will pause when the 'play video two' button is clicked.

Working example on jsFiddle.

The entire code is also in the snippet below.

var vid1 = new Vimeo.Player($('.one'));
var vid2 = new Vimeo.Player($('.two'));
$('.btnonePlay').on('click', function() {
  vid1.play();
})
$('.btnonePause').on('click', function() {
  vid1.pause();
})
$('.btntwoPlay').on('click', function() {
  vid2.play();
})
$('.btntwoPause').on('click', function() {
  vid2.pause();
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="one">
  <iframe src="https://player.vimeo.com/video/286183716" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  <p><a href="https://vimeo.com/286183716">Annihilation Song | Rubblebucket (Official Music Video)</a> from <a href="https://vimeo.com/amandabonaiuto">Amanda Bonaiuto</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
</div>
<button class="btnonePlay"> Play video one</button>
<button class="btnonePause"> Pause video one</button>

<div class="two">
  <iframe src="https://player.vimeo.com/video/286183716" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  <p><a href="https://vimeo.com/286183716">Annihilation Song | Rubblebucket (Official Music Video)</a> from <a href="https://vimeo.com/amandabonaiuto">Amanda Bonaiuto</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
</div>
<button class="btntwoPlay"> Play video two</button>
<button class="btntwoPause"> Pause video two</button>

回答1:


By default on our Vimeo videos we enable autopause. Autopause is when one video automatically pauses when another starts playing. Most people do not want two videos playing at the same time.

However, if you do want that you can turn off autopause by using the embed parameter attached to the url ?autopause=0. I have adjusted your jsfiddle to work accordingly. Working JSFiddle!

You can learn more about the available embed parameters from our API readme or this help article.



来源:https://stackoverflow.com/questions/52070737/vimeo-player-pause-another-video-when-you-play-any-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!