Forum

How to redirect JWP...
 
Notifications
Clear all

How to redirect JWPlayer video after it finishes playing

380433b0c0305034cd333db1e6823e78?s=110&d=identicon&r=x - Forum
(@admin)
Member Admin

The trick to making the redirect work is to create a separate tag for the on.complete function.

So let's say this is your video code:

<div id="myElement"></div>
<script type="text/javascript">
jwplayer('myElement').setup({
file: 'https://www.yourvideourl.com',
image: '//www.longtailvideo.com/content/images/jw-player/lWMJeVvV-876.jpg',
title: 'Vic Dorfman Music',
width: '100%',
aspectratio: '16:9',
controls: 'false',
autostart: 'true'
});
</script>

*(replace http://www.yourvideourl.com with the URL of your video file or the URL of a YouTube video)

Embed this video code as is, WITHOUT the on.complete function inside the snippet.

Then embed a separate snippet below it like so:

<script type="text/javascript">
jwplayer().onComplete(function() {window.location = "http://www.google.com";});
</script>

As long as you separate these two Javascript snippets the redirect will work fine.

Make sure to replace http://www.google.com above with your redirect URL.

When your video ends, the visitor will be redirect to this URL.

Quote
Topic starter Posted : 02/06/2015 6:20 am
Share: