嵌入在网站上Flash播放机(2)

2022-07-06 09:13:01 浏览数 (1)

大家好,又见面了,我是全栈君。

然后在一个博客。这里有一个flash嵌入式播放器。这是公司内部使用的flash播放机,支持格更多款式,同时支持swf格视频播放的类型。

以下是页面嵌入代码:

代码语言:javascript复制
<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 run
					or 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对像巷,在网页代码基本上几乎相同的。

版权声明:本文博客原创文章,博客,未经同意,不得转载。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117443.html原文链接:https://javaforall.cn

0 人点赞