JSP和PHP FLV视频播放方案
JSP、PHP和ASP.NET以及ASP总体介绍了解 JSP和PHP的页面提交方式有着相同之处,只是语言不同,JSP页面则在页面中嵌入Java语言;PHP页面则在页面中嵌入PHP脚本语言,页面提交都是form通过method的post或get方式,action指定 所要提交的页面。ASP.NET不同的是,ASP.NET继承了早期ASP编写模式通直接在前台页面中写入VBScript脚本语言,form提交和JSP,PHP相同;在ASP.NET中则是个封装体,同时也提供了大量服务器控件,在默认情况下所有的控件都是放在Form中的,在生成预览的ASPX页面中action默认是指定本页的,这个在开发过程中对开发者来说的确方便了很多,开发者不需要把精力方在页面表但提交指定页面上面,而是把精力放在后台程序逻辑数据上面。在JSP、PHP和早期ASP页面中,当一个页面有多个不同表单要都提交到本页或同一个页面时,就需要开发者写大量的条件判断,而这一点在ASP.NET WebForm中就不需要顾及,这在ASP.NET中已经是一个基础现成的框架 。
JSP、PHP FLV视频播放演示地址
Weisim3Media 媒体播放JSP平台应用
在Weisim3Media中已经提供了现成的框架,JMcript.js已经将media.swf播放器封装好,在JSP页面中将JMcript.js引入进来即可,然后在javascript中用 Media(thisVideo,'480', '363', 'window');方法调入在页面中,Media中的参数介绍Media(视频路径url,'视频宽', '视频高', 'window|transparent|opaque')第四个参数也就flash wmode属性默认wmode即可。下面一个简单示例展示。
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="Scripts/JMcript.js" type="text/javascript"></script>
<title>Weisim3Media 视频播放组件 - JSP</title>
</head> <body>
Media('http://media.weisim3.com/20111106222905497.flv','480', '363','window');
<br/>
<script type="text/javascript">
Media('http://media.weisim3.com/20111106222905497.flv','480', '363','window');
</script>
</body>
</html>
通过 Media('http://media.weisim3.com/20111106222905497.flv','480', '363','window');将视频路径url,尺寸宽高,指定即可,效果如下。
JSP动态指定视频播放,进一步复杂通过JSP的post提交视频地址。效果演示地址http://118.244.2.4:8080/weisim3Media/index.jsp。在服务器上TomCat同样需要配置flv、mov、mp4三种视频格式,在 “tomcat根目录/conf/web.xml”的web-app节点中配置,下面是web.xml的flv、mov、mp4的配置以及详细代码。
<web-app>
<mime-mapping>
<extension>flv</extension>
<mime-type>video/x-flv</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mov</extension>
<mime-type>video/quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp4</extension>
<mime-type>video/mp4</mime-type>
</mime-mapping>
</web-app>
<div style=" padding:0px 5px">
<script type="text/javascript">
var myVideoFlv='<%=request.getParameter("myflv")%>';
var myVideoWmv='<%=request.getParameter("mywmv")%>';
var myVideoMov='<%=request.getParameter("mymov")%>';
var myVideoMp4='<%=request.getParameter("mymp4")%>';
//alert(myVideoFlv.toString()+"_"+myVideoWmv.toString());
var thisVideo=""
if(myVideoWmv!="null" || myVideoFlv!="null"
|| myVideoMov!="null" || myVideoMp4!="null")
{
if(myVideoWmv!="null")
{
thisVideo=myVideoWmv;
//alert("2_"+thisVideo);
}
if(myVideoFlv!="null")
{
thisVideo=myVideoFlv;
//alert("1_"+thisVideo);
}
if(myVideoMov!="null")
{
thisVideo=myVideoMov;
//alert("1_"+thisVideo);
}
if(myVideoMp4!="null")
{
thisVideo=myVideoMp4;
//alert("1_"+thisVideo);
}
![]()
}
![]()
if(myVideoFlv=="null" && myVideoWmv=="null"&&
myVideoMov=="null" && myVideoMp4=="null" )
{
thisVideo=myVideoFlv;
//alert("All_"+myVideoFlv);
}
![]()
if(thisVideo=="null")
{
//alert("All_Mov"+thisVideo);
![]()
thisVideo="http://media.weisim3.com/20111106222905497.flv";
}
![]()
Media(thisVideo,'480', '363','window');
//alert(thisVideo);
![]()
</script>
![]()
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="padding:10px 0px">
<form name="mediaFLV" action="index.jsp" method="post"
style="float:left">
<input name="myflv" type="hidden"
value="http://media.weisim3.com/20111106222905497.flv"/>
<input name="flv" type="submit" value="flv"
style="width:80px">
</form>
![]()
<form name="mediaFLV" action="index.jsp" method="post"
style="float:left">
<input name="mymov" type="hidden"
value="http://media.weisim3.com/Coerver Week 11.mov"/>
<input name="mov" type="submit" value="mov"
style="width:80px" />
</form>
<form name="mediaFLV" action="index.jsp" method="post"
style="float:left">
<input name="mymp4" type="hidden"
value="http://media.weisim3.com/Untitled.mp4"/>
<input name="mov" type="submit" value="mp4"
style="width:80px" />
</form>
</td>
</tr>
</table>
</div>
PHP动态指定视频播放 PHP的post接收视频播放和JSP的相似,只是接收参数有PHP的语言方法接受不同而已,演示地址http://118.244.2.4:8020/index.php。
<div style=" padding:0px 5px">
<script type="text/javascript">
function onload()
{
![]()
var myVideoFlv='<?php try{ echo @$_POST["myflv"]; }catch(Exception $e){} ?>';
var myVideoWmv='<?php try{ echo @$_POST["mywmv"]; }catch(Exception $e){} ?>';
var myVideoMov='<?php try{ echo @$_POST["mymov"]; }catch(Exception $e){} ?>';
var myVideoMp4='<?php try{ echo @$_POST["mymp4"]; }catch(Exception $e){} ?>';
var thisVideo="";
if(myVideoFlv!="" || myVideoWmv!="" || myVideoMov !=""|| myVideoMp4 !="")
{
![]()
if(myVideoWmv!="")
{
thisVideo=myVideoWmv;
//alert("2_"+thisVideo);
}
if(myVideoFlv!="")
{
thisVideo=myVideoFlv;
//alert("1_"+thisVideo);
}
if(myVideoMov!="")
{
thisVideo=myVideoMov;
//alert("1_"+thisVideo);
}
if(myVideoMp4!="")
{
thisVideo=myVideoMp4;
//alert("1_"+thisVideo);
}
}
![]()
if(myVideoFlv=="" && myVideoWmv=="" && myVideoMov==""&& myVideoMp4 =="")
{
thisVideo=myVideoFlv;
//alert("All_"+myVideoFlv);
}
![]()
if(thisVideo=="")
{
thisVideo="http://media.weisim3.com/20111106222905497.flv";
![]()
}
Media(thisVideo,'480', '363', 'window');
}
![]()
onload();
![]()
</script>
![]()
![]()
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<form name="mediaFLV" action="index.php" method="post" style="float:left">
![]()
<input name="myflv"
type="hidden" value="http://media.weisim3.com/20111106222905497.flv"/>
![]()
<input name="flv" type="submit" value="flv" style="width:100px">
![]()
</form>
<form name="mediaMOV" action="index.php" method="post" style="float:left">
![]()
<input name="mymov" type="hidden"
value="http://media.weisim3.com/Coerver Week 11.mov"/>
<input name="mov" type="submit" value="mov" style="width:100px" />
</form>
![]()
<form name="mediaMP4" action="index.php" method="post" style="float:left">
<input name="mymp4" type="hidden"
value="http://media.weisim3.com/Untitled.mp4"/>
<input name="mov" type="submit" value="mp4" style="width:100px" />
</form>
</td>
</tr>
</table>
</div>
本文相关技术支持请加入 QQ 729260499 .