This is a message.

IE throws errors when deleting a player, then adding a new one Created Jan 17, 2011

This thread is solved

Views: 1975     Replies: 6     Last reply Dec 10, 2011  
You must login first before you can use this feature

romain

Posts: 2

Registered:
Jan 17, 2011

IE throws errors when deleting a player, then adding a new one

Posted: Jan 17, 2011

Hello,

the following code produces some bug in IE and does not work.
However, I this code is correct and works well in other browsers


<!doctype>
<html>
  <head>
    <script src="http://static.flowplayer.org/js/flowplayer-3.2.4.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  </head>
  <body>
    <div id="player" style="width:500px;height:300px"></div>

    <a href="#" onclick="renew();return false;">Renew the player</a>

    <script type="text/javascript">
      var n = 0;
      var player;
      function fill_player()
      {
        n++;
        var wrapper_id = "wrapper"+n;
        $('#player').append('<div id="'+wrapper_id+'"> </div>');
        try{
          player = flowplayer(wrapper_id, {
                src: "http://releases.flowplayer.org/swf/flowplayer-3.2.5.swf"
            },
            {
                clip: "video.mp4"
            }
          );
        }
        catch(err)
        {
          alert(err);
        }
      }

      function renew()
      {
        if(typeof(player) != 'undefined' && typeof(player.unload) == 'function')
        {
          player.unload();
        }
        $('#player').empty();
        fill_player();
      }
      $(document).ready(
        function(){
          fill_player();
        }
      );
    </script>

  </body>
</html>

Thanks for feedback :)

Romain

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1868

Registered:
Nov 16, 2007

» IE throws errors when deleting a player, then adding a new one

Posted: Feb 24, 2011

Reply to: IE throws errors when deleting a player, then adding a new one, from romain
what happens if you just reinstall the player again on the same container. essentially calling the same flowplayer() call twice.

I did that on this page:

http://flowplayer.org/demos/installation/index.htm

and entered this command on the browser's console:


flowplayer("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.6.swf");

Worked for me on Chrome.

romain

Posts: 2

Registered:
Jan 17, 2011

» » IE throws errors when deleting a player, then adding a new one

Posted: Feb 24, 2011

Reply to: » IE throws errors when deleting a player, then adding a new one, from tipiirai
Hello,

thanks for the reply.

After trying many things, I've understood what happens !

With every browser, you can empty / remove the DOM element containing the player, then adding a new one with another DOM id and call the flowplayer constructor.

With Internet Explorer, you can not !
You have to always use the same DOM id, otherwise it throws some weird javascript errors.

I think the workaround for this problem is to use flowplayer this way ?
http://flowplayer.org/demos/installation/multiple-players.html

As I understand, there's no way to have multiple flowplayer flash object playing at the same time, or, at least, loaded at the same time.

anyway, thanks again for the feedback

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1868

Registered:
Nov 16, 2007

» » » IE throws errors when deleting a player, then adding a new one

Posted: Feb 24, 2011

Reply to: » » IE throws errors when deleting a player, then adding a new one, from romain
multiple-players.html is a good way to switch players. that is the method we definitely prefer and our player supports this "natively". I'm glad if you can setup your players like that.