0

SWFObject我的网页上有一个小问题。行为是,当 Flash 播放器被另一个选项卡覆盖或最小化时,它不会开始播放音频,直到选项卡再次获得焦点并可见。它使用SWFObject来自http://code.google.com/p/swfobject/的 2.1 版本。为了验证这种行为,加载页面,在 5 秒内将其最小化,您会注意到代码中的代码beginPlay更改了页面的标题。这发生在音频应该开始播放之后,但直到浏览器再次获得焦点才会开始。这是复制问题的代码示例:

<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>
4

1 回答 1

1

这不是特定于 SWFObject 的问题,通常是由于浏览器对 Flash Player 插件的处理所致;当 Flash 播放器内容被隐藏或离开屏幕时,许多浏览器会终止该进程,然后在 SWF 再次可见时重新初始化它。见http://pipwerks.com/lab/swfobject/hide-swf/2.0/index.html

除了不隐藏 SWF 之外,我不相信您可以做很多事情。

于 2009-06-17T06:30:25.903 回答