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

how to execute javascript afrer ned video?


Hi! How i can execute my own javascript after video end? i want execute test_myscrpt();

11 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

http://support.jwplayer.com/customer/portal/articles/1413089-javascript-api-reference

onComplete

mikhailtpm

User  
0 rated :

Thanks! But it don't work:( Can you help please? i add onComplete: 'test_myscrpt();', but it doesn't works. my code is:

<html>
<head>
<script src="http://jwpsrv.com/library/test.js"></script>
</head>
<body>

<div id='playertest'></div>
<div id='playertest'></div>
<script type='text/javascript'>
jwplayer('playertest').setup({
playlist: '//jwpsrv.com/feed/test.rss',
width: '100%',
aspectratio: '16:9',
onComplete: 'test_myscrpt();',
primary: 'flash'
});
</script>

</body>

</html>

ben1189

User  
0 rated :

Read the docs...
<html>
<head>
<script src="http://jwpsrv.com/library/test.js"></script>
</head>
<body>

<div id='playertest'></div>
<div id='playertest'></div>
<script type='text/javascript'>
jwplayer('playertest').setup({
playlist: '//jwpsrv.com/feed/test.rss',
width: '100%',
aspectratio: '16:9',
primary: 'flash' // WHY FLASH????!!
});
</script>
<script>
jwplayer().onComplete(function(){});
</script>
</body>

</html>

jherrieven

User  
0 rated :

@mikhailtpm

You'll probably want to get rid of the duplicate "playertest" DIV as well:

<div id='playertest'></div>

@ben1189

There are many reasons why an embed may be forced to default to Flash:

> the version of JW Player / browser combination

and

> what's in the RSS playlist

Are just two potential reasons given this code.

Ethan Feldman

JW Player Support Agent  
0 rated :

You don’t necessarily need primary flash, it looks like you generated this code from the wizard though, so that option can always be toggled.

jherrieven

User  
0 rated :

If you are using JW6.7,
Or the playlist contains YouTube videos after the first playlist item,
it would be sensible to default to flash...

Ethan Feldman

JW Player Support Agent  
0 rated :

It is probably 6.9 if using cloud hosted though.

jherrieven

User  
0 rated :

Apologies...

> what's in the RSS playlist

Is just one potential reason given this code.

Ethan Feldman

JW Player Support Agent  
0 rated :

Yeah, it is possible that the wizard defaulted to Flash because of what’s in the RSS.

jherrieven

User  
0 rated :

Ethan,

Just because the embed code is likely to be using 6.9 *now*, doesn't mean it was using 6.9 when the code was originally created - who knows, who cares - I was simple suggesting a couple of reasons why - given the code on offer - a user may actively chose to set the "primary" to "flash" - this was simply in a bid answer @ben1189's sub question.

None of this really matters.

As @ben1189 pointed out, the reason the code is not executing is because the event binding was done incorrect, and I was additionally suggesting the duplicate ID'ed DIV would not be helping matters.

James

Ethan Feldman

JW Player Support Agent  
0 rated :

Yeah, I understand :) Not trying to argue about that here :)

Yes, Ben’s observation is indeed correct.

This question has received the maximum number of answers.