如何在jwplayer api中获取函数来循环遍历数组的多个对象?例如:
myArray = 'video1', 'video2', 'video3';
//jwplayer api functions
jwplayer().getPosition() and jwplayer().getDuration()
//currently I achieve this by pass an object one at a time like so,
jwplayer(video2).onPlay(function(event){
_satellite.track("videostart");
var q = $(".sliderkit-selected a").attr('title'),
t = jwplayer(video2).getPosition(),
u = jwplayer(video2).getDuration(),
initialPos = "-_--_--_--_--_--_--_--_--_--_--_--_-2-_-" + t + '-_-' + u,
mm = 'Video : ' + _satellite.getVar('Page ID'),
attr = cmAttributes(_satellite.getVar('cmAttr'));
cmCreateElementTag(q,mm,initialPos, attr);
});
我原本写了一个for循环,它只会在jwplayer.onPlay()函数中返回正确的视频,同时为每个视频选择的getPosition和getDuration传递视频1的值。低于t和u的变量是如何将coremtrics集成到adobe dtm的函数,所以请忽略它。
答案 0 :(得分:0)
循环浏览myArray
:
myArray = ['video1', 'video2', 'video3'];
$.each(myArray, function(index, value) {
...
});