Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

jwplayer breaks .each loop?


If i get rid of jwplayer the .each loop works correctly, however with it in, the logs are incorrect. Is there a good way to loop through a dom like below to instantiate multiple jwplayers?

Any help would be great.
Regards
John

HTML ----

<div id=''
class="videoHeader"
data-video="/videos/video1.mp4"
data-image="/images/image1.jpg"
></div>

<div id=''
class="videoHeader"
data-video="/videos/video2.mp4"
data-image="/images/image2.jpg"
></div>

HTML END ----

JS ---

function init_video_headers($,jwplayer){

var headers = $(".videoHeader");
if(!headers.length){
return;
}

headers.each(function(i,d){

var el = $(d);

if(!el.hasClass('initiated')){

el.addClass('initiated');
var newid = "video-header-"+i;
el.attr('id',newid);

var videoUrl = el.attr("data-video"),
imgUrl = el.attr("data-image");

if(videoUrl){
console.log('id to input '+newid) // This outputs correctly if jwplayer is not included?
jwplayer(newid).setup({
file: videoUrl,
image: imgUrl,
skin : {
name:"helia"
}
}).on("ready", function(){
console.log("video ready");
});
}
}
});
}

JS END ---




1 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi, there.

Normally, we cannot provide support for custom JavaScript, but I definitely have no issues trying to help. Do you have a link to where this player is embedded? I would need to see it in action to see what is going on.

Thanks in advance.

This question has received the maximum number of answers.