2009-04-20 103 views
0

我的網頁上有一個小小的問題,SWFObject。行爲是,當Flash播放器被另一個標籤覆蓋或最小化時,它不會開始播放音頻,直到標籤再次獲得焦點並且可見。它使用來自http://code.google.com/p/swfobject/SWFObject的2.1版本。爲了驗證此行爲,請加載頁面,並在5秒內將其最小化,並且您會注意到beginPlay中的代碼會更改頁面的標題。這種情況發生在音頻開始播放之後,但是直到瀏覽器重新獲得焦點後纔會開始播放。下面是代碼的樣本複製的問題:SWFObject音頻播放器在最小化時不播放

<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

它不是一個具體的SWFObject-的問題,通常是由於瀏覽器處理Flash播放器插件;當Flash播放器內容被隱藏或脫屏時,許多瀏覽器會終止該流程,然後在重新初始化SWF時再重新初始化它。請參閱http://pipwerks.com/lab/swfobject/hide-swf/2.0/index.html

我不相信你沒有辦法隱藏SWF。