在页面上发现多个jwplayer [英] Discover multiple jwplayers on a page

查看:87
本文介绍了在页面上发现多个jwplayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一些javascript代码,这些代码将遍历页面上所有可用的jwplayers.

I need to write some javascript code which will loop through all jwplayers available on a page.

jwplayer api具有功能selectPlayer():

The jwplayer api has a function selectPlayer():

var player = jwplayer.api.selectPlayer();

但这只会返回页面上的第一个播放器.我看不到找到全部的方法吗?

But this only returns the first player on the page. I can't see a way to find them all?

推荐答案

有几种方法可以做到这一点,但是最简单的方法是调用"jwplayer( x )"-其中 x 是与页面上的jwplayers数组相关的从零开始的索引-因为它将返回该索引处的Player实例.

There are a few ways to do this, but the simplest would be to call "jwplayer(x)" - where x is a zero-based index relating to an Array of jwplayers on the page - as this will return the Player instance at that index.

因此,对于JW7/JW8,您可以简单地执行以下操作:

So for JW7 / JW8 you could simply do the following:

var jwpAll = document.querySelectorAll('.jwplayer');
for(var jwpIndex=0,jwpTotal=jwpAll.length;jwpIndex<jwpTotal;jwpIndex++){
    var player = jwplayer(jwpIndex);
}

这篇关于在页面上发现多个jwplayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