java flash player

there are a lot of flash players we can use. here just illustrate very few.

1. jaris player

http://jarisflvplayer.org/

download it and unpack, copy the directory into your project, open player.html or create a new file. for example:

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Jaris FLV Player</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<meta name=”language” content=”en” />
<meta name=”description” content=”” />
<meta name=”keywords” content=”” />
<link rel=”stylesheet” type=”text/css” href=”http://localhost:8080/TSE/ext/resources/css/ext-all.css”&gt;
<link rel=”stylesheet” type=”text/css” href=”http://localhost:8080/TSE/css/media.css”&gt;
<link rel=”stylesheet” type=”text/css” href=”http://localhost:8080/TSE/css/icon.css”&gt;
<script type=”text/javascript” src=”http://localhost:8080/TSE/ext/ext-all.js”></script&gt;

<script type=”text/javascript” src=”js/swfobject.js”></script>
<script type=”text/javascript”>
var flashvarsVideo = {
source: “http://localhost:8080/TSE/flv/mv/CTCS-3.flv&#8221;,
type: “video”,
streamtype: “file”,
server: “”,//Used for rtmp streams
duration: “52”,
poster: “http://localhost:8080/TSE/flv/poster.png&#8221;,
autostart: “false”,
logo: “http://localhost:8080/TSE/flv/logo.jpg&#8221;,
logoposition: “top left”,
logoalpha: “30”,
logowidth: “130”,
logolink: “http://jaris.sourceforge.net&#8221;,
hardwarescaling: “false”,
darkcolor: “000000”,
brightcolor: “4c4c4c”,
controlcolor: “FFFFFF”,
hovercolor: “67A8C1”
};
var params = {
menu: “false”,
scale: “noScale”,
allowFullscreen: “true”,
allowScriptAccess: “always”,
bgcolor: “#000000”,
quality: “high”,
wmode: “opaque”
};
var attributes = {
id:”JarisFLVPlayer”
};
//swfobject.embedSWF(“JarisFLVPlayer.swf”, “altContentOne”, “576px”, “360px”, “10.0.0”, “expressInstall.swf”, flashvarsVideo, params, attributes);
swfobject.embedSWF(“JarisFLVPlayer.swf”, “altContentOne”, “750px”, “520px”, “10.0.0”, “expressInstall.swf”, flashvarsVideo, params, attributes);
</script>
<style>
html, body { height:100%; }
body { margin:0; }
</style>
</head>
<body>
<div id=”headerDiv”>
<table border=”0″ width=”1000px” id=”table1″ cellspacing=”0″ cellpadding=”0″ background=”http://localhost:8080/TSE/image/lbg1.png”&gt;
<tr height=”80″><td width=”5″>&nbsp;</td>
<td width=”211″ align=”left” valign=”top”><img src=”http://localhost:8080/TSE/image/shlogo.png&#8221; height=”60″/></td>
<td width=”auto” align=”center”><img src=”http://localhost:8080/TSE/image/shtitle.png&#8221; height=”35″/></td>
<td width=”100″><img src=”http://localhost:8080/TSE/image/lms.png&#8221; height=”50″/></td>
</tr></table>
</div>
<div id=”headToolbarDiv”></div>
<div class=”blankw”></div>
<div class=”clear”></div>
<div id=”mainDiv”>
<div id=”mainright” class=”mainright”>
<div id=”docTitleDiv”>
<h2>CASCO</h2>
<h1 id=”spanTitle”><span id=”docTitle”>
<a id=”rootNode” name=”rootNode”>CTCS三级列控体系介绍</a>
</span></h1>
<br/>
<h3><span id=”docAuthor”>作者:总公司</span></h3>
</div>
</div>
<center>
<div id=”altContentOne”>
<h1>Jaris FLV Player</h1>
<p>Alternative content</p>
<p><a href=”http://www.adobe.com/go/getflashplayer”><img
src=”http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&#8221;
alt=”Get Adobe Flash player” /></a></p>
</div>

</center>
</div>

<script type=”text/javascript”>
var strdate = new Date();
var stryear = strdate.getFullYear();
var strmonth = strdate.getMonth() + 1;
var strday = strdate.getDate();
var strweek = strdate.getDay();
var arr_week = new Array(“星期日”, “星期一”, “星期二”, “星期三”, “星期四”, “星期五”, “星期六”);
var headToolbar = Ext.create(‘Ext.toolbar.Toolbar’, {
id : ‘headToolbar’,
anchor : ‘100%’,
renderTo : ‘headToolbarDiv’,
items : [{
xtype : ‘tbtext’,
html : ‘<img src=”image/ind-top-calendar-bl.jpg” width=”15″ height=”15″ align=”absmiddle” />&nbsp;’
+ stryear
+ “年”
+ strmonth
+ “月”
+ strday
+ “日 ”
+ arr_week[strweek]
},{
xtype: ‘tbtext’,
text: ‘欢迎:’ + ‘管理员’
},’->’,{
xtype: ‘button’,
text: ‘退出’
}]
});

</script>
<br/>
<hr style=”width:80%”/>
<div class=”copyrightDiv”><span>卡斯柯信号有限公司 &copy Casco Signal Ltd.</span></div>
</body>
</html>

