views:

418

answers:

1

I have a small problem with the SWFObject on my web page. The behavior is that when the flash player is covered up by another tab or minimized it does not start to play the audio until the tab gets focus again and is visible. It is using the 2.1 version of SWFObject from http://code.google.com/p/swfobject/. In order to verify this behavior, load the page, minimize it within 5 seconds and you will notice the code in beginPlay changes the title of the page. This occurs after the audio should start playing, but it will not start until the browser gets focus again. Here is a sample of the code to duplicate the problem:

<html> 
<head> 
    <script type="text/javascript" src="swfobject.js"></script> 
    <script type="text/javascript" src="audio-player-uncompressed.js"></script> 
    <script> 
    function doLoad() {
     AudioPlayer.setup("player2.swf", { 
      width: "350px",
      animation: "no",
      autostart: "yes",
      loop: "yes",
      buffer: "5",
      initialvolume: 100,
     }); 
     AudioPlayer.embed("flashPlayer"); 
    }

    function beginPlay(){
     setTimeout(function(){
      AudioPlayer.embed("flashPlayer", {
       soundFile: "test.mp3"
      });
      document.title = "code after the flash player has executed."
     }, 5000);
    }
    </script> 
</head>
<body onload="doLoad();">
  This demonstration is to show how either WP Audio Player or SWFObject
  does not build the flash player while the browser is minimized.
  <br><br>
  <a href="javascript:beginPlay();">click this and minimize quickly.</a><br>
  <div id="flashPlayer"></div>
</body> 
</html>
+1  A: 

It isn't a SWFObject-specific problem, and is usually due to the browser's handling of the Flash Player plugin; when Flash player content is hidden or taken off-screen, many browsers kill the process then re-initialize the SWF when it is made visible again. See http://pipwerks.com/lab/swfobject/hide-swf/2.0/index.html

I don't believe there's much you can do about it short of not hiding the SWF.

pipwerks