
Admessage: unwanted "Ad 1 of 1"
Hi,
I have customized the ad message into my language.
Since not long ago the player adds an "Ad 1 of 1" in front of this message.
How can I remove that? Or how can I translate this into my language?
Thanks,
Marc
Hi,
I have customized the ad message into my language.
Since not long ago the player adds an "Ad 1 of 1" in front of this message.
How can I remove that? Or how can I translate this into my language?
Thanks,
Marc
Are you using an ad pod tag? Does your ad tag have a sequence parameter?
We do not have built-in functionality to edit the “Ad 1 of 1” message, but you can potentially change this using CSS and Javascript on the page.
Hi Todd,
Pod Tag? This conveys nothing to me...
Here's my embedded ad code:
advertising: {
client: 'vast',
skipoffset: '0',
admessage: 'my text',
schedule: {
firstPreroll: {
offset: 'pre',
tag: (prerollVastUrl) ? prerollVastUrl+";ord=__timestamp__" : ""
}
}
}
CSS or JS? Can you give me a hint?
Thanks,
Marc
An ad pod is a single ad tag that returns multiple ads. This is usually what causes the “Ad 1 of 2” or “Ad 2 of 2” message in our player. Please see https://support.jwplayer.com/customer/en/portal/articles/1433722-vast3-ad-pods for more details.
Here is some sample code that will change that message. Please note that your getElementsByClassName query may return a different number of results…
<script>
jwplayer().on('adTime',function(){
document.getElementsByClassName('jw-text')[2].innerHTML = 'My custom message here...'
});
</script>
Hm, this doesn't work... Probably I'm doing sth. wrong.
Is there a documentation somewhere?
We do not have any documentation for document.getElementsByClassName() because this is a generic Javascript function, not one specific to our player.
What do you get when you do:
var test = document.getElementsByClassName('jw-text');
console.log(test);
in Chrome’s Javascript console?
I'm getting an "undefined"...
Are you trying this while the ad is playing? You might need to pause the ad first…
Can you post a link to a test page where you have added the jwplayer().on(‘adTime’,function(){}) ?
Ok, my mistake. The console says "Uncaught TypeError: jwplayer(...).on is not a function"
http://gearsofwar.xboxaktuell.de/videos.html
You are using JW6 on this page, but my first code example will only work in JW7 because I am using the .on() syntax introduced in JW7, as well as the JW7 CSS classes.
The correct code in JW6 would be:
<script>
jwplayer().onAdTime(function(){
document.getElementsByClassName('jwtext jwalt')[1].innerHTML = 'My custom message here...'
});
</script>
Hm, console says "Uncaught TypeError: jwplayer(...).onAdTime is not a function"...
It looks like the browser is calling jwplayer().onAdTime() before it has called jwplayer().setup. Add the onAdTime() call immediately after the end of your jwplayer().setup() in the same <script> tag, like this:
<script> jwplayer().setup({ file: '', etc });
jwplayer().onAdTime(); </script>
Hm, that's what I'm doing...
<script type='text/javascript'>
var fn = function(prerollVastUrl) {
jwplayer('my-video').setup({
image: 'image.jpg',
sources: [
{ file: "video1.mp4", label: "SD",
{ file: "video2.mp4", label: "HD"
],
width: '100%',
aspectratio: '16:9',
primary: 'html5',
autostart: false,
logo: {
file: 'logo.png',
position: 'top-left'
},
advertising: {
client: 'vast',
admessage: 'message',
schedule: {
firstPreroll: {
offset: 'pre',
tag: (prerollVastUrl) ? prerollVastUrl+";ord=__timestamp__" : ""
}
}
}
});
};
if (typeof(naMediaAd) == "undefined" || naMediaAd.includeAd("PREROLL", fn) === false) fn();
jwplayer().onAdTime(function(){
document.getElementsByClassName('jwtext jwalt')[1].innerHTML = 'My custom message here...'
});
</script>
Ahhh...
I've put the second script two rows above and it seems to work.
But now the remaining time isn't diplayed anymore... That's too bad.
onAdTime() returns an object that contains position and duration, so you could build your own countdown. Check out this sample code:
jwplayer().onAdTime(function(e){
document.getElementsByClassName('jwtext jwalt')[1].innerHTML = 'My custom message here...ad ends in '+Math.ceil(e.duration-e.position)+' seconds';
});
Hey Todd, thank you very much! Great support! :)
You’re welcome. I will mark this support case as closed, but certainly contact us again if you have any other support questions or concerns.
Ok, one last question... Really!
On one page I have integrated two players:
jwplayer('my-video').setup({...
jwplayer('my-video2').setup({...
With your code the message of the second player doesn't change. Can I fix this somehow?
jwplayer().onAdTime(function(e){} talks to the first player on the page. You need to use
jwplayer('my-video').onAdTime(function(e){}
jwplayer('my-video2').onAdTime(function(e){}
to talk to a specific player on the page.
You will also need to change document.getElementsByClassName(‘jwtext jwalt’)1 in the second function to
document.getElementsByClassName('jwtext jwalt')[2]
Yes, that's it! Thanks!
You’re welcome.