ckplayer-plus 1.0.8 → 1.1.0

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/README.md CHANGED
@@ -108,7 +108,7 @@ React:
108
108
 
109
109
  ```vue
110
110
  <template>
111
- <CkPlayer :video="url" poster="/poster.png" height="400px" @play="onPlay" />
111
+ <CkPlayer :video="url" :seek="16" poster="/poster.png" height="400px" @play="onPlay" />
112
112
  </template>
113
113
 
114
114
  <script>
@@ -125,6 +125,8 @@ export default {
125
125
  </script>
126
126
  ```
127
127
 
128
+ 断点续播:`seek` 用 `:seek` 或 `options.seek` 在创建时传入;**不要**在 `@ready` 里再 `player.seek(16)`,否则会重复加载 HLS、取消 `.ts` 分片导致卡住。
129
+
128
130
  SSR(Nuxt 等)请用 `<ClientOnly>`,仅在浏览器初始化。
129
131
 
130
132
  ## React
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.0.8/dist/';
144
+ var ckplayerPlusDefaultCdn='https://cdn.jsdelivr.net/npm/ckplayer-plus@1.1.0/dist/';
145
145
  function ckplayerEmbed(videoObj){
146
146
  /*
147
147
  * rightMenu
@@ -213,6 +213,33 @@
213
213
  var cookieArray=[];//保存当前所有记录
214
214
  var focusPause=true;//失去焦点前是否是暂停状态
215
215
  var existenceObj=false;//是否使用源码里已有的dom
216
+ /*
217
+ * invokeGlobalFn
218
+ * 功能:安全调用全局函数名(替代 eval(name+'()')),仅允许合法标识符路径,避免任意代码执行
219
+ * @expr 形如 "fnName" 或 "a.b.c" 的全局函数名(可含尾随括号)
220
+ */
221
+ function invokeGlobalFn(expr){
222
+ if(typeof expr!=='string'){
223
+ return;
224
+ }
225
+ var name=expr.replace(/\(\s*\)\s*;?\s*$/,'').trim();
226
+ if(!/^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/.test(name)){
227
+ return;
228
+ }
229
+ var parts=name.split('.');
230
+ var ctx=(typeof window!=='undefined')?window:this;
231
+ var fn=ctx;
232
+ for(var i=0;i<parts.length;i++){
233
+ if(fn==null){
234
+ return;
235
+ }
236
+ ctx=fn;
237
+ fn=fn[parts[i]];
238
+ }
239
+ if(typeof fn==='function'){
240
+ return fn.call(ctx);
241
+ }
242
+ }
216
243
  /*
217
244
  * into
218
245
  * 功能:初始化,调用播放器则首先调用该函数
@@ -417,7 +444,7 @@
417
444
  }
418
445
  var allowCdn=!vars || vars['cdnFallback']!==false;
419
446
  var cdn=(typeof window!=='undefined' && window.ckplayerPlusCdn) ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
420
- if(!allowCdn || !cdn || cdn.indexOf('1.0.8')>-1){
447
+ if(!allowCdn || !cdn || cdn.indexOf('1.1.0')>-1){
421
448
  // 避免占位版本或显式关闭 CDN 时请求坏地址;交给相对路径或业务 pluginPath
422
449
  return folder+'/'+file;
423
450
  }
@@ -2711,7 +2738,7 @@
2711
2738
  }
2712
2739
  else if(valType(ad['front']['closeButtonClick'])=='string'){
2713
2740
  try{
2714
- eval(ad['front']['closeButtonClick']+ '()');
2741
+ invokeGlobalFn(ad['front']['closeButtonClick']);
2715
2742
  }
2716
2743
  catch(event){console.error(event);}
2717
2744
  }
@@ -3608,7 +3635,7 @@
3608
3635
  fun();
3609
3636
  }
3610
3637
  if(valType(fun)=='string'){
3611
- eval(fun+ '()');
3638
+ invokeGlobalFn(fun);
3612
3639
  }
3613
3640
  }
3614
3641
  else{
@@ -3641,7 +3668,7 @@
3641
3668
  fun();
3642
3669
  }
3643
3670
  if(valType(fun)=='string'){
3644
- eval(fun+ '()');
3671
+ invokeGlobalFn(fun);
3645
3672
  }
3646
3673
  }
3647
3674
  else{
@@ -4201,7 +4228,7 @@
4201
4228
  var a=createlJsLink(m['title']);
4202
4229
  a.attr('data-click',m['click'].toString());
4203
4230
  a.click(function(){
4204
- eval($(this).attr('data-click')+'()');
4231
+ invokeGlobalFn($(this).attr('data-click'));
4205
4232
  C['menu'].hide();
4206
4233
  });
4207
4234
  li.append(a);
@@ -4936,7 +4963,7 @@
4936
4963
  vars['next']['click']();
4937
4964
  }
4938
4965
  else if(valType(vars['next']['click'])=='string'){
4939
- eval(vars['next']['click']+'()');
4966
+ invokeGlobalFn(vars['next']['click']);
4940
4967
  }
4941
4968
  }
4942
4969
  if('link' in vars['next']){
@@ -7034,7 +7061,7 @@
7034
7061
  if(!isRetry && (!vars || vars['cdnFallback']!==false)){
7035
7062
  var cdn=(typeof window!=='undefined' && window.ckplayerPlusCdn) ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
7036
7063
  var m=String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
7037
- if(cdn && cdn.indexOf('1.0.8')===-1 && m){
7064
+ if(cdn && cdn.indexOf('1.1.0')===-1 && m){
7038
7065
  if(cdn.slice(-1)!=='/'){
7039
7066
  cdn+='/';
7040
7067
  }
@@ -7204,7 +7231,14 @@
7204
7231
  if (xhr.status === 200) {
7205
7232
  if (obj.dataType === 'json') {
7206
7233
  try {
7207
- successFun(eval('(' + xhr.responseText + ')')); //回调传递参数
7234
+ var jsonData;
7235
+ try {
7236
+ jsonData = JSON.parse(xhr.responseText);
7237
+ }
7238
+ catch(parseErr) {
7239
+ jsonData = eval('(' + xhr.responseText + ')');
7240
+ }
7241
+ successFun(jsonData); //回调传递参数
7208
7242
  }
7209
7243
  catch(event) {
7210
7244
  successFun(null);