网页中播放swf文件与flv文件共存的方法

    技术2024-11-07  24

    下面是实现代码,主要是通过判断文件的后缀名,如果是swf文件,就用第一 种方法,如果是其他的就调用jw flv播放器来播放.

    <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>视频资料学习</title>    <link type="text/css" href="../CSS/StyleNew.css" rel="stylesheet"/>    <script type="text/javascript" src="swfobject.js"></script>    </head><body>    <form id="form1" runat="server">    <asp:ScriptManager ID="ScriptManager1" runat="server">    </asp:ScriptManager>    <asp:UpdatePanel ID="UpdatePanel1" runat="server">        <ContentTemplate>           <div style=" height:30px;"></div>           <div class="txtdoc" style="text-align:center">           <p id="player1">           <asp:HiddenField ID="H_str" runat="server" />            <script type="text/javascript">                var H_name = document.getElementById("H_str");                var str = H_name.value;                var hzm = str.substring(str.length - 3, str.length);//取文件后缀名称                if (hzm == "swf") {                    var so = new SWFObject(str,"mymovie","80%","95%","7","#336699");                    so.write("player1");                }                else {                    var s1 = new SWFObject("mediaplayer.swf", "mediaplayer", "640", "480", "7");                   s1.addParam("allowfullscreen", "true");                   s1.addVariable("autostart", "true");                   s1.addVariable("file", str);                   s1.addVariable("logo", "xbd.png")                   s1.addVariable("clicktext","点击播放")                   s1.addVariable("width", "640");                   s1.addVariable("height", "480");                   s1.write("player1");                }             </script></div>        </ContentTemplate>    </asp:UpdatePanel>    </form>

    </body></html>

    最新回复(0)