当前位置:   article > 正文

ckplayer ajax,谁能帮我做一个脚本啊?能让这个网页视频播放可以拉动进度条 可以快进...

设置网页视频改播放进度

谁能帮我做一个脚本啊?能让这个网页视频播放可以拉动进度条 可以快进

$('.c_type').click(function(){

var data_id = $(this).attr('data-id');

$('.course_type div').removeClass('active');

$('.tab_content').css('display','none');

$(this).addClass('active');

$('#'+data_id).css('display','block')

});

function setCookieday(name, value, iDay)

{

var oDate = new Date();

oDate.setDate(oDate.getDate() + iDay);

document.cookie = name+ '=' +value+ '; expires = '+oDate

}

//所有服务器线路

var line_list = {"\u8054\u901a":[{"name":"\u901a\u8fbd","isp":"\u8054\u901a","ip":"116.116.56.87:8088","url":"116.116.56.87:8088","docview":"http:\/\/ow365.cn\/?i=13378&furl=","sort":"100","doc":"upload","doc_avatar":"uploadavatar","status":"1","id":"1"}],"\u7535\u4fe1":[{"name":"\u901a\u8fbd","isp":"\u7535\u4fe1","ip":"222.74.122.106:3722","url":"222.74.122.106:3722","docview":"http:\/\/ow365.cn\/?i=13145&furl=","sort":"100","doc":"upload","doc_avatar":"uploadavatar","status":"1","id":"2"}],"\u79fb\u52a8":[{"name":"\u901a\u8fbd","isp":"\u79fb\u52a8","ip":"39.153.128.53:8078","url":"39.153.128.53:8078","docview":"http:\/\/ow365.cn\/?i=15554&furl=","sort":"100","doc":"upload","doc_avatar":"uploadavatar","status":"1","id":"3"}],"\u4e3b\u7ebf\u8def":[{"name":"\u901a\u8fbd","isp":"\u4e3b\u7ebf\u8def","ip":"116.116.56.87:8088","url":"116.116.56.87:8088","docview":"http:\/\/ow365.cn\/?i=13378&furl=","sort":"100","doc":"upload","doc_avatar":"uploadavatar","status":"1","id":"1"}]};

var is_done = 0;

//默认服务器线路

var u_server = '主线路';

var propertys = Object.getOwnPropertyNames(line_list)

var is_open = false;

var iscode = false;

var flashvars={

c:0,

p:0,

};

var course_id=1;

var chapter_id=2;

var train_id=1;

var support = ['all'];

var video_url = "";

if(getCookie('network') == 99){

video_url = "http://course1.tlsjyy.cn:8035/02 国内外微课学习网站及文献.mp4";

}else{

video_url = "http://course.tlsjyy.cn/02 国内外微课学习网站及文献.mp4";

}

CKobject.embedHTML5('video_c','ckplayer_a1','750px','500px',[video_url],flashvars,support);

var time_now,time_n;

if($.cookie('starttime')){

time_now = $.cookie('starttime')

CKobject.getObjectById('ckplayer_a1').videoPlay();

}else{

time_now = 0;

}

function switch_line(num){

var date = new Date();

if(is_open){

time_n = CKobject.getObjectById('ckplayer_a1').getStatus().time;

}else{

time_n = undefined;

}

if(num == 99){

$.cookie('network',99);

$.cookie('starttime',time_n,{ expires: date });

location.reload();

}else{

$.cookie('network',100);

$.cookie('starttime',time_n,{ expires: date });

location.reload();

}

}

// $(".btn_line").click(function(){

// if(is_open){

// time_n = CKobject.getObjectById('ckplayer_a1').getStatus().time;

// }else{

// time_n = undefined;

// }

// var date = new Date();

// date.setTime(date.getTime()+60*1000);

// if($(this).index()==0){

// $.cookie('network',line_list['主线路'][0].ip);

// $.cookie('starttime',time_n,{ expires: date });

// location.reload();

// }else if($(this).index()==1){

// $.cookie('network',line_list['移动'][0].ip);

// $.cookie('starttime',time_n,{ expires: date });

// location.reload();

// }else if($(this).index()==2){

// $.cookie('network',line_list['联通'][0].ip);

// $.cookie('starttime',time_n,{ expires: date });

// location.reload();

// }else{

// $.cookie('network',line_list['电信'][0].ip);

