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

Forums

/

Exit fullscreen when playlist ends

6 replies [Last post]

Hello All,

I'm a non-programmer trying to get the player to automatically exit fullscreen mode when the playlist ends. I've tried to work with the scripts from a couple different posts but have had no success. Not sure what I'm missing.

Can anybody help?

 

    <script type="text/javascript">
      var player       =  null;
      var playlist     =  null;
      var currentItem  =  null;

      function playerReady(obj)
      {
        player = gid(obj.id);
        addListeners();
      };

      function addListeners()
      {
        playlist = player.getPlaylist();

        if((playlist !== null) && (playlist.length > 0))
        {
          player.addModelListener('STATE',      'stateMonitor');
          player.addControllerListener('ITEM',  'itemMonitor');
        }
        else
        {
          setTimeout("addListeners()", 100);
        }
      };

      function itemMonitor(obj)
      {
        currentItem = obj.index;
      };

      function stateMonitor(obj)
      {
        if((obj.newstate == 'COMPLETED') && ((currentItem + 1) == (player.getPlaylist().length)))
        {
          document.location.href = 'http://www.someredirecturl.com';
        }
      };

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

If you're still having trouble, post a link to your Test Page so someone can help ou further.

Thanks Hobbs,

I replaced

document.location.href = 'http://www.someredirecturl.com';

with

this.window.focus();

and it worked as expected in Internet Explorer, but in Firefox it remains in full screen mode.

Any suggestions?

 
I vaguely recall having some problem when I first tried this method, but I can't recall exactly what it was. I'll look through some old files later today and try to see what works in FF.

 
Seems that the only method that works in Firefox is to re-instantiate the player.

So wrap your player code in a function and then call that function.

        if((obj.newstate == 'COMPLETED') && ((currentItem + 1) == (player.getPlaylist().length)))
        {
        //...drop out of fullscreen
          createPlayer();
        }

ok. great! I'll give it a shot.
Thanks for your time.

hobbs, you are awesome. wasn't really looking for this but your post gave me an idea that solves many issues. thanks.