OlderBird
时间的流逝,能让你保持存在的只有语言文字

导航

 

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>获取当前播放时间的示例-ckplayer应用示例</title>
<meta name="keywords" content="flv播放器,f4v,mp4,hlv,rtmp播放器,网页视频播放器,ckplayer官网,视频流,播放器" />
<meta name="description" content="ckplayer(超酷网页视频播放器),支持http协议下的flv,f4v,mp4,支持rtmp视频流和rtmp视频回放,支持m3u8格式,是你做视频直播,视频点播的理想播放器 " />
<meta name="author" content="ckplayer,超酷网页视频播放器" />
<meta name="copyright" content="ckplayer,超酷网页视频播放器" />
<script type="text/javascript" src="/static/js/jq1.9.1.js"></script>
<script type="text/javascript" src="/static/js/help.js"></script>
<link href="/static/css/example.css" rel="stylesheet" type="text/css">
<style type="text/css">
#a1 {
height: 400px;
width: 600px;
}

#nowTime {
line-height: 35px;
background-color: #EBEBEB;
height: 35px;
}
</style>
</head>
<body>
<script type="text/javascript" src="http://www.ckplayer.com/static/js/laycode/laycode2.js"></script>
<div class="top">
<div class="top_left"><a href="http://www.ckplayer.com/">ckplayer.com</a></div>
<div class="top_tab"><a href="http://www.ckplayer.com/">首页</a> | <a href="http://www.ckplayer.com/bbs/forum.php?mod=forumdisplay&fid=2">下载</a> | <a href="http://www.ckplayer.com/tool/">帮助手册</a> | <a href="http://www.ckplayer.com/article/19.htm">应用示例</a> | <a href="http://www.ckplayer.com/bbs/forum.php">论坛</a></div>
</div>
<div class="c_title">自动播放上次播放的示例</div>
<div id="a1"></div>
<!--<script type="text/javascript" src="/ckplayer/6.6/ckplayer.js"></script>-->
<script src="../flash/ckplayer/ckplayer.js"></script>
<script type="text/javascript">
function loadedHandler() {
if (CKobject.getObjectById('ckplayer_a1').getType()) {
addPlayListener();
}
else {
addPlayListener();
}
}
function timeHandler(t) {
if (t > -1) {
SetCookie("Time", t);
}
}
function addPlayListener() {//增加播放监听
if (CKobject.getObjectById('ckplayer_a1').getType()) {//说明使用html5播放器
CKobject.getObjectById('ckplayer_a1').addListener('play', playHandler);
}
else {
CKobject.getObjectById('ckplayer_a1').addListener('play', 'playHandler');
}
}
function playHandler() {
//alert('因为注册了监听播放,所以弹出此内容,删除监听将不再弹出');
removePlayListener();
CKobject.getObjectById('ckplayer_a1').videoSeek(getCookie("Time"));
addTimeListener();
}
function removePlayListener() {//删除播放监听事件
if (CKobject.getObjectById('ckplayer_a1').getType()) {//说明使用html5播放器
CKobject.getObjectById('ckplayer_a1').removeListener('play', playHandler);
}
else {
CKobject.getObjectById('ckplayer_a1').removeListener('play', 'playHandler');
}
}
function addTimeListener() {//增加时间监听
if (CKobject.getObjectById('ckplayer_a1').getType()) {//说明使用html5播放器
CKobject.getObjectById('ckplayer_a1').addListener('time', timeHandler);
}
else {
CKobject.getObjectById('ckplayer_a1').addListener('time', 'timeHandler');
}
}
//写cookies函数
function SetCookie(name, value)//两个参数,一个是cookie的名子,一个是值
{
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}

function getCookie(name)//取cookies函数
{
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null) return unescape(arr[2]); return null;

}
var flashvars = {
f: 'http://movie.ks.js.cn/flv/other/2014/06/20-2.flv',
c: 0,
p: 2,
b: 0,
i: '/static/images/letitgo.jpg',
loaded: 'loadedHandler',
my_url: encodeURIComponent(window.location.href)
};
var video = ['http://movie.ks.js.cn/flv/other/1_0.mp4->video/mp4'];
CKobject.embed('../flash/ckplayer/ckplayer.swf', 'a1', 'ckplayer_a1', '100%', '100%', false, flashvars, video);
// CKobject.embed('/ckplayer/6.6/ckplayer.swf','a1','ckplayer_a1','100%','100%',false,flashvars,video);
</script>
<div class="yytf">
<script type="text/javascript">
/*示例详情页960-90*/
var cpro_id = "u1837010";
</script>
<script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script>
</div>
<div class="explain_title">相关代码及说明</div>
<div class="exp">
原理:主要运用监听技术和Cookie来记录上次播放的位置,当播放器加载时,如果监听到当前状态为播放的话,那就会自动跳转到上次Cookie的记录,然后去除播放监听,同时增加对时间的监听状态,用js写入Cookie记录播放时间。
</div>
</body>
</html>

posted on 2014-12-02 17:32  OlderBird  阅读(2716)  评论(0编辑  收藏  举报