// $.cookie('starttime',time_n,{ expires: date });

// location.reload();

// }

// // $("#ckplayer_a1").attr('src','http://116.116.56.87:8089/JXJYW/tgzmk190a/zt02.mp4')

// })

// 视频容器背景颜色

$('#video_c').css('background','rgba(48, 154, 235, 0.4)');

// 监听视频是否播放状态

CKobject.getObjectById('ckplayer_a1').addListener('play','playHandler');

function playHandler(){

is_open = true;

$('.end').show();

$('.continue').hide();

}

// 点击开始学习

$('.continue').click(function(){

var times=new Date().getTime();

if(train_id == null || chapter_id == null){

alert('数据错误');

location.reload();

return false;

}

$.cookie('start_time_continue',times,{path:'/'});

$.ajax({

type: "post",

cache: false,

//async: true,

url: "/student/index/ajax_video_star.html",

data: {train_id:train_id,chapter_id:chapter_id},

dataType: "json",

success: function(result){

// 进度时间发送成功后,显示开始学习按钮

console.log(result);

if(result=="ok"){

CKobject.getObjectById('ckplayer_a1').videoPlay();

$('.end').show();

$('.continue').hide();

$('#mask').hide();

}else{

layer.msg("为防止多个学习同时进行,请先完成"+result.chapter_title+"的课程学习",{icon:2});

setTimeout(function(){

location.href="/student/index/watch_course/train_id/"+result.train_id+"/course_id/"+result.course_id+"/chapter_id/"+result.chapter_id+".html";

},2000);

}

},

});

// 视频播放,显示结束学习按钮

})

// 点击结束学习,并将现在播放进度时间发给服务器

$('.end').click(function(){

var time_length = Math.ceil(CKobject.getObjectById('ckplayer_a1').getStatus().time);

if(isNaN(time_length)){

time_length = 0;

}

var url="/student/index/bxtimelog.html";

// 视频暂停

CKobject.getObjectById('ckplayer_a1').videoPause();

$.ajax({

type: "post",

cache: false,

//async: true,

url: "/student/index/ajax_video_end.html",

data: {train_id:train_id,chapter_id:chapter_id},

dataType: "json",

success: function(result){

// 进度时间发送成功后,显示开始学习按钮

console.log(result);

if(result == 0){

layer.msg("结束失败,请稍后重试");

return false;

}else{

$.ajax({

type: "post",

cache: false,

//async: true,

url: url,

data: {time_length:time_length,train_id:train_id,course_id:course_id,chapter_id:chapter_id},

dataType: "json",

//jsonpCallback:"jsonpCallback"+Math.round(Math.random()*10000),

success: function(json){

// 进度时间发送成功后,显示开始学习按钮

console.log(json);

$('.end').hide();

$('.continue').show();

$('#mask').show();

},

});

}

},

});

})

// 从服务器获得上一次学习进度时间,从此时间开始继续学习

~function videoSeek(t){

CKobject.getObjectById('ckplayer_a1').videoSeek(time_now);

}();

// 不能拖动进度条

// 添加遮罩层

var html = "

$('#video_c').append(html);

// 监听是否全屏

document.addEventListener("webkitfullscreenchange", function () {

// 视频的宽度,高度

var videoW = $('#ckplayer_a1').width();

var videoH = $('#ckplayer_a1').height();

console.log(videoW);

console.log(videoH);

if(videoW == '600')

{

// 不是全屏

$('.mask-mid').css('width',360);

$('#pop').css({'top':videoH/2-100,'left':videoW/2-178});

}

else

{

// 全屏

$('.mask-mid').css('width',videoW-240);

$('#pop').css({'top':videoH/2-100,'left':videoW/2-178});

}

});

// 每隔一秒获得一次当前播放时间

var timer = setInterval(function loadedHandler(){

var time_length = CKobject.getObjectById('ckplayer_a1').getStatus().time;

},1000);

// 阻止用户前进后退

var time = setInterval(preventchangetime,500);

var hou = 0;

function preventchangetime(){

var currttime = document.getElementById('ckplayer_a1').currentTime;

var xc = currttime-hou;

if(is_done == 1){clearInterval(time)

} else if(xc>2||xc<=-2){

CKobject.getObjectById('ckplayer_a1').videoSeek(hou);

}else{

hou = currttime;

}

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/130261
推荐阅读
相关标签
  

闽ICP备14008679号