Ckplayer的搭建

它是一款用于网页上播放视频的软件,支持的格式有: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>


js页的代码

$(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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值