它是一款用于网页上播放视频的软件,支持的格式有:http协议上的flv,f4v,mp4格式,我用它主要是因为它支持在firefox上的MP4播放。
下面是我在项目上应用的一个小例子
jsp代码
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String url = request.getParameter("url");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
System.out.println(url);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<base href="<%=basePath%>">
<script type="text/javascript" src="/js/CKPlayer_6.3/ckplayer.js" charset="utf-8"></script>
<title>video</title>
</head>
<body>
<div id="video"
style="position: relative; z-index: 100; width: 600px; height: 400px; float: left;">
<div id="a1"></div>
</div>
<script type="text/javascript">
var url='<%=url%>';
var flashvars = {
f : 'http://localhost:8080/java/video/' + url,
c : 0,
b : 1
};
var params = {
bgcolor : '#FFF',
allowFullScreen : true,
allowScriptAccess : 'always'
};
CKobject.embedSWF('/js/CKPlayer_6.3/ckplayer.swf', 'a1', 'ckplayer_a1', '600', '400',
flashvars, params);
/*
CKobject.embedSWF(播放器路径,容器id,播放器id/name,播放器宽,播放器高,flashvars的值,其它定义也可省略);
下面三行是调用html5播放器用到的
*/
var video = [ 'http://movie.ks.js.cn/flv/other/1_0.mp4->video/mp4',
'http://www.ckplayer.com/webm/0.webm->video/webm',
'http://www.ckplayer.com/webm/0.ogv->video/ogg' ];
var support = [ 'iPad', 'iPhone', 'ios', 'android+false',
'msie10+false' ];
CKobject.embedHTML5('video', 'ckplayer_a1', 600, 400, video, flashvars,
support);
</script>
</body>
</html>
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
title: "",
m4v: "http://localhost:8080/java/video/"+url,
ogv: "http://localhost:8080/java/video/"+url,
poster: "http://localhost:8080/java/video/"+url
});
},
swfPath: "/js",
supplied: "m4v, ogv"
});
});
然后我把CKplayer需要的样式和js文件都在外面引用,没有放在项目中。其中的js文件可以按个人喜好更改其样式,logo和广告等内容。
如有问题请指出。
2014.6.4