no commit message

This commit is contained in:
niandeng
2022-02-16 16:35:22 +08:00
parent a4edc94afc
commit b9a7a35d54
2 changed files with 54 additions and 19 deletions
+53 -18
View File
@@ -174,6 +174,7 @@
var pugPlayer=null;//插件播放器 var pugPlayer=null;//插件播放器
var hls=null;//播放hls var hls=null;//播放hls
var loadMeta=true;//第一次加载到元数据 var loadMeta=true;//第一次加载到元数据
var app='';//平台类型
/* /*
* into * into
* 功能:初始化,调用播放器则首先调用该函数 * 功能:初始化,调用播放器则首先调用该函数
@@ -199,6 +200,10 @@
* newEvent是提供给播放器外部监听函数使用的,如监听时间player.time(function(t){console.log('已播放:'+t);}); * newEvent是提供给播放器外部监听函数使用的,如监听时间player.time(function(t){console.log('已播放:'+t);});
*/ */
eventTarget(); eventTarget();
/*
* 判断平台类型
*/
app=getApp();
/* /*
* 简单复制一下初始化时的默认配置 * 简单复制一下初始化时的默认配置
*/ */
@@ -517,8 +522,7 @@
plugPlayer(vstr[i][0]); plugPlayer(vstr[i][0]);
} }
else{ else{
var type=''; var type=' type="'+ vstr[i][1]+'"';
type=' type="'+ vstr[i][1]+'"';
if(vstr[i].length>1){ if(vstr[i].length>1){
source += '<source src="' + decodeURIComponent(vstr[i][0]) + '"' +type + '>'; source += '<source src="' + decodeURIComponent(vstr[i][0]) + '"' +type + '>';
} }
@@ -1145,6 +1149,9 @@
loadAbout();//构建关于视频相关内容 loadAbout();//构建关于视频相关内容
loadMenu();//构建右键 loadMenu();//构建右键
} }
if(app=='iphone'){
C['loading'].hide();
}
changeTopTime();//修改顶部时间 changeTopTime();//修改顶部时间
CK.mouseout(function(){ CK.mouseout(function(){
if(!paused){ if(!paused){
@@ -1290,17 +1297,36 @@
} }
} }
} }
/*
* loadedMetaData
* 功能:视频播放对象video注册内部监听调用函数
*/
function loadedMetaData(){
eventTarget('loadedMetaData',{
width:CK.getWidth(),
height:CK.getHeight(),
videoWidth:CT.videoWidth,
videoHeight:CT.videoHeight,
duration:duration,
volume:CT.volume
});
replaceInformation('videoWidth',CT.videoWidth);
replaceInformation('videoHeight',CT.videoHeight);
replaceInformation('volume',parseInt(CT.volume*100));
replaceInformation('duration',parseInt(duration));
}
/* /*
* videoHandler * videoHandler
* 功能:视频播放对象video注册内部监听调用函数 * 功能:视频播放对象video注册内部监听调用函数
*/ */
var videoHandler={ var videoHandler={
loadStart:function(){ loadStart:function(){
if(!vars['controls']){ if(!vars['controls'] && app!='iphone'){
C['loading'].show(); C['loading'].show();
} }
C['centerPlay'].hide(); C['centerPlay'].hide();
eventTarget('loadstart'); eventTarget('loadstart');
}, },
canPlay:function(){ canPlay:function(){
C['loading'].hide(); C['loading'].hide();
@@ -1310,9 +1336,6 @@
eventTarget('loadeddata'); eventTarget('loadeddata');
}, },
loadedMetaData:function(){ loadedMetaData:function(){
if(!this.videoWidth || !this.videoHeight){
return;
}
duration=this.duration; duration=this.duration;
if(!isUndefined(this.duration) && vars['duration']){ if(!isUndefined(this.duration) && vars['duration']){
duration=vars['duration']; duration=vars['duration'];
@@ -1327,23 +1350,16 @@
} }
if(!vars['autoplay'] && !vars['controls']){ if(!vars['autoplay'] && !vars['controls']){
C['centerPlay'].show(); C['centerPlay'].show();
C['buffer'].hide();
} }
eventTarget('loadedMetaData',{
width:CK.getWidth(),
height:CK.getHeight(),
videoWidth:this.videoWidth,
videoHeight:this.videoHeight,
duration:duration,
volume:this.volume
});
CT.duration=duration; CT.duration=duration;
CT.videoWidth=this.videoWidth; CT.videoWidth=this.videoWidth;
CT.videoHeight=this.videoHeight; CT.videoHeight=this.videoHeight;
CT.volume=this.volume; CT.volume=this.volume;
replaceInformation('videoWidth',this.videoWidth); if(CT.videoWidth || CT.videoHeight || duration){
replaceInformation('videoHeight',this.videoHeight); loadedMetaData();
replaceInformation('volume',parseInt(this.volume*100)); }
replaceInformation('duration',parseInt(duration));
var len = 0; var len = 0;
if(!isUndefined(this.buffered)){ if(!isUndefined(this.buffered)){
len=this.buffered.length; len=this.buffered.length;
@@ -1396,6 +1412,16 @@
if(len>0){ if(len>0){
changeLoad(); changeLoad();
} }
if(!duration && this.duration){
consoleObj(this);
duration=this.duration;
CT.duration=duration;
CT.videoWidth=this.videoWidth;
CT.videoHeight=this.videoHeight;
if(CT.videoWidth || CT.videoHeight || duration){
loadedMetaData();
}
}
oldTime=playTime; oldTime=playTime;
playTime=this.currentTime; playTime=this.currentTime;
if(maxSeeTime<oldTime){ if(maxSeeTime<oldTime){
@@ -1598,12 +1624,14 @@
else{ else{
if(!vars['controls']){ if(!vars['controls']){
C['centerPlay'].show(); C['centerPlay'].show();
C['buffer'].hide();
} }
} }
} }
else{ else{
if(!vars['controls']){ if(!vars['controls']){
C['centerPlay'].show(); C['centerPlay'].show();
C['buffer'].hide();
} }
} }
C['bar']['playAndPause']['pause'].hide(); C['bar']['playAndPause']['pause'].hide();
@@ -2003,6 +2031,7 @@
ad['pauseClose']=createlButton('ck-pause-close'); ad['pauseClose']=createlButton('ck-pause-close');
ad['pauseClose'].click(function(){ ad['pauseClose'].click(function(){
C['centerPlay'].show(); C['centerPlay'].show();
C['buffer'].hide();
closePauseAd(); closePauseAd();
}); });
} }
@@ -6626,5 +6655,11 @@
$('body').removeListener('touchmove',bodyScroll, {passive: false}); $('body').removeListener('touchmove',bodyScroll, {passive: false});
} }
} }
function getApp(){
var u = navigator.userAgent.toLowerCase();
if(u.indexOf('iphone')>-1){
return 'iphone';
}
}
return into; return into;
})); }));
+1 -1
View File
File diff suppressed because one or more lines are too long