網頁上嵌入Flash播放器(2),嵌入flash
接著上一篇部落格,下面介紹另一種flash播放器的嵌入,這個是公司內部用的的一款flash播放器,支援的格式比較多,還能支援swf格式的視頻播放。
下面是頁面內嵌程式碼:
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/flash/history/history.css" /><script type="text/javascript" src="<%=request.getContextPath()%>/flash/history/history.js"></script><script type="text/javascript" src="<%=request.getContextPath()%>/flash/swfobject.js"></script><script type="text/javascript"> // For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. var swfVersionStr = "11.1.0"; // To use express install, set to playerProductInstall.swf, otherwise the empty string. var xiSwfUrlStr = "playerProductInstall.swf"; var flashvars = {}; //資源前置路徑,為要載入flash的路徑,例如:http://demo.com/assets/flash/ var assetPath = "<%=request.getContextPath()%>/flash/";//配置資源路徑 flashvars.url='<c:out value="${generateSwfUrl}"/>';//視頻播放路徑,可以動態賦值 flashvars.duration=${duration};//視頻時間長度,可以動態賦值 var params = {}; params.quality = "high"; params.bgcolor = "#000000"; params.allowscriptaccess = "sameDomain"; params.allowfullscreen = "true"; params.wmode= "transparent"; var attributes = {}; attributes.id = "VideoPreviewer"; attributes.name = "VideoPreviewer"; attributes.align = "middle"; //防緩衝 var d = new Date(); flashvars.time = d.getTime(); var preloaderUrl = assetPath + "VideoPreviewer.swf" + "?time=" + flashvars.time;//preloader.swf swfobject.embedSWF(preloaderUrl, "flashContent", "380", "290", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); // JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. swfobject.createCSS("#flashContent", "display:block;text-align:left;");</script><div class="publish_video"><center style="position: relative; top:0px; left:0px; margin:0px; padding:0px; background:#000000; overflow: hidden; "><div id="flashContent" style="position: relative; top:0px; left:0px; margin:0px; padding:0px;"><p>To view this page ensure that Adobe Flash Player version 11.1.0 or greater is installed.</p><script type="text/javascript"> var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://"); document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='" + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" ); </script></div><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"width="390px" height="390px" id="VideoPreviewer"><param name="movie" value="VideoPreviewer.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><!--[if !IE]>--><object type="application/x-shockwave-flash"data="VideoPreviewer.swf" width="370px" height="277px"><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><!--<![endif]--><!--[if gte IE 6]>--><p>Either scripts and active content are not permitted to runor Adobe Flash Player version 11.1.0 or greater is not installed.</p><!--<![endif]--><a href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" /> </a><!--[if !IE]>--></object><!--<![endif]--></object></noscript></center></div>備忘:這隻是頁面的內嵌程式碼,他還需要一些資源檔,我將需要的所有資源檔作為demo放在檔案夾裡打包上傳到空間裡了。
:http://download.csdn.net/detail/smszhuang168/7689225
總結:flash的嵌入方式其實都差不多,無非就是用js動態傳入一些參數而已,主要的代碼在flash對象裡,頁面上的代碼基本上都差不多。
怎在網頁中插入一個FLASH播放器呀
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="download.macromedia.com/...sion=6,0,29,0" width="80" height="80">
<param name="movie" value="調用資料庫裡flash地址">
<param name="quality" value="high">
<param name="wmode" value="transparent">
<param name="menu" value="false">
<embed src="調用資料庫裡flash地址" width="80" height="80" wmode=transparent quality="high" pluginspage="www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>
</object>
怎在網頁中加入FLASH播放器
<script type="text/javascript" src="changmc.com/audioplayer.js"></script>
<script type="text/javascript" src="changmc.com/flashobject.js"></script>
<div><b>歌名</b></div>
<div id="8902" style="width:290;height:24;"></div>
</div>
<script type="text/javascript">var fo = new FlashObject("changmc.com/images/audioplayer.swf","audioplayer8902","290px","24px","7");fo.addParam("quality","high");fo.addParam("FlashVars","playerID=8902&bg=0xf8f8f8&leftbg=0xeeeeee&lefticon=0x666666&rightbg=0xcccccc&rightbghover=0x999999&righticon=0x666666&righticonhover=0xFFFFFF&text=0x666666&slider=0x666666&track=0xFFFFFF&border=0x666666&loader=0xdedede&loop=yes&soundFile=90.shangdu.com/...09.mp3");fo.addParam("wmode","transparent");fo.addParam(&......餘下全文>>