Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

How To Detect Stream Completion

3 replies [Last post]

My objective is redirect viewer to a web page upon the completion of a stream.

I have read several posts regarding redirect upon completion of a playlist.

Is this possible? Can you point me to some sample code?

Thanks,

jared

Are you looking for code to detect the end of a live stream or a VOD streamed using RTMP or HTTP?

Thanks for the reply hobbs.

It is actually a simulated live stream. In other words, a prerecorded video that is being streamed as a live stream at a specific time.

Anyway, I found that the following code worked perfectly for anyone else who is searching for a similar solution.

<script type="text/javascript">
var player    =  null;
function playerReady(obj)
{
        player = gid(obj.id);
        addListeners();
      };

      function addListeners()
      {
player.addModelListener('STATE', 'stateMonitor');
      };

      function stateMonitor(obj)
      {
        if(obj.newstate == 'COMPLETED')
        {
          // drop out of fullscreen
          // this.window.focus();

          // load a new page
          window.location = 'http://www.google.com';
        }
      };

      function gid(name)
      {
        return document.getElementById(name);
      };
    </script>

Jared... Or someone else that may know...
I'm interested in setting up a pre-recorded live stream but am at a loss.
I know that there are two areas to deal with.
1. The first is the "controller" which allows me to start the video at the time that I want.
2. The other is the actual player itself. The HTML page is displayed with the video (using jw player) the video will be black and not play until I start the player using the "controller".
Does anyone have sample javascript or html or whatever source code I need to do this?
Thank you in advance.