判定flash是否載入成功

來源:互聯網
上載者:User

取得FLASH對象的PercentLoaded方法,看其返回是否為100。下面是個小樣本:

<!doctype html><html>    <head>        <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"  allowfullscreen="true"/>        <title>FLASH 播放器 by 司徒正美</title>        <script language="javascript" type="text/javascript"> </script>        <style type="text/css">            html, body, #mask{                width:100%;                height:100%;            }            #mask{                background:url(http://softwarelivre.sapo.pt/projects/quizcreator/export/13/trunk/core/res/loading.gif) center center no-repeat;            }        </style>    </head>    <body>        <div id="mask">            <!--這裡是蒙板-->        </div>        <div id="player">            <!--這裡是播放器-->        </div>        <script type="text/javascript">                       //通過ID取得頁面元素            function $(id){                return document.getElementById(id)            }            //判定是否載入成功            function checkLoaded(flash){                try{                    return Math.floor(flash.PercentLoaded()) == 100                }catch(e){                    return false;                }            }            //取得flash的播放地址            function getFlashURL(){                return 'http://player.youku.com/player.php/sid/XMzkwNTgzMTIw/v.swf';            }            function createFlashHTML(u,w,h,i,wm,v){                var g= "";                if(window.ActiveXObject){                    g='<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" id="'+i+'" name="'+i+'" border="0" width="'+w+'" height="'+h+'"><param name="movie" value="'+u+'" /><param name="quality" value="high" /><param name="allowScriptAccess" value="always" /><param name="menu" value="false" /><param name="allowFullScreen" value="true" /><param name="wmode" value="'+wm+'" /><param name="flashvars" value="'+v+'" /></OBJECT>'                }else{                    g='<embed name="'+i+'" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" pluginspage=" http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" allowScriptAccess="always" allowFullScreen="true" quality="high" menu="false" wmode="'+wm+'" flashvars="'+v+'" src="'+u+'"></embed>'                }                return g;            }            var flashHTML = createFlashHTML(getFlashURL(),'100%','100%',"videoPlayer","Opaque","autoPlay=true&isAutoPlay=true&auto=1&playMovie=true&adss=0&api=1");            $("player").innerHTML = flashHTML            var flash = $("player").children[0];            var intervalID =  setInterval(function(){                if(checkLoaded(flash)){                    clearInterval(intervalID);                    $("mask").style.display = "none";                    intervalID = null;                }            },60)                               </script>    </body></html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.