gpt4 book ai didi

jquery - 当一个 VideoJS 实例启动时,如何暂停页面上所有正在播放的 VideoJS 实例?

转载 作者:行者123 更新时间:2023-12-01 03:14:51 26 4
gpt4 key购买 nike

我现在想出了这个解决方案:

    var myPlayer1 = _V_("ID1");
var myPlayer2 = _V_("ID2");
...
...

var myFunc1 = function(){
var myPlayer1 = this;

myPlayer2.pause();
myPlayer3.pause();
myPlayer4.pause();
...
};
myPlayer1.on("play", myFunc1);

var myFunc2 = function(){
var myPlayer2 = this;

myPlayer1.pause();
myPlayer3.pause();
myPlayer4.pause();
...
};
myPlayer2.on("play", myFunc2);

...

还有其他明智的方法吗?

谢谢。

最佳答案

纯JS上也是如此:

var medias = Array.prototype.slice.apply(document.querySelectorAll('audio,video'));
medias.forEach(function(media) {
media.addEventListener('play', function(event) {
medias.forEach(function(media) {
if(event.target != media) media.pause();
});
});
});

关于jquery - 当一个 VideoJS 实例启动时,如何暂停页面上所有正在播放的 VideoJS 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17769051/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com