Attention: full uri should be used(like http://localhost:8080/TSE/flv/mv/CTCS-3.flv, you can not use relative url). And what’s more, I was failed using struts’s redirection. If you have any idea, please contact zhonghuafy@gmail.com.

Snap1

2. jw player

http://www.longtailvideo.com/

as jaris, download it and put it into your project. write a page like below:

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>
<%@ page import=”casco.com.tse.hibernate.pojo.TbDocmedia” %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<base href=”<%=basePath%>”>

<title>My JSP ‘jwplayer.jsp’ starting page</title>

<meta http-equiv=”pragma” content=”no-cache”>
<meta http-equiv=”cache-control” content=”no-cache”>
<meta http-equiv=”expires” content=”0″>
<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
<meta http-equiv=”description” content=”This is my page”>
<!–
<link rel=”stylesheet” type=”text/css” href=”styles.css”>
–>
<link rel=”stylesheet” type=”text/css” href=”http://localhost:8080/TSE/ext/resources/css/ext-all.css”&gt;
<link rel=”stylesheet” type=”text/css” href=”http://localhost:8080/TSE/css/media.css”&gt;
<link rel=”stylesheet” type=”text/css” href=”http://localhost:8080/TSE/css/icon.css”&gt;
<script type=”text/javascript” src=”http://localhost:8080/TSE/ext/ext-all.js”></script&gt;
<script type=”text/javascript” src=”jwplayer/jwplayer.js”></script>

<%
String username = “”;
if(request.getSession() != null){
username = (String) request.getSession().getAttribute(“FullName”);
}
TbDocmedia media = (TbDocmedia) request.getAttribute(“mdoc”);
%>
<script type=”text/javascript”>
var uname = ‘<%=username%>’;
if(uname==null || uname==’null’){
window.location = “index.jsp”;
}
</script>

</head>

<body>
<div id=”headerDiv”>
<table border=”0″ width=”1000px” id=”table1″ cellspacing=”0″ cellpadding=”0″ background=”http://localhost:8080/TSE/image/lbg1.png”&gt;
<tr height=”80″><td width=”5″>&nbsp;</td>
<td width=”211″ align=”left” valign=”top”><img src=”http://localhost:8080/TSE/image/shlogo.png&#8221; height=”60″/></td>
<td width=”auto” align=”center”><img src=”http://localhost:8080/TSE/image/shtitle.png&#8221; height=”35″/></td>
<td width=”100″><img src=”http://localhost:8080/TSE/image/lms.png&#8221; height=”50″/></td>
</tr></table>
</div>
<div id=”headToolbarDiv”></div>
<div class=”blankw”></div>
<div class=”clear”></div>
<div id=”mainDiv”>
<div id=”mainright” class=”mainright”>
<div id=”docTitleDiv”>
<h2>CASCO</h2>
<h1 id=”spanTitle”><span id=”docTitle”>
<a id=”rootNode” name=”rootNode”><%=media.getDname() %></a>
</span></h1>
<br/>
<h3><span id=”docAuthor”>作者:<%=media.getDauthor() %></span></h3>
</div>
</div>
<center>
<div id=”myElement”>Loading the player…</div>

</center>
</div>

<script type=”text/javascript”>
var vuname = “<%=media.getDuuname()%>”;
var vfile = “<%=basePath%>”+vuname;
jwplayer(“myElement”).setup({
file: vfile,
//title: ‘<%=media.getDname()%>’,
image: “http://localhost:8080/TSE/image/shlogo.png&#8221;,
logo: {
file: “http://localhost:8080/TSE/flv/logo.jpg&#8221;,
link: “http://www.casco.com.cn&#8221;
},
width: 650,
height: 400,
primary: ‘flash’,
//stretching: ‘fill’,
usekeys: true
});
</script>

<script type=”text/javascript”>
var strdate = new Date();
var stryear = strdate.getFullYear();
var strmonth = strdate.getMonth() + 1;
var strday = strdate.getDate();
var strweek = strdate.getDay();
var arr_week = new Array(“星期日”, “星期一”, “星期二”, “星期三”, “星期四”, “星期五”, “星期六”);
var headToolbar = Ext.create(‘Ext.toolbar.Toolbar’, {
id : ‘headToolbar’,
anchor : ‘100%’,
renderTo : ‘headToolbarDiv’,
items : [{
xtype : ‘tbtext’,
html : ‘<img src=”http://localhost:8080/TSE/image/ind-top-calendar-bl.jpg&#8221; width=”15″ height=”15″ align=”absmiddle” />&nbsp;’
+ stryear
+ “年”
+ strmonth
+ “月”
+ strday
+ “日 ”
+ arr_week[strweek]
},{
xtype: ‘tbtext’,
text: ‘欢迎:’ + ‘管理员’
},’->’,{
xtype: ‘button’,
text: ‘退出’
}]
});

function kevent(){
if(event.keyCode==32){
if(jwplayer().getState()==’PLAYING’){
jwplayer().pause(true);
}else if(jwplayer().getState()==’PAUSED’){
jwplayer().play(true);
}
}
}
document.onkeypress=kevent;
//jwplayer().onkeypress=kevent;
</script>
<br/>
<div class=”blankw”></div>
<div class=”clear”></div>
<hr style=”width:80%”/>
<div class=”copyrightDiv”><span>卡斯柯信号有限公司 &copy Casco Signal Ltd.</span></div>

</body>
</html>

TbDocmedia is a java class that including flv media’s file name, path, author etc.

I had implemented pause/play keyboard shortcut. But it can not work when full screen. If you have any good idea, please contact zhonghuafy@gmail.com

Snap2

the end

 

 

This entry was posted in Computer, Java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s