zwplayer-vue2x 1.0.29 → 1.0.30
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 +50 -50
- package/zwplayerlib/zwplayer/plugins/hls.light.min.js +1 -1
- package/zwplayerlib/zwplayer/plugins/hls.min.js +1 -1
- package/zwplayerlib/zwplayer/plugins/mpeg.min.js +9 -2
- package/zwplayerlib/zwplayer/zwplayer.js +406 -404
- package/sources/vueplayer/src/loadjs.js +0 -75
- package/sources/vueplayer/src/main.vue +0 -380
|
@@ -1,75 +0,0 @@
|
|
|
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;
|
|
@@ -1,380 +0,0 @@
|
|
|
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
|
-
|