media插件默认支持播放五种格式,为:.asx.asf.avi.wma.wmv,实现视频在页面播放步骤:
1、首先导入js文件:jquery.media.js
2、先将文件上传到eclipes的工作空间的目录下。参照方法:
ServletActionContext.getRequest().getRealPath("")+ "/videoFiles/"+ fileName.avi
3、页面操作:
导入js文件后,需在页面加载完成页面后运行如下来加载flash播放器:
设置获取播放文件代码:
1、首先导入js文件:jquery.media.js
2、先将文件上传到eclipes的工作空间的目录下。参照方法:
ServletActionContext.getRequest().getRealPath("")+ "/videoFiles/"+ fileName.avi
3、页面操作:
导入js文件后,需在页面加载完成页面后运行如下来加载flash播放器:
$(document).ready(function () {
$.fn.media.defaults.flvPlayer = '<%=basepath %>/js/mediaplayer.swf';
$.fn.media.defaults.mp3Player = '<%=basepath %>/js/mediaplayer.swf';
$('a.media').media({ width: 500, height: 400, autoplay: true });
});
设置获取播放文件代码:
<c:choose>
<c:when test='${fn:indexOf(upFile.fileSaveName,".swf") != -1}'>
<EMBED src="videoFiles/${upFile.fileSaveName}" width=500 height=400 autostart=true >
</c:when>
<c:otherwise>
<a class="media" href="videoFiles/${upFile.fileSaveName}"> </a>
</c:otherwise>
</c:choose>