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

How To Redirect After Video Finishes Playing


Hi Everyone,

I've been searching the forums and cannot find a simple answer to this question.

I have ONE video player in ONE player - and want it to redirect to another page on the web afterward. That's it.

I've found scripts that are 20 pages long for php and all sorts of things. Is there a relatively simple way to redirect to a new web page after the video plays?

Your help is GREATLY appreciated in advance. Thank you.

- Andrea

11 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

You can do this with JS.

<div id="container">This'll be the player</div>

<script type="text/javascript">
jwplayer("container").setup({
    file:"http://www.longtailvideo.com/jw/upload/bunny.mp4",
    height:400,
	width:600,
    events:{
        onComplete: function() {
            window.location = "http://www.cnn.com";
        }
    },
});

</script>

JW Player

User  
0 rated :

hi Ethan,

I'm going to try this right now. Thank you!
I'll post back when I've tested...

Andrea

JW Player

User  
0 rated :

Hmmm... so far I can't get this to work.

Here's the script I have in my page and it's working fine. Just can't yet redirect it to anywhere the way I want to:

bc.. <div id='mediaspace'>This text will be replaced</div>

<script type='text/javascript'>
jwplayer('mediaspace').setup({
'flashplayer': 'http://www.restorefinance.com/video/player.swf',
'author': 'Andrea Steward and Michael Kaplan',
'duration': '1315',
'file': 'http://ae.restorefinance.com/webinar1/webinar1.flv',
'image': 'http://ae.restorefinance.com/webinar1/FirstFrame.png',
'volume': '80',
'autostart': 'true',
'controlbar': 'bottom',
'backcolor': '000000',
'frontcolor': '00FF00',
'lightcolor': '99FF99',
'linktarget': 'http://webinar.restorefinance.com/afterwebinar.html',
'controlbar': 'bottom',
'width': '640',
'height': '480'
});
</script>
</div>



The header script of course has the jwplayer.js in it.
This script works and the video plays perfectly. At the end it doesn't redirect - I tried adding a part of your script... the part that says:

bc.. events:{
onComplete: function() {
window.location = "http://www.cnn.com";
}
},



since that appears to be the part I need... but no go.

Lost,
Andrea




JW Player

User  
-1 rated :

Here's what ended up working for me. This goes in the head...

bc.. <script type="text/javascript"> var player = null; function playerReady(obj) { player = document.getElementsByName(obj.id)[0]; player.addModelListener('STATE', 'stateMonitor'); }; function stateMonitor(obj) { if(obj.newstate == 'COMPLETED') { document.location.href = "http://www.WEBADDRESS.com"; } }; </script>




Put everything else in as normal. The player goes in the body and the .js script in the header.

- Andrea

Ethan Feldman

JW Player Support Agent  
0 rated :

Thanks for letting me know, glad you got it.

JW Player

User  
0 rated :

Hi Andrea,

To clarify what you found to work, did you NOT use what Ethan suggested and instead use your snipped above placed inside the doc head?

Thanks.

Gregory

Ethan Feldman

JW Player Support Agent  
0 rated :

@Gregory – The code I posted above definitely works for me…

JW Player

User  
0 rated :

I'm not a sophisticated coder but I've been reading all the forums and trying every scenario. I still can't get this to work. The video plays fine, but no redirect at the end. Can someone take a look at this code and see what I'm doing wrong? I'm sure it's some small thing.

bc.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Port of Houston Authority</title>
<script type='text/javascript' src='swfobject.js'> var player = null; function playerReady(obj) { player = document.getElementsByName(obj.id)[0]; player.addModelListener('STATE', 'stateMonitor'); }; function stateMonitor(obj) { if(obj.newstate == 'COMPLETED') { document.location.href = "http://pharila12reception.eventbrite.com/"; } }; </script>
</head>

<body>
<table width="720" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" bgcolor="#c6c8ca"><p> </p>
<p> </p>
<p>  </p>
<p> </p>
<p>

<div id='mediaspace'>The video is loading</div>

<script type='text/javascript'>
var so = new SWFObject('player.swf','mpl','720','405','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('file','http://www.portofhouston.com/rila/files/PHA_720x405.flv');
so.addVariable('controlbar','none');
so.addVariable('autostart','true');
so.write('mediaspace');
</script>

</p> <p> </p>
<p class="smalltype"><a href="http://pharila12reception.eventbrite.com/">(skip video)</a> </p>
</td>
</tr>
</table>

</body>
</html>

Ethan Feldman

JW Player Support Agent  
0 rated :

@Damon – Do you have a link?

JW Player

User  
0 rated :

@Ethan - http://www.portofhouston.com/rila/index6.html

Ethan Feldman

JW Player Support Agent  
0 rated :

You should just do the whole thing in the embedder.

Like this, I have this working locally:

<div id="container">This'll be the player</div>

<script type="text/javascript">
jwplayer("container").setup({
    file:"http://www.longtailvideo.com/jw/upload/bunny.mp4",
    height:400,
	width:600,
    events:{
        onComplete: function() {
            window.location = "http://www.cnn.com";
        }
    }
});

</script>

This question has received the maximum number of answers.