If you don't find an answer, please click here to post your question.
Occasional Visitor
Posts: 1
Registered: ‎08-07-2017

Video Ending Event

I am trying to redirect a page once the video has ended, meaning the user has viewed the video to it’s completion but i cannot find a Javascript event that handles that. Do you guys know if there is one or how I would achieve that?

Posts: 14
Registered: ‎05-10-2016

Re: Video Ending Event

Hi EBM25,


You can achieve this by using our Message Bus API. Using this, you can listen to either "VideoPlayed" or perhaps "endScreenShown" event.


Here is an example using "endScreenShown" event:



<!DOCTYPE html>
<link rel="stylesheet" href="http://player.ooyala.com/static/v4/stable/latest/skin-plugin/html5-skin.min.css"/>
<script language="javascript" src="http://player.ooyala.com/static/v4/stable/latest/core.min.js"></script>
<script type="text/javascript" src="http://player.ooyala.com/static/v4/stable/latest/video-plugin/main_html5.min.js"></script>
<script type="text/javascript" src="http://player.ooyala.com/static/v4/stable/latest/skin-plugin/html5-skin.min.js"></script>

<div id='container' style='width:640px;height:480px'></div>
<script> /* * Always add event listeners and error handling * within the onCreate() function. * Include this function in the embedded parameters * in the Player.create() call. */ function onCreate(player) {
//*** Subscribe to endScreenShow event player.mb.subscribe('endScreenShown', 'myPage', function(eventName) { alert("Finished playing"); window.open("http://help.ooyala.com/"); }); } OO.ready(function() { window.pp = OO.Player.create('container', '<EMBED_CODE>', { "playerBrandingId":"<PLAYER_ID>", "pcode": "<PCODE>", skin: { config: "http://player.ooyala.com/static/v4/stable/latest/skin-plugin/skin.json", }, // Include the onCreate() function you defined above in these embedded parameters. onCreate : window.onCreate }); }); </script>


For details on the message bus, you can refer to  our documentation - http://help.ooyala.com/video-platform/reference/pbv4_dev_mbapi.html. Do also refer to "http://help.ooyala.com/video-platform/reference/pbv4_dev_listenevent.html" for an example on how to get the list of events.


I hope this helps.