zwplayer-vue2x 1.0.30 → 1.0.31
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/package.json
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// zwplayer tools
|
|
2
|
+
|
|
3
|
+
const zwplayer_loadjs = function(id,url,cb) {
|
|
4
|
+
let headNode = document.getElementsByTagName("head");
|
|
5
|
+
|
|
6
|
+
if (headNode.length == 0) {
|
|
7
|
+
headNode = document.createElement("head");
|
|
8
|
+
let body = document.getElementsByTagName("body");
|
|
9
|
+
if (body.length > 0) {
|
|
10
|
+
body = body[0];
|
|
11
|
+
document.insertBefore(headNode,body);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
alert('Invalid html document: no HEAD tag');
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
headNode = headNode[0];
|
|
20
|
+
const nodes = headNode.childNodes;
|
|
21
|
+
|
|
22
|
+
for (let i = 0; i < nodes.length; i ++) {
|
|
23
|
+
const node = nodes[i];
|
|
24
|
+
if (node.nodeName.toUpperCase() === 'SCRIPT') {
|
|
25
|
+
if (node.id && node.id == id) {
|
|
26
|
+
if (node.getAttribute('loadstate') != 'true') {
|
|
27
|
+
const checkLoad = function () {
|
|
28
|
+
if (node.getAttribute('loadstate') != 'true') {
|
|
29
|
+
setTimeout(checkLoad,50);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (typeof cb == 'function') cb(id);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
setTimeout(checkLoad,50);
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof cb == 'function') cb(id);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const script = document.createElement("script");
|
|
48
|
+
|
|
49
|
+
script.type = "text/javascript";
|
|
50
|
+
|
|
51
|
+
if(script.readyState){ // IE
|
|
52
|
+
script.onreadystatechange = function(){
|
|
53
|
+
if(script.readyState == "loaded" || script.readyState == "complete"){
|
|
54
|
+
script.onreadystatechange = null;
|
|
55
|
+
script.setAttribute('loadstate','true');
|
|
56
|
+
if (typeof cb == 'function') cb(id);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
script.onload = function(){
|
|
62
|
+
script.setAttribute('loadstate','true');
|
|
63
|
+
script.setAttribute('charset','utf-8');
|
|
64
|
+
if (typeof cb == 'function') cb(id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
script.id = id;
|
|
68
|
+
script.src = url;
|
|
69
|
+
|
|
70
|
+
headNode.appendChild(script);
|
|
71
|
+
|
|
72
|
+
return false;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
module.exports.zwplayer_loadjs = zwplayer_loadjs;
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
<!-- zwplayer for vue -->
|
|
2
|
+
<script>
|
|
3
|
+
// import { h } from 'vue'
|
|
4
|
+
import { zwplayer_loadjs } from "./loadjs.js";
|
|
5
|
+
|
|
6
|
+
const zwplayer_js_def = 'zwplayer/zwplayer.js?v=3.6';
|
|
7
|
+
|
|
8
|
+
const availabe_props = {
|
|
9
|
+
isLive: 'boolean',
|
|
10
|
+
useOldFlv: 'boolean',
|
|
11
|
+
useFlv: 'boolean',
|
|
12
|
+
streamtype: 'string',
|
|
13
|
+
hasAudio: 'boolean',
|
|
14
|
+
hasVideo: 'boolean',
|
|
15
|
+
xmc_url: 'string',
|
|
16
|
+
fixedControlbar: 'boolean',
|
|
17
|
+
nativecontrols: 'boolean',
|
|
18
|
+
infoButton: 'boolean',
|
|
19
|
+
speedButton: 'boolean',
|
|
20
|
+
optionButton: 'boolean',
|
|
21
|
+
snapshotButton: 'boolean',
|
|
22
|
+
chapterButton: 'boolean',
|
|
23
|
+
enableDanmu: 'boolean',
|
|
24
|
+
useProgressTooltip: 'boolean',
|
|
25
|
+
hidePlayBtn: 'boolean',
|
|
26
|
+
disablePlayBtn: 'boolean',
|
|
27
|
+
disableSeek: 'boolean',
|
|
28
|
+
disableFullscreenWin: 'boolean',
|
|
29
|
+
disablePicInPic: 'boolean',
|
|
30
|
+
disableVolumeControl: 'boolean',
|
|
31
|
+
lostFocusPause: 'boolean',
|
|
32
|
+
autoSmallWindow: 'boolean',
|
|
33
|
+
thumbnails: 'object',
|
|
34
|
+
sendDanmu: 'function',
|
|
35
|
+
danmuBarId: 'string',
|
|
36
|
+
fluid: 'boolean',
|
|
37
|
+
poster: 'string',
|
|
38
|
+
logo: 'object|string',
|
|
39
|
+
ratio: 'string|number',
|
|
40
|
+
width: 'string|number',
|
|
41
|
+
height: 'string|number'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
name: 'ZwPlayer',
|
|
46
|
+
data () {
|
|
47
|
+
return {
|
|
48
|
+
zwplayer: null,
|
|
49
|
+
nodename: 'ZwPlayer'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
props: {
|
|
53
|
+
zwplayerlib: String,
|
|
54
|
+
murl: String,
|
|
55
|
+
nodeid: String,
|
|
56
|
+
muted: Boolean,
|
|
57
|
+
autoplay: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: true
|
|
60
|
+
},
|
|
61
|
+
videoprop: Object,
|
|
62
|
+
videostyle: String,
|
|
63
|
+
reconnect: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: true
|
|
66
|
+
},
|
|
67
|
+
controlbar: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: true
|
|
70
|
+
},
|
|
71
|
+
useProgressTooltip: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
emits: ['oneterror', 'onmediaevent', 'onready'],
|
|
78
|
+
methods: {
|
|
79
|
+
play(url, isLive, useOldFlv) {
|
|
80
|
+
let vm = this;
|
|
81
|
+
|
|
82
|
+
if (!url)
|
|
83
|
+
url = this.murl;
|
|
84
|
+
if (!vm.zwplayer)
|
|
85
|
+
return;
|
|
86
|
+
|
|
87
|
+
vm.zwplayer.play(url, isLive, useOldFlv);
|
|
88
|
+
},
|
|
89
|
+
stop() {
|
|
90
|
+
let vm = this;
|
|
91
|
+
|
|
92
|
+
if (vm.zwplayer) {
|
|
93
|
+
vm.zwplayer.stop();
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
pause() {
|
|
97
|
+
let vm = this;
|
|
98
|
+
|
|
99
|
+
if (vm.zwplayer) {
|
|
100
|
+
vm.zwplayer.pause();
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
resume() {
|
|
104
|
+
let vm = this;
|
|
105
|
+
if (vm.zwplayer) {
|
|
106
|
+
vm.zwplayer.resume();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
getDuration() {
|
|
110
|
+
let vm = this;
|
|
111
|
+
if (vm.zwplayer) {
|
|
112
|
+
return vm.zwplayer.getDuration();
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
getCurrentTime() {
|
|
118
|
+
let vm = this;
|
|
119
|
+
if (vm.zwplayer) {
|
|
120
|
+
return vm.zwplayer.CurrentTime;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
seekTime(time) {
|
|
126
|
+
let vm = this;
|
|
127
|
+
|
|
128
|
+
if (vm.zwplayer) {
|
|
129
|
+
vm.zwplayer.seekTime(time);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
destroy() {
|
|
133
|
+
let vm = this;
|
|
134
|
+
|
|
135
|
+
if (vm.zwplayer) {
|
|
136
|
+
vm.zwplayer.destroy();
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
setplaystate(bPlaying) {
|
|
140
|
+
let vm = this;
|
|
141
|
+
|
|
142
|
+
if (vm.zwplayer) {
|
|
143
|
+
vm.zwplayer.setplaystate(bPlaying);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
setEnableDanmu(bEnable) {
|
|
148
|
+
let vm = this;
|
|
149
|
+
|
|
150
|
+
if (vm.zwplayer) {
|
|
151
|
+
vm.zwplayer.setEnableDanmu(bEnable);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
appendDanmu(msgObj, setting) {
|
|
156
|
+
let vm = this;
|
|
157
|
+
|
|
158
|
+
if (vm.zwplayer) {
|
|
159
|
+
vm.zwplayer.appendDanmu(msgObj, setting);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
setChapters(chapters) {
|
|
164
|
+
let vm = this;
|
|
165
|
+
|
|
166
|
+
if (vm.zwplayer) {
|
|
167
|
+
vm.zwplayer.setChapters(chapters);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
addSubtitle(subtitleUrl, pos, title) {
|
|
172
|
+
let vm = this;
|
|
173
|
+
|
|
174
|
+
if (vm.zwplayer) {
|
|
175
|
+
vm.zwplayer.addSubtitle(subtitleUrl, pos, title);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
removeSubtitle() {
|
|
180
|
+
let vm = this;
|
|
181
|
+
|
|
182
|
+
if (vm.zwplayer) {
|
|
183
|
+
vm.zwplayer.removeSubtitle();
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
buildDanmuControlbar(parentId, className) {
|
|
188
|
+
let vm = this;
|
|
189
|
+
|
|
190
|
+
if (vm.zwplayer) {
|
|
191
|
+
vm.zwplayer.buildDanmuControlbar(parentId, className);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
notifyResize(width, height) {
|
|
196
|
+
let vm = this;
|
|
197
|
+
|
|
198
|
+
if (vm.zwplayer) {
|
|
199
|
+
vm.zwplayer.notifyResize(width, height);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
setMute(bMute) {
|
|
204
|
+
let vm = this;
|
|
205
|
+
|
|
206
|
+
if (vm.zwplayer) {
|
|
207
|
+
vm.zwplayer.setMuted(bMute);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
setullscr(bFullScr) {
|
|
212
|
+
let vm = this;
|
|
213
|
+
|
|
214
|
+
if (vm.zwplayer) {
|
|
215
|
+
vm.is_fullscr = bFullScr;
|
|
216
|
+
vm.zwplayer.setFullscreen(bFullScr);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
computed: {
|
|
222
|
+
CurrentTime: function() {
|
|
223
|
+
let vm = this;
|
|
224
|
+
if (vm.zwplayer) {
|
|
225
|
+
return vm.zwplayer.CurrentTime;
|
|
226
|
+
}
|
|
227
|
+
return -1;
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
render(createElement) {
|
|
232
|
+
let playerid;
|
|
233
|
+
|
|
234
|
+
// console.log('render');
|
|
235
|
+
if (this.nodeid) {
|
|
236
|
+
playerid = this.nodeid;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
let now = (new Date()).getTime();
|
|
240
|
+
|
|
241
|
+
if (!window.nextZWPlayerId) {
|
|
242
|
+
window.nextZWPlayerId = 1000;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
window.nextZWPlayerId++;
|
|
246
|
+
}
|
|
247
|
+
playerid = 'zwplayer-'+ window.nextZWPlayerId + '-' + now;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let playerWrap = createElement('div', {
|
|
251
|
+
class: {'zwplayer-vue': true},
|
|
252
|
+
attrs: {
|
|
253
|
+
id: playerid,
|
|
254
|
+
},
|
|
255
|
+
}, []);
|
|
256
|
+
|
|
257
|
+
if (playerWrap) {
|
|
258
|
+
let vm = this;
|
|
259
|
+
vm.playerid = playerid;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (this.zwplayer && this.murl !== this.old_murl) {
|
|
263
|
+
this.zwplayer.play(this.murl); // change movie url
|
|
264
|
+
this.old_murl = this.murl;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return playerWrap;
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
mounted() {
|
|
271
|
+
let vm = this;
|
|
272
|
+
// console.log('mounted');
|
|
273
|
+
let zwplayer_js;
|
|
274
|
+
|
|
275
|
+
if (vm.zwplayerlib)
|
|
276
|
+
zwplayer_js = vm.zwplayerlib;
|
|
277
|
+
else
|
|
278
|
+
zwplayer_js = zwplayer_js_def;
|
|
279
|
+
|
|
280
|
+
vm.rootElm = document.getElementById(vm.playerid);
|
|
281
|
+
if (vm.rootElm) {
|
|
282
|
+
vm.rootElm.style.width = '100%';
|
|
283
|
+
vm.rootElm.style.height = '100%';
|
|
284
|
+
vm.rootElm.style.margin = '0';
|
|
285
|
+
vm.rootElm.style.padding = '0';
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
zwplayer_loadjs('zwplayer-core', zwplayer_js, function(jsid) {
|
|
289
|
+
let url = '';
|
|
290
|
+
|
|
291
|
+
if (!jsid) {
|
|
292
|
+
console.log('zwplayer_loadjs failed!');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (vm.murl)
|
|
296
|
+
url = vm.murl;
|
|
297
|
+
else if (vm.videoprop && typeof vm.videoprop.url !== 'undefined')
|
|
298
|
+
url = vm.videoprop.url;
|
|
299
|
+
let videostyle = "width:100%;height:100%;";
|
|
300
|
+
if (vm.videoprop && typeof vm.videoprop.videostyle !== 'undefined')
|
|
301
|
+
videostyle = vm.videoprop.videostyle;
|
|
302
|
+
|
|
303
|
+
let params = {
|
|
304
|
+
url: url,
|
|
305
|
+
playerElm: vm.rootElm,
|
|
306
|
+
videostyle: videostyle,
|
|
307
|
+
reconnect: vm.reconnect,
|
|
308
|
+
autoplay: vm.autoplay,
|
|
309
|
+
muted: vm.muted,
|
|
310
|
+
controlbar: vm.controlbar,
|
|
311
|
+
useProgressTooltip: vm.useProgressTooltip,
|
|
312
|
+
onready: function() {
|
|
313
|
+
vm.$emit('onready', this);
|
|
314
|
+
},
|
|
315
|
+
onnetclose: function() {
|
|
316
|
+
vm.$emit('onnetclose', this);
|
|
317
|
+
return true;
|
|
318
|
+
},
|
|
319
|
+
onneterror: function() {
|
|
320
|
+
vm.$emit('onneterror', this);
|
|
321
|
+
},
|
|
322
|
+
onmediaevent: function(event) {
|
|
323
|
+
vm.$emit('onmediaevent', event, this);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
let props_list = availabe_props;
|
|
328
|
+
|
|
329
|
+
const isTypeOf = function(type, types) {
|
|
330
|
+
if (types.indexOf('|') > 0) {
|
|
331
|
+
var typeList = types.split('|');
|
|
332
|
+
for(let i = 0; i < typeList.length; i++) {
|
|
333
|
+
if (type === typeList[i])
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return type === types;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
for (let prop in vm.$attrs) {
|
|
343
|
+
var propType = typeof vm.$attrs[prop];
|
|
344
|
+
if (prop in props_list && isTypeOf(propType, props_list[prop])) {
|
|
345
|
+
if (propType === 'object')
|
|
346
|
+
params[prop] = JSON.parse(JSON.stringify(vm.$attrs[prop])); // copy property
|
|
347
|
+
else
|
|
348
|
+
params[prop] = vm.$attrs[prop];
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
vm.zwplayer = new window.ZWPlayer(params);
|
|
353
|
+
|
|
354
|
+
if(params.danmuBarId) {
|
|
355
|
+
vm.zwplayer.buildDanmuControlbar(params.danmuBarId, 'vue-zwp-danmubar');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
vm.old_murl = url;
|
|
359
|
+
})
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
beforeDestroy() { // vue3.x beforeUnmount
|
|
363
|
+
let vm = this;
|
|
364
|
+
// console.log('beforeUnmount');
|
|
365
|
+
if (vm.zwplayer) {
|
|
366
|
+
vm.zwplayer.stop();
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
destroyed() { // vue3.x unmounted
|
|
371
|
+
let vm = this;
|
|
372
|
+
// console.log('unmounted');
|
|
373
|
+
if (vm.zwplayer) {
|
|
374
|
+
vm.zwplayer.destroy();
|
|
375
|
+
delete vm.zwplayer;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
</script>
|
|
380
|
+
|
|
@@ -341,15 +341,15 @@ this.setEnableDanmu(!1),H.find(".barrage_inp_text").attr("readonly","readonly").
|
|
|
341
341
|
H.stopPropagation();this.zwplayer=r;qb(H,this)});(l=r.danmuToolbar.querySelector(".btn_bubble"))&&l.addEventListener("click",function(H){H.preventDefault();H.stopPropagation();gb(this,H)});(l=r.danmuToolbar.querySelector(".btn_submit"))&&l.addEventListener("click",function(H){H.preventDefault();H.stopPropagation();a:{if(!this.inpbox){$inpbox=$$(this).parent().children("DIV.zwp-barrage_inp").children(".barrage_inp_text");if(!$inpbox)break a;this.inpbox=$inpbox}if(r){H=this.inpbox.val();if(H=="")break a;
|
|
342
342
|
H.indexOf("&")!=-1&&(H=H.replace(/&/g,"&"));H.indexOf("<")!=-1&&(H=H.replace(/</g,"<"));H.indexOf(">")!=-1&&(H=H.replace(/>/g,">"));H.indexOf('"')!=-1&&(H=H.replace(/"/g,"""));H.indexOf("'")!=-1&&(H=H.replace(/'/g,"'"));if(!r.sendDanmu(H))break a}this.inpbox.val("")}})}}.bind(c);c.reposDanmuToolbar=function(d){if(this.danmuToolbar&&this.progressBar&&this.progressBar.timeInfo){var l=this.__getDanmuBarDock(),r=this.danmuToolbar.parentNode;r&&(d?r!==l&&(r.removeChild(this.danmuToolbar),
|
|
343
343
|
l.appendChild(this.danmuToolbar),this.oldDanmuParentNode=r):this.oldDanmuParentNode&&(l.removeChild(this.danmuToolbar),this.oldDanmuParentNode.appendChild(this.danmuToolbar),delete this.oldDanmuParentNode))}}.bind(c);c.sendDanmu=function(d){if(typeof this._config.sendDanmu==="function"){var l="";this.danmuSetting.border&&(l+=',"border":"1"');this.danmuSetting.color&&(l+=',"color":"#'+this.danmuSetting.color+'"');this._config.sendDanmu('{"type":"danmu","text":"'+d+'"'+l+"}");return!0}alert("No danmu send function is setup");
|
|
344
|
-
return!1}.bind(c);c.showContextMenu=function(d){var l=this,r=d.offsetX;d=d.offsetY;var B=l.playerContainer.getBoundingClientRect(),H=B.width;B=B.height;var P="left",O="top",W=r,S=d;r+180>H&&(P="right",W=H-r);d+148>B&&(O="bottom",S=B-d);if(l.contextMenu)l.contextMenu.style[P==="left"?"right":"left"]=null,l.contextMenu.style[O==="top"?"bottom":"top"]=null,l.contextMenu.style[P]=W+"px",l.contextMenu.style[O]=S+"px";else{r='<div class="zwp-popupmenu" style="'+P+": "+W+"px; "+O+":"+S+'px;"><a class="zwp-menuitem" data-action="document" href="https://www.zwplayer.
|
|
345
|
-
(pa("player-help","Help and document")+"</span></a>");r+='<a class="zwp-menuitem" data-action="version" href="https://www.zwplayer.
|
|
344
|
+
return!1}.bind(c);c.showContextMenu=function(d){var l=this,r=d.offsetX;d=d.offsetY;var B=l.playerContainer.getBoundingClientRect(),H=B.width;B=B.height;var P="left",O="top",W=r,S=d;r+180>H&&(P="right",W=H-r);d+148>B&&(O="bottom",S=B-d);if(l.contextMenu)l.contextMenu.style[P==="left"?"right":"left"]=null,l.contextMenu.style[O==="top"?"bottom":"top"]=null,l.contextMenu.style[P]=W+"px",l.contextMenu.style[O]=S+"px";else{r='<div class="zwp-popupmenu" style="'+P+": "+W+"px; "+O+":"+S+'px;"><a class="zwp-menuitem" data-action="document" href="https://www.zwplayer.cn/docs/support.html" target="zwplayer-doc"><span class="zwp-menucaption">'+
|
|
345
|
+
(pa("player-help","Help and document")+"</span></a>");r+='<a class="zwp-menuitem" data-action="version" href="https://www.zwplayer.cn/pages/company/changelog.html?v=3.1.5" title="Build: 20251101" target="zwplayer-version"><span class="zwp-menucaption">'+pa("version-update","Version update")+' (<span class="zwp-version">'+pa("current")+": v3.1.5</span>) </span></a>";r=r+'<span class="zwp-menuseperator" action="version"></span><a class="zwp-menuitem" data-action="about" href="https://www.zwplayer.cn/pages/company/about.html"><span class="zwp-menucaption">'+
|
|
346
346
|
(pa("about","About")+" zwplayer</span></a>");l.playerContainer.insertAdjacentHTML("beforeEnd",r+"</div>");l.contextMenu=l.playerContainer.querySelector(".zwp-popupmenu");var U=function(g){g.stopPropagation();g.preventDefault();var t=this.getAttribute("data-action");this.getAttribute("target");var u=this.getAttribute("href");l.hideContextMenu();setTimeout(function(){t==="about"?K.open(u,"zwplayer-about"):t==="version"?K.open(u,"zwplayer-version"):t==="document"&&K.open(u,"zwplayer-doc")},10)};l.contextMenu.querySelectorAll("a.zwp-menuitem").forEach(function(g){g.addEventListener("click",
|
|
347
347
|
U,!1)});document.addEventListener("click",l.hideContextMenu)}}.bind(c);c.hideContextMenu=function(){this.contextMenu&&(this.playerContainer.removeChild(this.contextMenu),delete this.contextMenu,document.removeEventListener("click",this.hideContextMenu))}.bind(c);c.toast=function(d,l,r,B){var H=this;l=l||2E3;H.toastTimerId&&(clearTimeout(H.toastTimerId),H.toastBox&&(H.overlay_layers.removeChild(H.toastBox),delete H.toastBox));if(d!=="closetoast"){if(typeof d==="object"){if("icon"in d)var P=d.icon;
|
|
348
348
|
d=d.text}var O=document.createElement("div"),W="",S="zwp-toast zwp-center";P&&(S+=" zwp-toast-icon",W='<i class="xicon xicon-'+P+'"></i>');r&&(W+='<a href="javascript:void(0)" class="zwp-toast-closebtn"><i class="xicon xicon-close"></i></a>',S+=" zwp-use-close");B&&(S+=" zwp-lite");W+='<span class="zwp-toast-text">'+d+"</span>";O.setAttribute("class",S);O.innerHTML=W;H.overlay_layers.appendChild(O);H.toastBox=O;var U=function(g){if(H.toastBox){var t=H.toastBox.querySelector(".zwp-toast-closebtn");
|
|
349
349
|
t&&t.removeEventListener("click",U);H.overlay_layers.removeChild(H.toastBox);delete H.toastBox}H.toastTimerId&&(g&&g.type==="click"&&clearTimeout(H.toastTimerId),delete H.toastTimerId)};H.toastTimerId=K.setTimeout(U,l);r&&(r=O.querySelector(".zwp-toast-closebtn"))&&r.addEventListener("click",U)}}.bind(c);c.mutedConfirmBox=function(){var d=this;d.popup_layers||(d.popup_layers=document.createElement("div"),d.popup_layers.setAttribute("class","zwp__popup_layers"),d.playerContainer.appendChild(d.popup_layers));
|
|
350
|
-
var l=document.createElement("div");l.setAttribute("class","zwp-toast zwp-confirm zwp-center");l.innerHTML='<span class="zwp-toast-text">\u56e0<a href="#mutemore" class="mutemore">\u6d4f\u89c8\u5668\u9650\u5236</a>\uff0c\
|
|
351
|
-
r&&r.addEventListener("click",function(B){B.preventDefault();d.mutedTipBox&&(d.popup_layers.removeChild(d.mutedTipBox),d.popup_layers.style.display=null,delete d.mutedTipBox);K.allowAutoAudioPlay=!0});(r=l.querySelector(".openaudio"))&&r.addEventListener("click",function(B){B.preventDefault();B.stopPropagation();d.mutedTipBox&&(d.popup_layers.removeChild(d.mutedTipBox),d.popup_layers.style.display=null,delete d.mutedTipBox);d.setMuted(!1);K.allowAutoAudioPlay=!0});(r=
|
|
352
|
-
r.addEventListener("click",function(B){B.preventDefault();B.stopPropagation();var H=l.querySelector(".moreInfoBox");H||(l.insertAdjacentHTML("beforeend",'<div class="moreInfoBox"><div class="info-text">\u5f53\
|
|
350
|
+
var l=document.createElement("div");l.setAttribute("class","zwp-toast zwp-confirm zwp-center");l.innerHTML='<span class="zwp-toast-text">\u56e0<a href="#mutemore" class="mutemore">\u6d4f\u89c8\u5668\u9650\u5236</a>\uff0c\u5df2\u9759\u97f3\u64ad\u653e\uff0c\u8bf7\u70b9\u51fb<a href="#openaudio" class="openaudio">\u6253\u5f00\u58f0\u97f3</a><button class="closeBtn" title="\u5173\u95ed\u63d0\u793a"><i class="xicon xicon-close"></i></button></span>';d.popup_layers.appendChild(l);d.mutedTipBox=l;var r=
|
|
351
|
+
l.querySelector(".closeBtn");r&&r.addEventListener("click",function(B){B.preventDefault();d.mutedTipBox&&(d.popup_layers.removeChild(d.mutedTipBox),d.popup_layers.style.display=null,delete d.mutedTipBox);K.allowAutoAudioPlay=!0});(r=l.querySelector(".openaudio"))&&r.addEventListener("click",function(B){B.preventDefault();B.stopPropagation();d.mutedTipBox&&(d.popup_layers.removeChild(d.mutedTipBox),d.popup_layers.style.display=null,delete d.mutedTipBox);d.setMuted(!1);K.allowAutoAudioPlay=!0});(r=
|
|
352
|
+
l.querySelector(".mutemore"))&&r.addEventListener("click",function(B){B.preventDefault();B.stopPropagation();var H=l.querySelector(".moreInfoBox");H||(l.insertAdjacentHTML("beforeend",'<div class="moreInfoBox"><div class="info-text">\u5f53\u60a8\u8bbf\u95ee\u672c\u7f51\u7ad9\u7684\u6b21\u6570\u8f83\u5c11\uff0c\u6216\u7ecf\u5e38\u9759\u97f3\u64ad\u653e\u65f6\uff0c\u6d4f\u89c8\u5668\u53ef\u80fd\u4f1a\u9650\u5236\u7f51\u7ad9\u97f3\u91cf\uff0c\u5bfc\u81f4\u7f51\u7ad9\u65e0\u6cd5\u8fdb\u884c\u6709\u58f0\u81ea\u52a8\u64ad\u653e\u3002</div><div class="info-control"><button class="info-btn">\u6211\u77e5\u9053\u4e86</button></div></div>'),
|
|
353
353
|
H=l.querySelector(".moreInfoBox"),H.querySelector(".info-btn").addEventListener("click",function(P){P.preventDefault();P.stopPropagation();H.style.display="none"}));H&&(H.style.display="block");K.allowAutoAudioPlay=!0});d.popup_layers.style.display="block"}.bind(c);typeof c._config.playerElm=="string"?(e=c._config.playerElm,e.charAt(0)!="#"&&(e="#"+e),c.playerElm=document.querySelector(e)):Ua(c._config.playerElm)&&(c.playerElm=c._config.playerElm);c.playerElm?L(c.playerElm,"zwp-wrap")||(c.playerElmOldClass=
|
|
354
354
|
c.playerElm.getAttribute("class"),N(c.playerElm,"zwp-wrap"),c.doRemovePlayerClass=!0):(e="",typeof c._config.playerElm=="string"?(e=c._config.playerElm,e.charAt(0)=="#"&&(e=e.substr(1))):e="ZWP-"+(new Date).getTime(),c.playerElm=document.createElement("DIV"),c.playerElm.id=e,c.playerElm.style.position="absolute",c.playerElm.style.left=0,c.playerElm.style.top=0,c.playerElm.style.width="640px",c.playerElm.style.height="360px",document.body.appendChild(c.playerElm),c.playerElm.setAttribute("class","zwp-wrap"),
|
|
355
355
|
c.doDeletePlayerElm=!0);c.playerContainer=document.createElement("DIV");c.playerContainer.setAttribute("class","zwp-container");c.playerElm.appendChild(c.playerContainer);typeof c._config.videoElm=="string"?(e=c._config.videoElm,e.charAt(0)!="#"&&(e="#"+e),c.videoEl=document.querySelector(e)):Ua(c._config.videoElm)&&(c.videoEl=c._config.videoElm);if(!c.videoEl){var E=document.createElement("DIV");E.setAttribute("class","zwp-videoWrapper");c.playerContainer.appendChild(E);Ba.addElement(E);E.addEventListener("resize",
|
|
@@ -369,8 +369,8 @@ c.on_volthumb_mousemove),document.addEventListener("mouseup",c.on_volthumb_mouse
|
|
|
369
369
|
"none"});V.addEventListener("mouseleave",function(){m=!1;h||(la.style.display="none")});V.addEventListener("focusout",function(){m=!1});V.addEventListener("keydown",function(d){var l=d.which||d.keyCode||0;d.preventDefault();d.stopPropagation();l==32&&(c.videoEl.muted?c.setMuted(!1):c.setMuted(!0))});la.addEventListener("dragstart",function(){return!1});la.addEventListener("mouseover",function(){m=!0});la.addEventListener("focusin",function(){la.style.display="block";m=!0});la.addEventListener("focusout",
|
|
370
370
|
function(){m=!1;h||(la.style.display="none")});la.addEventListener("mousedown",c.on_volthumb_mousedown)}if(A=p.querySelector(".zwp-optionPanel"))A=A.querySelectorAll(".action-item"),A.length>0&&A.forEach(function(d){d.addEventListener("click",c.on_optionItemclick)})}}c._config.autoSmallWindow&&!c.windowScrollHandler&&(c.windowScrollHandler=function(d){if(!this.isFullscr&&!this.isFullscrWin&&this.videoEl&&this.playerElm&&this.isPlaying&&!this.isInPicInPic)if(d=w(this.playerElm),(document.documentElement.scrollTop||
|
|
371
371
|
document.body.scrollTop)>=d+this.playerElm.offsetHeight-100){if(!this.smallWindowMode){var l=this.playerContainer;hb(l,function(){Q(l,"zwp-smallwindow");l.style.left=null;l.style.top=null;l.style.width=null;l.style.height=null});N(l,"zwp-smallwindow");this.smallWindowMode=!0}}else this.smallWindowMode&&(l=this.playerContainer,Q(l,"zwp-smallwindow"),l.style.left=null,l.style.top=null,l.style.width=null,l.style.height=null,delete this.smallWindowMode)}.bind(c),K.addEventListener("scroll",c.windowScrollHandler));
|
|
372
|
-
c._config.clientip||(c._config.clientip="");c.videoEl&&(c._config.muted?c.setMuted(!0):typeof K.allowAutoAudioPlay==="undefined"?(c.setMuted(!0),cb(function(d){d?c.setMuted(!1):c.mutedConfirmBox();K.allowAutoAudioPlay=d})):K.allowAutoAudioPlay||(c.setMuted(!0),c.mutedConfirmBox()),(c._config.snapshotButton||c._config.allowSnapshot)&&c.videoEl.setAttribute("crossorigin","Anonymous"));A=function(d){var l=this;if(l.controlbar)if(l.isControlbarhidden){l.controlbar.style.display=
|
|
373
|
-
d=d||K.event;if(d.srcElement!=l.controlbar&&l.overlay_layers){var r=l.overlay_layers.offsetHeight,B=0;typeof d.offsetY!=="undefined"?B=r-d.offsetY:typeof d.layerY!=="undefined"&&(B=r-d.layerY);if(B>80)return}Pa(l.controlbar,500,function(H){H&&l.startHideControlbar(l)});l.isControlbarhidden=!1}else l.startHideControlbar(l)}.bind(c);c.playerElm.addEventListener("mousemove",A);c.playerElm.addEventListener("touchmove",A);c.playerElm.addEventListener("dblclick",function(d){this.overlayLayerClickTimer&&
|
|
372
|
+
c._config.clientip||(c._config.clientip="");c.videoEl&&(c._config.muted?c.setMuted(!0):typeof K.allowAutoAudioPlay==="undefined"?(c.setMuted(!0),cb(function(d){d?c.setMuted(!1):c._config.disableMutedConfirm||c.mutedConfirmBox();K.allowAutoAudioPlay=d})):K.allowAutoAudioPlay||(c.setMuted(!0),c.mutedConfirmBox()),(c._config.snapshotButton||c._config.allowSnapshot)&&c.videoEl.setAttribute("crossorigin","Anonymous"));A=function(d){var l=this;if(l.controlbar)if(l.isControlbarhidden){l.controlbar.style.display=
|
|
373
|
+
"flex";Q(l.playerElm,"hide-cursor");d=d||K.event;if(d.srcElement!=l.controlbar&&l.overlay_layers){var r=l.overlay_layers.offsetHeight,B=0;typeof d.offsetY!=="undefined"?B=r-d.offsetY:typeof d.layerY!=="undefined"&&(B=r-d.layerY);if(B>80)return}Pa(l.controlbar,500,function(H){H&&l.startHideControlbar(l)});l.isControlbarhidden=!1}else l.startHideControlbar(l)}.bind(c);c.playerElm.addEventListener("mousemove",A);c.playerElm.addEventListener("touchmove",A);c.playerElm.addEventListener("dblclick",function(d){this.overlayLayerClickTimer&&
|
|
374
374
|
(K.clearTimeout(this.overlayLayerClickTimer),delete this.overlayLayerClickTimer);if(this.controlbar&&(d={},d.currentTarget=this.controlbar.querySelector(".zwp-fullscrBtn"),d.currentTarget))this.on_btnclick(d)}.bind(c));typeof c._config.autoplay=="undefined"&&(c._config.autoplay=!0);c._config.url&&c._config.autoplay&&c.play(c._config.url);typeof c._config.onready=="function"&&c._config.onready.call(c);c._config.chapters&&(c.chapters=c._config.chapters);c._config.lostFocusPause&&typeof document.visibilityState!==
|
|
375
375
|
"undefined"&&document.addEventListener("visibilitychange",function(){this._config.isLive||this.isInPicInPic||(document.visibilityState==="visible"?this.focusPaused&&this.videoEl.paused&&!this.videoEl.ended&&(this.videoEl.play(),this.setplaystate(!0),delete this.focusPaused):this.focusPaused||this.videoEl.paused||this.videoEl.ended||(this.videoEl.pause(),this.setplaystate(!1),this.focusPaused=!0))}.bind(c));c._config.fluid?c._config.autoplay||(N(c.playerElm,"zwp-fluid"),c.playerElm.style.maxWidth=
|
|
376
376
|
"100%",c.playerElm.style.width="100%",c.playerElm.style.height="0",e=56.25,typeof c._config.ratio==="number"?e=c._config.ratio*100:typeof c._config.ratio==="string"?(A=c._config.ratio.split(":"),A.length===2&&(e=parseFloat(A[0]),A=parseFloat(A[1]),e===0&&(e=1),e=A*100/e)):typeof c._config.width==="number"&&typeof c._config.height==="number"&&(e=c._config.width,e===0&&(e=1),e=c._config.height*100/e),c.playerElm.style.paddingTop=e+"%"):c._config.width&&c._config.height&&(c.playerElm.style.width=typeof c._config.width===
|