ckplayer-plus 1.0.1 → 1.0.3
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 +10 -5
- package/dist/ckplayer.css +7 -7
- package/dist/ckplayer.ixigua.css +7 -7
- package/dist/ckplayer.js +46 -5
- package/dist/ckplayer.min.js +2 -2
- package/dist/ckplayer.red.css +7 -7
- package/dist/index.cjs +43 -5
- package/dist/index.js +43 -5
- package/dist/react.cjs +43 -5
- package/dist/react.js +43 -5
- package/dist/vue.cjs +43 -5
- package/dist/vue.js +43 -5
- package/package.json +2 -1
- package/types/index.d.ts +12 -1
package/README.md
CHANGED
|
@@ -74,28 +74,33 @@ React:
|
|
|
74
74
|
|------|------|------|
|
|
75
75
|
| `autoPlug` | `true` | 按地址自动选插件;通常保持默认即可 |
|
|
76
76
|
| `plug` | 自动 | 仅在要强制指定或 `autoPlug: false` 时填写:`hls.js` / `flv.js` / `mpegts.js` |
|
|
77
|
+
| `preferBuiltinPlug` | `true` | 优先加载本包内置脚本,避免复用页面上其它全局 `Hls` |
|
|
78
|
+
| `cdnFallback` | `true` | `getPath` 失败时回退 jsDelivr;内网无外网请设 `false` 并配 `pluginPath` |
|
|
77
79
|
| `pluginPath` | 自动 | 插件脚本根路径。默认:`window.ckplayerBasePath` → 本包 `dist/` → jsDelivr CDN |
|
|
80
|
+
| `seek` | `0` | 续播秒数(number 或数字字符串);会同步 `maxSeeTime`,兼容 `timeScheduleAdjust: 5` |
|
|
78
81
|
| `loaded` | — | **只支持函数**;字符串形式已禁用(防 XSS) |
|
|
79
82
|
|
|
80
83
|
### 进阶(按需)
|
|
81
84
|
|
|
82
85
|
| 配置 | 说明 |
|
|
83
86
|
|------|------|
|
|
87
|
+
| `timeScheduleAdjust` | `5` 时只能在已看进度内拖动;续播请同时传数字 `seek` |
|
|
84
88
|
| `crossOrigin` | 跨域视频 / 截图等场景 |
|
|
85
89
|
| `cookie` | 进度记忆;组件默认使用实例唯一名,避免多实例冲突 |
|
|
86
90
|
| `language` | 语言包名,如 `en`、`zh.hk`(需能加载到 `language/*.js`) |
|
|
87
|
-
| `
|
|
91
|
+
| `loop` / `controls` 等 | 与官方 ckplayer 一致,见[手册](https://www.ckplayer.com/manual/) |
|
|
88
92
|
| `window.ckplayerBasePath` | 全局指定插件根目录(以 `/` 结尾),优先于 CDN |
|
|
89
93
|
| `window.ckplayerPlusCdn` | 自定义 CDN 根地址(覆盖默认 jsDelivr) |
|
|
90
94
|
|
|
91
95
|
### 插件加载优先级
|
|
92
96
|
|
|
93
|
-
1.
|
|
94
|
-
2.
|
|
97
|
+
1. `preferBuiltinPlug: false` 且页面已有全局 `Hls` / `flvjs` / `mpegts` → 直接复用
|
|
98
|
+
2. 否则加载本包脚本:`pluginPath` 或 `window.ckplayerBasePath`
|
|
95
99
|
3. 传统 `<script src=".../ckplayer.min.js">` 同级目录推导
|
|
96
|
-
4.
|
|
100
|
+
4. `cdnFallback !== false` 时回退:`https://cdn.jsdelivr.net/npm/ckplayer-plus@x.y.z/dist/`
|
|
97
101
|
|
|
98
|
-
> 内网离线:把 `node_modules/ckplayer-plus/dist/` 里的 `hls.js/` 等目录放到可访问静态路径,并设置 `pluginPath` 或 `window.ckplayerBasePath`。
|
|
102
|
+
> 内网离线:把 `node_modules/ckplayer-plus/dist/` 里的 `hls.js/` 等目录放到可访问静态路径,并设置 `pluginPath` 或 `window.ckplayerBasePath`,建议同时 `cdnFallback: false`。
|
|
103
|
+
> 样式请使用 `import 'ckplayer-plus/style.css'`,保证 `./images/` 图标能被打包工具解析。
|
|
99
104
|
|
|
100
105
|
## Vue 2 / Vue 3
|
|
101
106
|
|
package/dist/ckplayer.css
CHANGED
|
@@ -87,13 +87,13 @@
|
|
|
87
87
|
width: 80px;
|
|
88
88
|
height: 80px;
|
|
89
89
|
border-radius: 50%;
|
|
90
|
-
background: url(images/loading.png) no-repeat center center;
|
|
90
|
+
background: url(./images/loading.png) no-repeat center center;
|
|
91
91
|
background-size: 100% 100%;
|
|
92
92
|
animation: ck-Circle 1.5s linear infinite;
|
|
93
93
|
-webkit-animation: ck-Circle 1.5s linear infinite
|
|
94
94
|
}
|
|
95
95
|
.ckplayer-ckplayer .ck-main .ck-center-play{
|
|
96
|
-
background: url(images/play.png) no-repeat 70% center;
|
|
96
|
+
background: url(./images/play.png) no-repeat 70% center;
|
|
97
97
|
background-size:60% 60%;
|
|
98
98
|
border: 8px solid rgba(255,255,255,.3);
|
|
99
99
|
border-radius: 50%;
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
height: 120px;
|
|
128
128
|
}
|
|
129
129
|
.ckplayer-ckplayer .ck-main .ck-buffer{
|
|
130
|
-
background: url(images/buffer.png) no-repeat center center;
|
|
130
|
+
background: url(./images/buffer.png) no-repeat center center;
|
|
131
131
|
background-size:100% 100%;
|
|
132
132
|
border-radius: 50%;
|
|
133
133
|
width: 60px;
|
|
@@ -501,7 +501,7 @@
|
|
|
501
501
|
/*显示广告时的底部按钮-共用*/
|
|
502
502
|
.ckplayer-ckplayer .ck-main .ck-yytf .ck-yytf-bottom .ck-yytf-btn{
|
|
503
503
|
background-color: rgba(0,0,0,.6);
|
|
504
|
-
background-image: url(images/ckplayer.png);
|
|
504
|
+
background-image: url(./images/ckplayer.png);
|
|
505
505
|
background-size: auto 100%;
|
|
506
506
|
border: none;
|
|
507
507
|
outline: none;
|
|
@@ -634,7 +634,7 @@
|
|
|
634
634
|
width: 30px;
|
|
635
635
|
height: 30px;
|
|
636
636
|
background-color: transparent;
|
|
637
|
-
background-image: url(images/adclose.png);
|
|
637
|
+
background-image: url(./images/adclose.png);
|
|
638
638
|
border: none;
|
|
639
639
|
outline: none;
|
|
640
640
|
cursor: pointer;
|
|
@@ -691,7 +691,7 @@
|
|
|
691
691
|
/*按钮公用样式*/
|
|
692
692
|
.ckplayer-ckplayer .ck-main .ck-bar-btn{
|
|
693
693
|
background-color: transparent;
|
|
694
|
-
background-image: url(images/ckplayer.48.png);
|
|
694
|
+
background-image: url(./images/ckplayer.48.png);
|
|
695
695
|
background-size: auto 100%;
|
|
696
696
|
border: none;
|
|
697
697
|
outline: none;
|
|
@@ -701,7 +701,7 @@
|
|
|
701
701
|
background-repeat: no-repeat ;
|
|
702
702
|
}
|
|
703
703
|
.ckplayer-ckplayer .ck-main.ck-main-full .ck-bar-btn{
|
|
704
|
-
background-image: url(images/ckplayer.png);
|
|
704
|
+
background-image: url(./images/ckplayer.png);
|
|
705
705
|
width: 70px;
|
|
706
706
|
height: 70px;
|
|
707
707
|
}
|
package/dist/ckplayer.ixigua.css
CHANGED
|
@@ -87,13 +87,13 @@
|
|
|
87
87
|
width: 80px;
|
|
88
88
|
height: 80px;
|
|
89
89
|
border-radius: 50%;
|
|
90
|
-
background: url(images/loading.png) no-repeat center center;
|
|
90
|
+
background: url(./images/loading.png) no-repeat center center;
|
|
91
91
|
background-size: 100% 100%;
|
|
92
92
|
animation: ck-Circle 1.5s linear infinite;
|
|
93
93
|
-webkit-animation: ck-Circle 1.5s linear infinite
|
|
94
94
|
}
|
|
95
95
|
.ckplayer-ckplayer .ck-main .ck-center-play{
|
|
96
|
-
background: url(images/play.png) no-repeat 70% center;
|
|
96
|
+
background: url(./images/play.png) no-repeat 70% center;
|
|
97
97
|
background-size:60% 60%;
|
|
98
98
|
border: 8px solid rgba(255,255,255,.3);
|
|
99
99
|
border-radius: 50%;
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
height: 120px;
|
|
128
128
|
}
|
|
129
129
|
.ckplayer-ckplayer .ck-main .ck-buffer{
|
|
130
|
-
background: url(images/buffer.png) no-repeat center center;
|
|
130
|
+
background: url(./images/buffer.png) no-repeat center center;
|
|
131
131
|
background-size:100% 100%;
|
|
132
132
|
border-radius: 50%;
|
|
133
133
|
width: 60px;
|
|
@@ -501,7 +501,7 @@
|
|
|
501
501
|
/*显示广告时的底部按钮-共用*/
|
|
502
502
|
.ckplayer-ckplayer .ck-main .ck-yytf .ck-yytf-bottom .ck-yytf-btn{
|
|
503
503
|
background-color: rgba(0,0,0,.6);
|
|
504
|
-
background-image: url(images/ckplayer_ixigua.png);
|
|
504
|
+
background-image: url(./images/ckplayer_ixigua.png);
|
|
505
505
|
background-size: auto 100%;
|
|
506
506
|
border: none;
|
|
507
507
|
outline: none;
|
|
@@ -634,7 +634,7 @@
|
|
|
634
634
|
width: 30px;
|
|
635
635
|
height: 30px;
|
|
636
636
|
background-color: transparent;
|
|
637
|
-
background-image: url(images/adclose.png);
|
|
637
|
+
background-image: url(./images/adclose.png);
|
|
638
638
|
border: none;
|
|
639
639
|
outline: none;
|
|
640
640
|
cursor: pointer;
|
|
@@ -692,7 +692,7 @@
|
|
|
692
692
|
/*按钮公用样式*/
|
|
693
693
|
.ckplayer-ckplayer .ck-main .ck-bar-btn{
|
|
694
694
|
background-color: transparent;
|
|
695
|
-
background-image: url(images/ckplayer_ixigua.48.png);
|
|
695
|
+
background-image: url(./images/ckplayer_ixigua.48.png);
|
|
696
696
|
background-size: auto 100%;
|
|
697
697
|
border: none;
|
|
698
698
|
outline: none;
|
|
@@ -702,7 +702,7 @@
|
|
|
702
702
|
background-repeat: no-repeat ;
|
|
703
703
|
}
|
|
704
704
|
.ckplayer-ckplayer .ck-main.ck-main-full .ck-bar-btn{
|
|
705
|
-
background-image: url(images/ckplayer_ixigua.png);
|
|
705
|
+
background-image: url(./images/ckplayer_ixigua.png);
|
|
706
706
|
width: 70px;
|
|
707
707
|
height: 70px;
|
|
708
708
|
}
|
package/dist/ckplayer.js
CHANGED
|
@@ -136,10 +136,12 @@
|
|
|
136
136
|
keyVolume:2,//是否启用键盘控制音量调节,0=不启用,1=启用,2=全屏时才启用
|
|
137
137
|
errorShow:true,//是否显示错误信息
|
|
138
138
|
pluginPath:'',//插件与语言包根路径(bundler 下建议配置或设置 window.ckplayerBasePath)
|
|
139
|
-
autoPlug:true
|
|
139
|
+
autoPlug:true,//未指定 plug 时,根据视频地址后缀自动选择 hls.js / flv.js / mpegts.js
|
|
140
|
+
preferBuiltinPlug:true,//优先加载本包内置插件脚本,避免复用页面上其它版本的全局 Hls/flvjs/mpegts
|
|
141
|
+
cdnFallback:true// getPath 失败时是否回退到 jsDelivr(内网可设 false,并配置 pluginPath)
|
|
140
142
|
};
|
|
141
143
|
// 打包时替换为真实版本;用于 bundler 下 getPath 失效时的 CDN 回退
|
|
142
|
-
var ckplayerPlusDefaultCdn='https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.
|
|
144
|
+
var ckplayerPlusDefaultCdn='https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.3/dist/';
|
|
143
145
|
function ckplayerEmbed(videoObj){
|
|
144
146
|
/*
|
|
145
147
|
* rightMenu
|
|
@@ -392,7 +394,12 @@
|
|
|
392
394
|
if(fromScript && fromScript.indexOf(folder+'/')>-1 && fromScript.indexOf('undefined')===-1){
|
|
393
395
|
return fromScript;
|
|
394
396
|
}
|
|
397
|
+
var allowCdn=!vars || vars['cdnFallback']!==false;
|
|
395
398
|
var cdn=(typeof window!=='undefined' && window.ckplayerPlusCdn) ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
|
|
399
|
+
if(!allowCdn || !cdn || cdn.indexOf('1.0.3')>-1){
|
|
400
|
+
// 避免占位版本或显式关闭 CDN 时请求坏地址;交给相对路径或业务 pluginPath
|
|
401
|
+
return folder+'/'+file;
|
|
402
|
+
}
|
|
396
403
|
if(cdn.slice(-1)!=='/'){
|
|
397
404
|
cdn+='/';
|
|
398
405
|
}
|
|
@@ -773,6 +780,13 @@
|
|
|
773
780
|
else if(valType(vars['seek'])=='string' && vars['seek']!=='' && !isNaN(parseFloat(vars['seek']))){
|
|
774
781
|
seekTime=parseFloat(vars['seek']);
|
|
775
782
|
}
|
|
783
|
+
// 与旧版对齐:续播 seek 同步进度水位,避免 timeScheduleAdjust=5 时被打回 0
|
|
784
|
+
if(seekTime && seekTime>0){
|
|
785
|
+
maxSeeTime=Math.max(maxSeeTime,seekTime);
|
|
786
|
+
if(firstSeekTime<0){
|
|
787
|
+
firstSeekTime=seekTime;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
776
790
|
}
|
|
777
791
|
},
|
|
778
792
|
/*
|
|
@@ -849,7 +863,7 @@
|
|
|
849
863
|
video.attr('src',url);
|
|
850
864
|
}
|
|
851
865
|
};
|
|
852
|
-
if(typeof Hls!=='undefined' && !isUndefined(Hls)){
|
|
866
|
+
if(typeof Hls!=='undefined' && !isUndefined(Hls) && !vars['preferBuiltinPlug']){
|
|
853
867
|
startHls();
|
|
854
868
|
return;
|
|
855
869
|
}
|
|
@@ -892,7 +906,7 @@
|
|
|
892
906
|
});
|
|
893
907
|
}
|
|
894
908
|
};
|
|
895
|
-
if(typeof flvjs!=='undefined' && !isUndefined(flvjs)){
|
|
909
|
+
if(typeof flvjs!=='undefined' && !isUndefined(flvjs) && !vars['preferBuiltinPlug']){
|
|
896
910
|
startFlv();
|
|
897
911
|
return;
|
|
898
912
|
}
|
|
@@ -936,7 +950,7 @@
|
|
|
936
950
|
});
|
|
937
951
|
}
|
|
938
952
|
};
|
|
939
|
-
if(typeof mpegts!=='undefined' && !isUndefined(mpegts)){
|
|
953
|
+
if(typeof mpegts!=='undefined' && !isUndefined(mpegts) && !vars['preferBuiltinPlug']){
|
|
940
954
|
startMpegts();
|
|
941
955
|
return;
|
|
942
956
|
}
|
|
@@ -1603,6 +1617,13 @@
|
|
|
1603
1617
|
if(dur && isFinite(dur) && dur>0 && t>=dur){
|
|
1604
1618
|
t=Math.max(0,dur-0.3);
|
|
1605
1619
|
}
|
|
1620
|
+
// 续播水位同步(mode=5 依赖 maxSeeTime)
|
|
1621
|
+
if(t>0){
|
|
1622
|
+
maxSeeTime=Math.max(maxSeeTime,t);
|
|
1623
|
+
if(firstSeekTime<0){
|
|
1624
|
+
firstSeekTime=t;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1606
1627
|
seekTime=0;
|
|
1607
1628
|
try{
|
|
1608
1629
|
video.currentTime=t;
|
|
@@ -2843,6 +2864,13 @@
|
|
|
2843
2864
|
target=parseFloat(fn);
|
|
2844
2865
|
}
|
|
2845
2866
|
if(target!==null && video){
|
|
2867
|
+
// 续播水位需在 timeScheduleAdjust 校验前同步,否则 mode=5 会把 seek 打回 0
|
|
2868
|
+
if(target>0 && ((seekTime && Math.abs(seekTime-target)<0.5) || (vars['seek'] && parseFloat(vars['seek'])>0 && Math.abs(parseFloat(vars['seek'])-target)<0.5))){
|
|
2869
|
+
maxSeeTime=Math.max(maxSeeTime,target);
|
|
2870
|
+
if(firstSeekTime<0){
|
|
2871
|
+
firstSeekTime=target;
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2846
2874
|
switch(vars['timeScheduleAdjust']){
|
|
2847
2875
|
case 0://禁止拖动
|
|
2848
2876
|
message(language['timeScheduleAdjust']['prohibit']);
|
|
@@ -2883,6 +2911,12 @@
|
|
|
2883
2911
|
var ready=video.readyState>=2 || (duration && isFinite(duration) && duration>0);
|
|
2884
2912
|
if(!ready){
|
|
2885
2913
|
seekTime=target;
|
|
2914
|
+
if(target>0){
|
|
2915
|
+
maxSeeTime=Math.max(maxSeeTime,target);
|
|
2916
|
+
if(firstSeekTime<0){
|
|
2917
|
+
firstSeekTime=target;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2886
2920
|
try{video.currentTime=target;}catch(event){}
|
|
2887
2921
|
return player;
|
|
2888
2922
|
}
|
|
@@ -2892,9 +2926,16 @@
|
|
|
2892
2926
|
if(target<0){
|
|
2893
2927
|
target=0;
|
|
2894
2928
|
}
|
|
2929
|
+
// API 续播:若水位仍低于目标且目标等于初始化 seek,抬高水位
|
|
2930
|
+
if(vars['timeScheduleAdjust']==5 && target>maxSeeTime && seekTime && Math.abs(seekTime-target)<0.5){
|
|
2931
|
+
maxSeeTime=Math.max(maxSeeTime,target);
|
|
2932
|
+
}
|
|
2895
2933
|
try{
|
|
2896
2934
|
video.currentTime=target;
|
|
2897
2935
|
seekTime=0;
|
|
2936
|
+
if(target>maxSeeTime && vars['timeScheduleAdjust']!=5){
|
|
2937
|
+
maxSeeTime=target;
|
|
2938
|
+
}
|
|
2898
2939
|
}catch(event){
|
|
2899
2940
|
seekTime=target;
|
|
2900
2941
|
}
|