')
Lhtml="";
nbg = "";
obg="";
$.ajax({//jsonp 去随机数
type: "get",
url: "//zy.api.cntv.cn/list/getPCFeedRecommend?n=10&p="+pages+"&serviceId=tvcctv&type=0&utdid=NON-PERSONALIZED",
dataType:"jsonp",
jsonp:"cb",// 重写回调函数名字
cache:true,
jsonpCallback:"Callback",
success: function (data) {
if (data.errcode =="1002" && pages==1 ){
gundong=false;
setTimeout(function(){
listvideo(1)
},2000)
return false;
}
if (data.errcode =="1002" && pages !=1 ){
gundong=false;
setTimeout(function(){
psize--;
gundong=true;
$(".ind_pic_box_18951 .loading_xq18058").html('
加载失败,上滑重试
')
},2000)
return false;
}
if(data.data.code != "9000"){
gundong=false;
setTimeout(function(){
psize--;
gundong=true;
$(".ind_pic_box_18951 .loading_xq18058").html('
加载失败,上滑重试
')
},5000)
}else{
var utdid = data.data.utdid;
var abId = data.data.abId;
var data = data.data.list;
var ttimes=new Date().getTime();
oddArr = data;
for(var i=0;i
'+newArr[i].title+'';
//baoguang(abId,ttimes,1,newArr[i].guid)//曝光
nbg+=newArr[i].guid+"/";
Lhtml += '';
//baoguang(abId,ttimes,0,oddArr[i].guid)//曝光
obg+=oddArr[i].guid+"/";
oddGuidArr.push(newArr[i].guid);//右侧guid插入左侧数组
}else{
Lhtml += '';
//baoguang(abId,ttimes,0,oddArr[i].guid)//曝光
obg+=oddArr[i].guid+"/";
}
}
if(nbg !=""){
baoguang(abId,ttimes,1,nbg)//曝光
}
baoguang(abId,ttimes,0,obg)//曝光
$(".box_18951").append(Lhtml);
if(oddGuidArr.length>30){//左侧数组大于30,从头删除10+推荐条
oddGuidArr.splice(0,10+(newGuidArr.length))
}
newGuidArr=[];
newArr=[];
gundong=true;
if(data.length<9){
gundong=false;
$(".ind_pic_box_18951 .loading_xq18058").html('没有更多内容了
')
}
var isHttps = location.href.substr(0, 5) == "https" ? "true": "false";
var itemcontent_length = $(".ind_pic_box_18951 .box_18951 .video").length; //播放器总个数
var posterImg =""; //定帧图
var isAudio = 0;
var oBox_18951 = $(".ind_pic_box_18951 .box_18951 .video");
creatHtml();
//创建视频
function player_call(){
var _num = 0;
oBox_18951.each(function(){
_num++;
});
for(var i = cVideoNum ; i < _num ; i++){
creatMultiPlayerTest("flash_video"+i, twoArray_video[i][0], false, twoArray_video[i][2], false,twoArray_video[i][1]);
}
cVideoNum = _num;
jiazaizhong = false;
}
//给每个视频 添加video 的外层box
function creatHtml(){
var start=player_video;
for(var i=start;i");
}
player_call()
}
var shipinW;
function video_WH(){ //视频框宽高
var screenW=window.innerWidth || screen.width;
if(screenW>750){
screenW=750;
}
shipinW=screenW*0.8933;//视频框宽高
}
video_WH();
$(window).resize(function(){
video_WH();
setTimeout(function(){
changeVideoSize();
},300)
})
//多视频播放器
var isAudio_play = true; //视频
function creatMultiPlayerTest(divid, pid, isAutoPlay, posterImg, isAudio,isshuban){ // 新增 isshuban 参数 判断是否是 竖版视频
var _w = $("#"+divid).parents(".v_box").width(); //添加特殊样式后宽度获取播放器id父级p标签宽度
if(_w == null){_w = shipinW;}
if(isshuban==6){ // 判断是否是 竖版视频
var _h = _w / 9 * 16; // 竖版视频 比例
}else{
var _h = _w / 16 * 9;
}
if(isAudio=="true") {
_h =54;
} else {
}
var playerParas = {
divId: divid, /*播放器容器id,必填项*/
w: _w, /*播放器宽度,必填项*/
h: _h, /*播放器高度,必填项*/
t: "news", /*台名称,比如news,sports,tv等,必填项*/
videoCenterId: pid, /*视频生产中心guid,必填项*/
br: "", /*设置默认码率*/
id: "null", /*可填null,必填项*/
videoId: "VIDE100215108600", /*视频集id*/
url: "", /*视频页面url,如http://tv.cntv.cn/video/C18472/a28126e5e0424a44af6a9bc4c5a47742*/
articleId: "", /*文章id*/
filePath: "", /*文件路径*/
sysSource: "", /*视频来源*/
channelId: "", /*可为空*/
scheduleId: "C18472000001", /*关键字*/
isLogin: "", /*用户中心相关,是否登录*/
userId: "C18472000001", /*用户中心相关,用户登录id*/
isDefaultPreImage: "true", /*是否默认从vdn取图,非自动播放情况下才有效*/
isAutoPlay: isAutoPlay, /*是否自动播放,只有false为不自动播放,其它值为自动播放*/
posterImg: posterImg, /*播放器前贴图片*/
isAudio: isAudio, /*是否是音频播放器,为true表示是音频,false表示是视频*/
isHttps: isHttps, /*是否https视频,true是,false不是*/
wmode: "opaque", /*flash播放器的窗口模式,默认为opaque*/
wideMode: "normal", /*flash播放器的窗口模式,默认为opaque*/
setupOn: "false", /*是否显示设置按钮,默认为false*/
playerType : "vod_h5", /*播放器类型,vod表示普通播放器*/
isLeftBottom: "false", /*播放按钮是否在播放器左下角,为true表示是,false表示播放按钮在播放器中间*/
webFullScreenOn: "false", /*是否显示全屏按钮,默认true表示显示*/
language: "", /*语言,默认中文,en表示英语*/
drm:"true"
};
createVodPlayer(playerParas);
var sett=setInterval(function(){
if($("#"+playerParas.divId).find('video').length>0){
//console.log(playerParas.divId,divid)
var pp = navigator.userAgent
if(pp.includes('Mobile')){
// 这是移动端
var elevideo = document.getElementById("html5Player-"+divid);
} else {
// 这是PC端
var elevideo = document.getElementById(divid+"_player_html5_api");
}
var panduanbofang=false;
clearInterval(sett)
//console.log(elevideo)
elevideo.addEventListener('play', function () {//播放开始执行的函数
if(pp.includes('Mobile')){
// 这是移动端
newIndex = $(this).attr("id").substring(23);
} else {
// 这是PC端
newIndex = $(this).attr("id").split("_")[1].substring(5);
}
var data_time = oBox_18951.eq(newIndex).attr("data-time");
var data_title = oBox_18951.eq(newIndex).find(".tit").html();
var data_type = oBox_18951.eq(newIndex).attr("data-type");
var data_guid = oBox_18951.eq(newIndex).attr("data-guid");
dianji(abId,data_time,data_title,data_type,data_guid)
newid = $(this).attr("id")
if(newIndex != oddIndex){
oddIndex = newIndex;
var data_fc = oBox_18951.eq(newIndex).attr("data-fc");
var data_sc = oBox_18951.eq(newIndex).attr("data-sc");
var data_utdid = oBox_18951.eq(newIndex).attr("data-utdid");
var data_guid = oBox_18951.eq(newIndex).attr("data-guid");
tuijian(data_fc,data_guid,data_sc,data_utdid)
}
/*window.onresize = window.onscroll = function () {
var rectObject = document.getElementById(newid).getBoundingClientRect();
var recttop = rectObject.top;//元素上边缘与视窗(浏览器)上边缘距离
var rectbottom = rectObject.bottom;//元素下边缘与视窗下边缘距离
var nowcuroh = document.getElementById(newid).offsetHeight;
if(recttop+nowcuroh<0 || rectbottom-nowcuroh>window.innerHeight){
//console.log("不在可视区域")
elevideo.pause()//播放暂停
}else{
//console.log("在")
if(elevideo.paused && panduanbofang==false){
elevideo.play()
}
}
//console.log(rectObject.top,rectObject.bottom,window.innerHeight,document.getElementById(newid).offsetHeight)
}*/
});
/*elevideo.addEventListener('pause', function () {//暂停开始执行的函数
var rectObject = document.getElementById($(this).attr("id")).getBoundingClientRect();
var recttop = rectObject.top;//元素上边缘与视窗(浏览器)上边缘距离
var rectbottom = rectObject.bottom;//元素下边缘与视窗下边缘距离
var nowcuroh = document.getElementById($(this).attr("id")).offsetHeight;
var data_time = oBox_18951.eq(newIndex).attr("data-time");
var data_title = oBox_18951.eq(newIndex).find(".tit").html();
var data_type = oBox_18951.eq(newIndex).attr("data-type");
var data_guid = oBox_18951.eq(newIndex).attr("data-guid");
//dianji(abId,data_time,data_title,data_type,data_guid)
if(recttop+nowcuroh<0 || rectbottom-nowcuroh>window.innerHeight){
panduanbofang=false;
}else{
panduanbofang=true;
}
});*/
}
},100)
}
//多视频自适应宽高
function changeVideoSize(){
var _w1 = $(window).width();
var _h1 = $(window).height();
for(var i=0; i=9){
newGuidArr = newGuidArr.slice(1);
newArr = newArr.slice(1)
}
newGuidArr.push(guid_);
newArr.push(data[i])
}
}
}
},
error: function () {
console.log("跨域了");
}
});
}
var gundong = false;
$(window).scroll(()=>{
var height=getClientHeight(),
// 窗口滚动条高度
theight=getScrollTop(),
// 窗口可视范围的高度
rheight=getScrollHeight(),
// 滚动条距离底部的高度
bheight=rheight-theight-height;
//console.log(bheight)
if (gundong){
if (bheight<=600){
gundong = false;
setTimeout(function(){
psize = psize+1;
listvideo(psize)
},100);
}
}
})
//获取窗口可视范围的高度
function getClientHeight(){
var clientHeight=0;
if(document.body.clientHeight&&document.documentElement.clientHeight){
var clientHeight=(document.body.clientHeightdocument.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
}
return clientHeight;
}
//获取窗口滚动条高度
function getScrollTop(){
var scrollTop=0;
if(document.documentElement&&document.documentElement.scrollTop){
scrollTop=document.documentElement.scrollTop;
}else if(document.body){
scrollTop=document.body.scrollTop;
}
return scrollTop;
}
//获取文档内容实际高度
function getScrollHeight(){
return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
}