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

Javascript API - beforePlay event not working properly


According to this doc:
https://support.jwplayer.com/customer/portal/articles/1413089-javascript-api-reference#advertising

.on('beforePlay')
Fired just before the player begins playing. Unlike the onPlay event, the player will not have begun playing or buffering when triggered, which makes this the right moment to insert preroll ads using playAd(). It has no event attributes.

'beforePlay' event should play a preroll ad.

Here is my test page: http://sandbox.ht.indexexchange.com/ht/webmirrors/ApartmentTherapy/www.apartmenttherapy.com/beforePlayIssue.html

It does play a preroll ad. But every time I pause the video and resume, the ad is also playing.

Could you tell me what goes wrong? How could I make the preroll ad work?

Thanks!

Jim

1 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi, Jim.

My name is Alex and I am one of the Support Engineers at JW Player. I will be more than happy to assist you with your questions.

It is true that .on(“beforePlay”) does fire every time the player enters a “playing” state, regardless if it was just paused or not. Is there any reason why you are not adding your pre-roll in the embed code itself?

Thank you.

This question has received the maximum number of answers.