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

Ad Vast After Player Instance Setup?


I have a javascript function that can tell of a visitor is using adblocker. If that is the case, I want to add a VAST ad to the player.

Is there way to attach the "advertising" macros after the ".setup" process? If there is another way to do this, feedback appreciated.

Cheers
Ryan

25 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi, Ryan.

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.

There is a way to fire an ad at a specific moment via the .playAd() method. You would still have to set the client configuration option in your setup, but you can leave out any ad tags from that initial configuration. Then you can use playerInstance.playAd(“vasttag”) to play an ad. You can see more information on our JavaScript API Reference.

Please let me know if you need any more help or have any other questions.

Thank you!

contact

User  
0 rated :

I just saw you guys have your own AdBlock verification. So would it be possible to use the two together?

.on('adBlock') , what exactly does this do? Just opens up the option for me to create a function if the user is runnign adBlock, or does this do something automatically (like ask the user to disable their adblock)?

playerInstance.on('adBlock',function(){
playerInstance.playAd(“http://www.myvasttag.com/vast”);
});

Something like that?

Or, should it be more like...

playerInstance.on('adBlock',function(){
adblocker = true;
})

playerInstance.on('beforePlay',function(){
if(adblocker == true){
playerInstance.playAd(“http://www.myvasttag.com/vast”);
}
});

Feedback appreciated.

Cheers!
Ryan

contact

User  
0 rated :

Actually, I didn't realize that AdBlock was capable of blocking pre-rolls as well. Hmmm. Need to rethink this.

Cheers!
Ryan

ARTE GEIE Sandrine Weimer

User  
0 rated :

Hi there, it seems that calling playing playAd() function in the beforePlay event listener doesn't work anymore in jwplayer 7.3.4.

Are you aware of this bug ? It was working perfectly with 7.2 version

Alex

JW Player Support Agent  
0 rated :

Ryan – An ad blocking extension may block any type of ad, pre-roll or not. And the most popular use case for .on(“adBlock”) is to display some text to the user if they have an ad blocking extension installed.

Sandrine – I just tested this in 7.3.4 and 7.3.5, and it’s working just fine. Here is a link to my test page: http://qa.jwplayer.com/~abussey/demos/mar2016/77009-playad.html

Thank you.

Thibaut

User  
0 rated :

Thank you for your answer, it works, my bad :)

I have noticed another problem : if you call playAd() in the beforePlay eventListener, than the quality selector is never displayed and the levels event also never triggered

Alex

JW Player Support Agent  
0 rated :

Hi, Thibaut.

Can you supply me with a reproduction page showing it not working? I was able to get everything working on this page: http://qa.jwplayer.com/~abussey/demos/apr2016/77009-beforeplay.html

Please let me know if you need any more help or have any other questions.

Thank you!

Thibaut LION

User  
0 rated :

Hi thank your for answering,

your link doesn't work (timeout)

You can see it live here (flash enabled needed)

http://player-v3-dev.arte.tv/index.php?json_url=https://api.arte.tv/api/player/v1/config/fr/057414-002-A?platform=ARTEPLUS7&autostart=1&config=arte_tvguide

protocol is rtmp multiple qualities set in smil file here

http://player-v3-dev.arte.tv/webservices/playlist.smil?smilSources=%5B%7B%22url%22%3A%22am%2Ftvguide%2FSAT%2F057414-002-A_MQ_2_VOF-STF_02301244_MP4-300_AMM-Tvguide.mp4%22%2C%22streamer%22%3A%22rtmp%3A%2F%2Fcp363648.edgefcs.net%2Fondemand%2F%22%2C%22width%22%3A384%2C%22height%22%3A216%2C%22bitrate%22%3A300%7D%2C%7B%22url%22%3A%22am%2Ftvguide%2FSAT%2F057414-002-A_EQ_2_VOF-STF_02301246_MP4-1500_AMM-Tvguide.mp4%22%2C%22streamer%22%3A%22rtmp%3A%2F%2Fcp363648.edgefcs.net%2Fondemand%2F%22%2C%22width%22%3A720%2C%22height%22%3A406%2C%22bitrate%22%3A1500%7D%2C%7B%22url%22%3A%22am%2Ftvguide%2FSAT%2F057414-002-A_SQ_2_VOF-STF_02301251_MP4-2200_AMM-Tvguide.mp4%22%2C%22streamer%22%3A%22rtmp%3A%2F%2Fcp363648.edgefcs.net%2Fondemand%2F%22%2C%22width%22%3A1280%2C%22height%22%3A720%2C%22bitrate%22%3A2200%7D%5D&type=vod)

The problem appears only with rtmp or hls, not with mp4, I guess this is due to the fact that the quality list is not rendered in the dom at the same moment, as the qualities are coming from some metas or parsed manifest file, and not set directly with playlist object when instantiating the player (just like I do with mp4 files).

We don't want to play the ad into the "levels" event, as we think this is not the right place to do that (as you also say in the documentation).

Alex

JW Player Support Agent  
0 rated :

Hi, there.

The links I provided are working for me, I’m not sure why they weren’t working for you but you can try again. I replaced the source with yours and everything is still working for me.

Thibaut LION

User  
0 rated :

Hi Alex,

Thanks for having tested it.
Did you have a preroll before the video and a quality selector then ?

Your link still doesn't work, it failed on a timeout :(

Thibaut LION

User  
0 rated :

Hi Alex,

Thanks for having tested it.
The link actually work in http, https failed.

Anyway I tried your link and it works you're right but I think I have now found the problem.
I tried my player with the same config as you : that means autostart, playAd() in beforePlay() and it works also for me with my smil and my vast url.
Now try autostart:false, and use play() function to launch the video, then you will have the bug.

Thank you to give me your feedback about that.

Thibaut LION

User  
0 rated :

autostart:false

sorry for the misspelling

Thibaut LION

User  
0 rated :

sorry forget previous message

Thibaut LION

User  
0 rated :

Hi there, any news ?

Thank you !

Alex

JW Player Support Agent  
0 rated :

Hi, there.

Sorry about the delay – not sure why I wasn’t notified of your response.

I think I know what you’re getting out now. You’re seeing the ad not play if you are starting the player with .play(), correct? If so, that is what I’m seeing now too. If correct, do you mind me asking what the use case would be with starting the player with .play() instead of setting autostart: true? I have no problem escalating this to our Engineers but would need to have a reasoning behind setting up the player this way.

Thank you!

Thibaut LION

User  
0 rated :

Hi,

the player is setting up this way because we have a bunch of tests to execute before beeing sure to authorize a user to play a video.
It's for us the best solution as we want the player at this test phase to be instantiated, so the autostart true configuration for us is an absolute no way.

I guess using a normal option like autostart:faLse, then a normal function after player is ready like play() is not a non best-practice, so we can reasonably consider that as a bug.

It would be nice if you could escalating the problem to the dev team.

Thank you very much !

Alex

JW Player Support Agent  
0 rated :

If you are running various logic to determine if a user is authorized the view the content, then you wouldn’t be using .play() within a .on(“ready”) event, would you? Correct me if I’m wrong but I would think you would use .play() once you find out if the user is authorized, not once the player is finished setting up. Please let me know if I’m not understanding you correctly.

Thibaut LION

User  
0 rated :

Hi Alex,

For some business logic reasons some tests has to be runned after the player is ready.
After all, the problem is not why am I making these tests here or there, but why is the level event not triggered in an non-autostart situation with an ad.

Thank you

Alex

JW Player Support Agent  
0 rated :

The original link you supplied is now saying the video is no longer available. Can you supply another link please?

Thibaut LION

User  
0 rated :

Hi,

here is a fresh one

http://player-v3-dev.arte.tv/index.php?json_url=https://api.arte.tv/api/player/v1/config/fr/046358-010-A?platform=ARTEPLUS7&autostart=1&config=arte_tvguide

Alex

JW Player Support Agent  
0 rated :

OK, I was finally able to reproduce your issue. What I was missing was the fact that you were wrapping your .playAd() method in a setTimeout. It does look like it’s only happening when the player is in Flash, however. I’ll add this issue to the backlog and it’ll be taken care of based on priority. You can keep an eye on our JW 7 Release Notes page as we post release notes and bug fixes with every new update.

Please let me know if you need any more help or have any other questions.

Thank you!

Thibaut LION

User  
0 rated :

Hi Alex,

nice you finally got it ! Thanks you to have escalated it.

Have a nice day

Thibaut

Alex

JW Player Support Agent  
0 rated :

Hi Thibaut,

One of the Product Managers has filed this as a bug, but admits it will be on the backlog since it is a very specific use case. However, he did fine that firing .playAd() within .on(‘firstFrame’) will cause the levels to be recognized and the ad will play normally. I have updated the configuration of the player on the demo page with this method.

Please let me know if you need any more help or have any other questions.

Thank you!

n...

User  
0 rated :

Hi Alex,

Thank you for the feedback. Could you give me the link to the ticket in order for me to follow its state ?

Bye!

Alex

JW Player Support Agent  
0 rated :

Hi there,

Our issue/bug tracking system is only accessible internally, unfortunately.

This question has received the maximum number of answers.