当您播放任何视频时,Vimeo播放器会暂停另一个视频 [英] Vimeo player pause another video when you play any video
问题描述
当我播放第一个视频然后播放第二个视频时,我的页面上有2个Vimeo播放器.
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:
- 点击一个播放视频
- 点击两个播放视频
点击播放视频二" 按钮时,播放器一会暂停.
Player one will pause when the 'play video two' button is clicked.
整个代码也位于下面的代码段中.
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>
推荐答案
默认情况下,我们在Vimeo视频上启用autopause
.自动暂停是指当一个视频开始播放时自动暂停的时间.大多数人不希望同时播放两个视频.
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.
但是,如果您确实希望通过使用附加在URL ?autopause=0
上的embed参数可以关闭自动暂停.我已经对您的jsfiddle进行了相应的调整. 正在使用JSFiddle!
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!
您可以从我们的 API自述文件中了解更多有关可用嵌入参数的信息.这篇帮助文章.
You can learn more about the available embed parameters from our API readme or this help article.
这篇关于当您播放任何视频时,Vimeo播放器会暂停另一个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!