ckplayer-plus 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ckplayer.js CHANGED
@@ -141,7 +141,7 @@
141
141
  cdnFallback:true// getPath 失败时是否回退到 jsDelivr(内网可设 false,并配置 pluginPath)
142
142
  };
143
143
  // 打包时替换为真实版本;用于 bundler 下 getPath 失效时的 CDN 回退
144
- var ckplayerPlusDefaultCdn='https://cdn.jsdelivr.net/npm/ckplayer-plus@1.1.7/dist/';
144
+ var ckplayerPlusDefaultCdn='https://cdn.jsdelivr.net/npm/ckplayer-plus@1.1.8/dist/';
145
145
  function ckplayerEmbed(videoObj){
146
146
  /*
147
147
  * rightMenu
@@ -449,7 +449,7 @@
449
449
  }
450
450
  var allowCdn=!vars || vars['cdnFallback']!==false;
451
451
  var cdn=(typeof window!=='undefined' && window.ckplayerPlusCdn) ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
452
- if(!allowCdn || !cdn || cdn.indexOf('1.1.7')>-1){
452
+ if(!allowCdn || !cdn || cdn.indexOf('1.1.8')>-1){
453
453
  // 避免占位版本或显式关闭 CDN 时请求坏地址;交给相对路径或业务 pluginPath
454
454
  return folder+'/'+file;
455
455
  }
@@ -1090,9 +1090,10 @@
1090
1090
  if(!resumeAt){
1091
1091
  resumeAt=parseResumeSeekFromVars();
1092
1092
  }
1093
- // 断点续播对齐 ZWPlayer:保持默认 autoStartLoad,媒体就绪后 currentTime=seek。
1094
- // 不再 autoStartLoad:false + 手动 startLoad 预热(易自相 cancel)。
1093
+ // 断点续播:关闭 autoStartLoad,清单解析后从目标前一片 startLoad,缓冲就绪再定位。
1094
+ // 与拖动路径分离(拖动只改 currentTime,不手动 startLoad)。
1095
1095
  if(resumeAt && resumeAt>0 && (isUndefined(vars['live']) || !vars['live'])){
1096
+ hlsConf.autoStartLoad=false;
1096
1097
  maxSeeTime=Math.max(maxSeeTime,resumeAt);
1097
1098
  if(firstSeekTime<0){
1098
1099
  firstSeekTime=resumeAt;
@@ -1101,6 +1102,7 @@
1101
1102
  hlsResumeTarget=resumeAt;
1102
1103
  hlsResumeSettling=true;
1103
1104
  hlsResumeWarmup=false;
1105
+ autoplayPending=false;
1104
1106
  }
1105
1107
  hls = new Hls(hlsConf);
1106
1108
  hls.loadSource(url);
@@ -1108,31 +1110,19 @@
1108
1110
  hls.on(Hls.Events.MANIFEST_PARSED, function(){
1109
1111
  if(seekTime>0 && hlsResumeSettling){
1110
1112
  hlsStartPositionUsed=true;
1111
- var tryResume=function(){
1112
- if(!seekTime || !hlsResumeSettling){return;}
1113
- var t=seekTime;
1114
- if(video && (video.readyState>=1 || (duration && isFinite(duration) && duration>0))){
1115
- finishResumeSeek(t);
1113
+ hlsSeekTo(seekTime,true);
1114
+ if(C['buffer']){
1115
+ C['buffer'].show();
1116
+ }
1117
+ setTimeout(function(){
1118
+ if(!hlsResumeSettling){
1116
1119
  return;
1117
1120
  }
1118
- seekRetryCount++;
1119
- if(seekRetryCount<=25){
1120
- if(seekRetryTimer){
1121
- clearTimeout(seekRetryTimer);
1122
- }
1123
- seekRetryTimer=setTimeout(tryResume,120);
1124
- }
1125
- else{
1121
+ var t=seekTime>0?seekTime:hlsResumeTarget;
1122
+ if(t>0 && !tryCompleteResumeSeek(t) && hlsResumeSettling){
1126
1123
  finishResumeSeek(t);
1127
1124
  }
1128
- };
1129
- tryResume();
1130
- // 超时兜底:避免永久转圈
1131
- setTimeout(function(){
1132
- if(hlsResumeSettling && seekTime>0){
1133
- finishResumeSeek(seekTime);
1134
- }
1135
- },4000);
1125
+ },8000);
1136
1126
  return;
1137
1127
  }
1138
1128
  if(!hlsStartPositionUsed){
@@ -1140,7 +1130,9 @@
1140
1130
  }
1141
1131
  });
1142
1132
  hls.on(Hls.Events.FRAG_BUFFERED, function(event, data){
1143
- if(hlsResumeSettling && seekTime>0){
1133
+ if(hlsResumeSettling && (seekTime>0 || hlsResumeTarget>0)){
1134
+ var resumeT=seekTime>0?seekTime:hlsResumeTarget;
1135
+ tryCompleteResumeSeek(resumeT);
1144
1136
  return;
1145
1137
  }
1146
1138
  if(hlsResumeTarget<=0 || !data || !data.frag){
@@ -2102,10 +2094,23 @@
2102
2094
  }catch(event){}
2103
2095
  return false;
2104
2096
  },
2097
+ /*
2098
+ * tryCompleteResumeSeek
2099
+ * 功能:续播预热完成后,缓冲已覆盖前片→目标时再定位
2100
+ */
2101
+ tryCompleteResumeSeek=function(t){
2102
+ if(!hlsResumeSettling || isNaN(t) || t<=0 || !video){
2103
+ return false;
2104
+ }
2105
+ if(hlsCanSafelySeekTo(t)){
2106
+ finishResumeSeek(t);
2107
+ return true;
2108
+ }
2109
+ return false;
2110
+ },
2105
2111
  /*
2106
2112
  * finishResumeSeek
2107
2113
  * 功能:完成续播定位。只 seek、不自动 play(由用户点击中央按钮/播放键)
2108
- * ZW 模型:直接 currentTime,不依赖前片预热完成态
2109
2114
  */
2110
2115
  finishResumeSeek=function(t){
2111
2116
  hlsResumeWarmup=false;
@@ -2173,7 +2178,7 @@
2173
2178
  /*
2174
2179
  * applyPendingSeek
2175
2180
  * 功能:在媒体就绪后应用挂起的 seekTime
2176
- * HLS 对齐 ZWPlayer:就绪后直接 currentTime(finishResumeSeek),不再主路径 startLoad 预热
2181
+ * HLS 续播:startLoad 预热 + 缓冲就绪后 finishResumeSeek(与拖动 currentTime 路径分离)
2177
2182
  */
2178
2183
  applyPendingSeek=function(force){
2179
2184
  if(!seekTime || !video || seekApplyLock){
@@ -2199,9 +2204,22 @@
2199
2204
  firstSeekTime=t;
2200
2205
  }
2201
2206
  }
2202
- // HLS:媒体元数据就绪即可定位(由 hls.js 响应 seeking 拉片)
2203
2207
  if(hls){
2204
2208
  hlsResumeSettling=true;
2209
+ hlsResumeTarget=t;
2210
+ autoplayPending=false;
2211
+ if(hlsResumeWarmup){
2212
+ return;
2213
+ }
2214
+ if(tryCompleteResumeSeek(t)){
2215
+ return;
2216
+ }
2217
+ if(hlsSeekTo(t,force)){
2218
+ if(C['buffer']){
2219
+ C['buffer'].show();
2220
+ }
2221
+ return;
2222
+ }
2205
2223
  if(!force && (!isUndefined(video.readyState) && video.readyState<1) && !(dur && isFinite(dur) && dur>0)){
2206
2224
  seekRetryCount++;
2207
2225
  if(seekRetryCount<=40){
@@ -7463,7 +7481,7 @@
7463
7481
  if(!isRetry && (!vars || vars['cdnFallback']!==false)){
7464
7482
  var cdn=(typeof window!=='undefined' && window.ckplayerPlusCdn) ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
7465
7483
  var m=String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
7466
- if(cdn && cdn.indexOf('1.1.7')===-1 && m){
7484
+ if(cdn && cdn.indexOf('1.1.8')===-1 && m){
7467
7485
  if(cdn.slice(-1)!=='/'){
7468
7486
  cdn+='/';
7469
7487
  }