gpt4 book ai didi

javascript - jwplayer js api事件获取玩家索引

转载 作者:行者123 更新时间:2023-11-28 01:58:14 33 4
gpt4 key购买 nike

我面对 jwplayer api,我想获取一些事件,但我的页面中将有多个玩家,因此当我获取事件时,我需要知道哪个玩家正在触发该事件。

类似 youtube api 的功能:

    function onPlayerReady(event) {
n = event.target.id - 1; //The index of the player which fire the event
}

但在 jwplayer 中我不知道该怎么做:

//PARA TODOS LOS REPRODUCTORES
for (var i = 0; i < videos.length; i++) {
var id = videos[i];
jwplayer(id).setup({
file: "http://content.bitsontherun.com/videos/lWMJeVvV-364767.mp4",
events: {
onReady: function(ev) {
alert('ha iniciado el reproductor '+INDEX OF THE PLAYER WHICH FIRE THE EVENT);
},
onComplete: function(ev) {
alert('ha finalizando el reproductor '+INDEX OF THE PLAYER WHICH FIRE THE EVENT);
}
}
});
}

最佳答案

您可以通过这种方式保存您想要的任何内容:

for (var i = 0; i < videos.length; i++) {
var id = videos[i];
jwplayer(id).setup({
file: "http://content.bitsontherun.com/videos/lWMJeVvV-364767.mp4",
my_var: videos[i], /*WHATEVER YOU WANT AS A VARIABLE OF THE PLAYER*/
events: {
onReady: function(ev) {
alert('ha iniciado el reproductor '+this.config.my_var);
},
onComplete: function(ev) {
alert('ha finalizando el reproductor '+this.config.my_var);
}
}
});
}

关于javascript - jwplayer js api事件获取玩家索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18786007/

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