zwplayer-vue2x 1.0.1

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.
Files changed (65) hide show
  1. package/README.md +24 -0
  2. package/jsconfig.json +19 -0
  3. package/lib/demo.html +1 -0
  4. package/lib/zwplayervue2.common.js +599 -0
  5. package/lib/zwplayervue2.umd.js +618 -0
  6. package/lib/zwplayervue2.umd.min.js +2 -0
  7. package/npm-scripts.mjs +191 -0
  8. package/package.json +50 -0
  9. package/sources/index.js +23 -0
  10. package/sources/vueplayer/index.js +13 -0
  11. package/sources/vueplayer/src/loadjs.js +75 -0
  12. package/sources/vueplayer/src/main.vue +338 -0
  13. package/zwplayerlib/zwplayer/css/openhand.cur +0 -0
  14. package/zwplayerlib/zwplayer/css/zwplayer.css +3103 -0
  15. package/zwplayerlib/zwplayer/css/zwplayer.ttf +0 -0
  16. package/zwplayerlib/zwplayer/css/zwplayer.woff +0 -0
  17. package/zwplayerlib/zwplayer/css/zwplayer.woff2 +0 -0
  18. package/zwplayerlib/zwplayer/plugins/dash.all.min.js +3 -0
  19. package/zwplayerlib/zwplayer/plugins/flv.live.js +358 -0
  20. package/zwplayerlib/zwplayer/plugins/flv.min.js +2 -0
  21. package/zwplayerlib/zwplayer/plugins/hls.light.min.js +2 -0
  22. package/zwplayerlib/zwplayer/plugins/hls.min.js +2 -0
  23. package/zwplayerlib/zwplayer/plugins/mpeg.min.js +2 -0
  24. package/zwplayerlib/zwplayer/widgets/danmu_setting.html +116 -0
  25. package/zwplayerlib/zwplayer/widgets/smiles/p1.png +0 -0
  26. package/zwplayerlib/zwplayer/widgets/smiles/p10.png +0 -0
  27. package/zwplayerlib/zwplayer/widgets/smiles/p11.png +0 -0
  28. package/zwplayerlib/zwplayer/widgets/smiles/p12.png +0 -0
  29. package/zwplayerlib/zwplayer/widgets/smiles/p13.png +0 -0
  30. package/zwplayerlib/zwplayer/widgets/smiles/p14.png +0 -0
  31. package/zwplayerlib/zwplayer/widgets/smiles/p15.png +0 -0
  32. package/zwplayerlib/zwplayer/widgets/smiles/p16.png +0 -0
  33. package/zwplayerlib/zwplayer/widgets/smiles/p17.png +0 -0
  34. package/zwplayerlib/zwplayer/widgets/smiles/p18.png +0 -0
  35. package/zwplayerlib/zwplayer/widgets/smiles/p19.png +0 -0
  36. package/zwplayerlib/zwplayer/widgets/smiles/p2.png +0 -0
  37. package/zwplayerlib/zwplayer/widgets/smiles/p20.png +0 -0
  38. package/zwplayerlib/zwplayer/widgets/smiles/p21.png +0 -0
  39. package/zwplayerlib/zwplayer/widgets/smiles/p22.png +0 -0
  40. package/zwplayerlib/zwplayer/widgets/smiles/p23.png +0 -0
  41. package/zwplayerlib/zwplayer/widgets/smiles/p24.png +0 -0
  42. package/zwplayerlib/zwplayer/widgets/smiles/p25.png +0 -0
  43. package/zwplayerlib/zwplayer/widgets/smiles/p26.png +0 -0
  44. package/zwplayerlib/zwplayer/widgets/smiles/p27.png +0 -0
  45. package/zwplayerlib/zwplayer/widgets/smiles/p28.png +0 -0
  46. package/zwplayerlib/zwplayer/widgets/smiles/p29.png +0 -0
  47. package/zwplayerlib/zwplayer/widgets/smiles/p3.png +0 -0
  48. package/zwplayerlib/zwplayer/widgets/smiles/p30.png +0 -0
  49. package/zwplayerlib/zwplayer/widgets/smiles/p31.png +0 -0
  50. package/zwplayerlib/zwplayer/widgets/smiles/p32.png +0 -0
  51. package/zwplayerlib/zwplayer/widgets/smiles/p33.png +0 -0
  52. package/zwplayerlib/zwplayer/widgets/smiles/p34.png +0 -0
  53. package/zwplayerlib/zwplayer/widgets/smiles/p35.png +0 -0
  54. package/zwplayerlib/zwplayer/widgets/smiles/p36.png +0 -0
  55. package/zwplayerlib/zwplayer/widgets/smiles/p37.png +0 -0
  56. package/zwplayerlib/zwplayer/widgets/smiles/p38.png +0 -0
  57. package/zwplayerlib/zwplayer/widgets/smiles/p39.png +0 -0
  58. package/zwplayerlib/zwplayer/widgets/smiles/p4.png +0 -0
  59. package/zwplayerlib/zwplayer/widgets/smiles/p40.png +0 -0
  60. package/zwplayerlib/zwplayer/widgets/smiles/p5.png +0 -0
  61. package/zwplayerlib/zwplayer/widgets/smiles/p6.png +0 -0
  62. package/zwplayerlib/zwplayer/widgets/smiles/p7.png +0 -0
  63. package/zwplayerlib/zwplayer/widgets/smiles/p8.png +0 -0
  64. package/zwplayerlib/zwplayer/widgets/smiles/p9.png +0 -0
  65. package/zwplayerlib/zwplayer/zwplayer.js +424 -0
@@ -0,0 +1,191 @@
1
+ import process from 'process';
2
+ import os from 'os';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url'
6
+ import { execSync, spawnSync } from 'child_process';
7
+
8
+ const PKG = JSON.parse(fs.readFileSync('./package.json').toString());
9
+ const IS_FREEBSD = os.platform() === 'freebsd';
10
+ const IS_WINDOWS = os.platform() === 'win32';
11
+ const MAYOR_VERSION = PKG.version.split('.')[0];
12
+ const ZWPLAYER_LIBRARY_DIR = 'zwplayerlib/prebuild';
13
+ const __filenameCur = fileURLToPath(import.meta.url)
14
+ const __dirnameCur = path.dirname(__filenameCur);
15
+ const CURRENT_DIRECTORY = path.resolve(__dirnameCur);
16
+
17
+ const task = process.argv.slice(2).join(' ');
18
+
19
+ run();
20
+
21
+ async function run()
22
+ {
23
+ switch (task)
24
+ {
25
+ case 'prepare':
26
+ {
27
+ logInfo('zwplayer run script prepare...');
28
+
29
+ break;
30
+ }
31
+
32
+ case 'postinstall':
33
+ {
34
+ logInfo('zwplayer run script postinstall...');
35
+
36
+ const zwplayerLibDir = `${CURRENT_DIRECTORY}/zwplayerlib/zwplayer`;
37
+ const zwplayer_js = `${zwplayerLibDir}/zwplayer.js`;
38
+
39
+ const zwplayer_js_filepath = path.normalize(zwplayer_js);
40
+
41
+ if (!fs.existsSync(zwplayer_js_filepath))
42
+ {
43
+ logError(`zwplayer library file "${zwplayer_js}" does not exist.`);
44
+ zwplayer_library_install();
45
+ return;
46
+ }
47
+
48
+ const project_path = path.normalize(`${CURRENT_DIRECTORY}/../..`);
49
+ const project_package = path.normalize(`${project_path}/package.json`);
50
+
51
+ if (!fs.existsSync(project_package))
52
+ {
53
+ logError(`project package.json ${project_package} does not exist.`);
54
+ please_run_vue_crate_project();
55
+ return;
56
+ }
57
+
58
+ const vue_config_js = path.normalize(`${project_path}/vue.config.js`);
59
+ const vite_config_js = path.normalize(`${project_path}/vite.config.js`);
60
+
61
+ if (!fs.existsSync(vue_config_js) && !fs.existsSync(vite_config_js))
62
+ {
63
+ logError(`vue config vue.config.js or vite.config.js does not exist.`);
64
+ please_run_vue_crate_project();
65
+ return;
66
+ }
67
+
68
+ const public_path = path.normalize(`${project_path}/public`);
69
+
70
+ if (!fs.existsSync(public_path))
71
+ {
72
+ logError(`vue public path ${public_path} does not exist.`);
73
+ please_run_vue_crate_project();
74
+ return;
75
+ }
76
+
77
+ // copy files
78
+ const source_path = path.normalize(`${CURRENT_DIRECTORY}/zwplayerlib`);
79
+
80
+ copyDirectory(source_path, public_path);
81
+
82
+ break;
83
+ }
84
+ }
85
+ }
86
+
87
+ function logInfo(message)
88
+ {
89
+ // eslint-disable-next-line no-console
90
+ console.log(`npm-scripts \x1b[36m[INFO] [${task}]\x1b\[0m`, message);
91
+ }
92
+
93
+ function logWarn(message)
94
+ {
95
+ // eslint-disable-next-line no-console
96
+ console.warn(`npm-scripts \x1b[33m[WARN] [${task}]\x1b\[0m`, message);
97
+ }
98
+
99
+ function logError(message)
100
+ {
101
+ // eslint-disable-next-line no-console
102
+ console.error(`npm-scripts \x1b[31m[ERROR] [${task}]\x1b\[0m`, message);
103
+ }
104
+
105
+ function exitWithError()
106
+ {
107
+ process.exit(1);
108
+ }
109
+
110
+ function checkExistSync(path)
111
+ {
112
+ try {
113
+ fs.accessSync(
114
+ path,
115
+ fs.constants.F_OK | fs.constants.R_OK | fs.constants.W_OK
116
+ );
117
+ // console.log(`Directory "${path}" exists.`);
118
+ return true;
119
+ } catch (err) {
120
+ logInfo(`Directory "${path}" does not exist.`);
121
+ return false;
122
+ }
123
+ }
124
+
125
+ function ensureDirSync(dir)
126
+ {
127
+ const exists = fs.existsSync(dir);
128
+ if (!exists) {
129
+
130
+ ensureDirSync(path.dirname(dir));
131
+
132
+ fs.mkdirSync(dir);
133
+ }
134
+ }
135
+
136
+ function copyFile(srcFile, desFile)
137
+ {
138
+ const _fs = fs;
139
+
140
+ const destDir = path.dirname(desFile);
141
+
142
+ ensureDirSync(destDir);
143
+
144
+ return new Promise((resolve, reject) => {
145
+ try {
146
+ const writeStream = _fs.createWriteStream(desFile);
147
+ const readStream = _fs.createReadStream(srcFile);
148
+ readStream.on("error", reject);
149
+ readStream.on("close", resolve);
150
+ writeStream.on("error", reject);
151
+ writeStream.on("finish", () => {
152
+ console.log("File copied successfully!");
153
+ });
154
+ readStream.pipe(writeStream);
155
+ } catch (error) {
156
+ console.error(error);
157
+ }
158
+ });
159
+ }
160
+
161
+ async function copyDirectory(srcPath, desPath)
162
+ {
163
+ const _fs = fs;
164
+ const _path = path;
165
+ try {
166
+ const isSrcExist = checkExistSync(srcPath);
167
+ if (!isSrcExist) {
168
+ logError(`copyDirectory error: ${srcPath} does not exist`);
169
+ return;
170
+ }
171
+
172
+ const isDesExist = checkExistSync(desPath);
173
+ if (!isDesExist) ensureDirSync(desPath);
174
+
175
+ const files = _fs.readdirSync(srcPath);
176
+
177
+ for (const file of files) {
178
+ const copyPath = _path.join(srcPath, file);
179
+ const destPath = _path.join(desPath, file);
180
+ const stats = await _fs.statSync(copyPath);
181
+
182
+ if (stats.isDirectory()) {
183
+ await copyDirectory(copyPath, destPath);
184
+ } else {
185
+ await copyFile(copyPath, destPath);
186
+ }
187
+ }
188
+ } catch (error) {
189
+ console.error(`Error copying directory: ${error.message}`);
190
+ }
191
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "zwplayer-vue2x",
3
+ "version": "1.0.1",
4
+ "description": "A fully functional and lightweight free open-source web player",
5
+ "main": "lib/zwplayervue2.umd.min.js",
6
+ "keyword": "zwplayervue2, zwplayer-vue2x, zero-web-player",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "scripts": {
10
+ "prepare": "node npm-scripts.mjs prepare",
11
+ "postinstall": "node npm-scripts.mjs postinstall",
12
+ "serve": "vue-cli-service serve",
13
+ "build": "vue-cli-service build",
14
+ "lint": "vue-cli-service lint",
15
+ "lib": "vue-cli-service build --target lib --name zwplayervue2 --dest lib sources/index.js"
16
+ },
17
+ "dependencies": {
18
+ "core-js": "^3.8.3",
19
+ "vue": "^2.6.11"
20
+ },
21
+ "devDependencies": {
22
+ "@babel/core": "^7.12.16",
23
+ "@babel/eslint-parser": "^7.12.16",
24
+ "@vue/cli-plugin-babel": "~5.0.0",
25
+ "@vue/cli-plugin-eslint": "~5.0.0",
26
+ "@vue/cli-service": "^5.0.8",
27
+ "eslint": "^7.32.0",
28
+ "eslint-plugin-vue": "^8.0.3",
29
+ "vue-template-compiler": "^2.6.14"
30
+ },
31
+ "eslintConfig": {
32
+ "root": true,
33
+ "env": {
34
+ "node": true
35
+ },
36
+ "extends": [
37
+ "plugin:vue/essential",
38
+ "eslint:recommended"
39
+ ],
40
+ "parserOptions": {
41
+ "parser": "@babel/eslint-parser"
42
+ },
43
+ "rules": {}
44
+ },
45
+ "browserslist": [
46
+ "> 1%",
47
+ "last 2 versions",
48
+ "not dead"
49
+ ]
50
+ }
@@ -0,0 +1,23 @@
1
+ // 引入该目录下所有的组件
2
+ import zwplayer from "./vueplayer/index.js";
3
+
4
+ const components = [
5
+ zwplayer
6
+ ]
7
+
8
+ const ZwModule = {}
9
+ ZwModule.install = Vue => {
10
+ components.forEach(component => {
11
+ component.install(Vue);
12
+ })
13
+ }
14
+
15
+ if (typeof window !== 'undefined' && window.Vue) {
16
+ ZwModule.install(window.Vue)
17
+ }
18
+
19
+ export {
20
+ zwplayer
21
+ };
22
+
23
+ export default ZwModule;
@@ -0,0 +1,13 @@
1
+ //export defines
2
+ import zwplayer from './src/main';
3
+
4
+ /* istanbul ignore next */
5
+ zwplayer.install = function(Vue) {
6
+ Vue.component(zwplayer.name, zwplayer); //
7
+ Vue.component('zero-web-player', zwplayer);
8
+ Vue.component('zero-player', zwplayer);
9
+ Vue.component('ZPlayer', zwplayer);
10
+ };
11
+
12
+ export default zwplayer;
13
+
@@ -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,338 @@
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.2';
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
+ };
37
+
38
+ export default {
39
+ name: 'ZwPlayer',
40
+ data () {
41
+ return {
42
+ zwplayer: null,
43
+ nodename: 'ZwPlayer'
44
+ }
45
+ },
46
+ props: {
47
+ zwplayerlib: String,
48
+ murl: String,
49
+ nodeid: String,
50
+ muted: Boolean,
51
+ autoplay: {
52
+ type: Boolean,
53
+ default: true
54
+ },
55
+ videoprop: Object,
56
+ videostyle: String,
57
+ reconnect: {
58
+ type: Boolean,
59
+ default: true
60
+ },
61
+ controlbar: {
62
+ type: Boolean,
63
+ default: true
64
+ },
65
+ useProgressTooltip: {
66
+ type: Boolean,
67
+ default: true
68
+ }
69
+ },
70
+
71
+ emits: ['oneterror', 'onmediaevent', 'onready'],
72
+ methods: {
73
+ play(url, isLive, useOldFlv) {
74
+ let vm = this;
75
+
76
+ if (!url)
77
+ url = this.murl;
78
+ if (!vm.zwplayer)
79
+ return;
80
+
81
+ vm.zwplayer.play(url, isLive, useOldFlv);
82
+ },
83
+ stop() {
84
+ let vm = this;
85
+
86
+ if (vm.zwplayer) {
87
+ vm.zwplayer.stop();
88
+ }
89
+ },
90
+ pause() {
91
+ let vm = this;
92
+
93
+ if (vm.zwplayer) {
94
+ vm.zwplayer.pause();
95
+ }
96
+ },
97
+ resume() {
98
+ let vm = this;
99
+ if (vm.zwplayer) {
100
+ vm.zwplayer.resume();
101
+ }
102
+ },
103
+ getDuration() {
104
+ let vm = this;
105
+ if (vm.zwplayer) {
106
+ return vm.zwplayer.getDuration();
107
+ }
108
+ return undefined;
109
+ },
110
+ seekTime(time) {
111
+ let vm = this;
112
+
113
+ if (vm.zwplayer) {
114
+ vm.zwplayer.seekTime(time);
115
+ }
116
+ },
117
+ destroy() {
118
+ let vm = this;
119
+
120
+ if (vm.zwplayer) {
121
+ vm.zwplayer.destroy();
122
+ }
123
+ },
124
+ setplaystate(bPlaying) {
125
+ let vm = this;
126
+
127
+ if (vm.zwplayer) {
128
+ vm.zwplayer.setplaystate(bPlaying);
129
+ }
130
+ },
131
+
132
+ setEnableDanmu(bEnable) {
133
+ let vm = this;
134
+
135
+ if (vm.zwplayer) {
136
+ vm.zwplayer.setEnableDanmu(bEnable);
137
+ }
138
+ },
139
+
140
+ appendDanmu(msgObj, setting) {
141
+ let vm = this;
142
+
143
+ if (vm.zwplayer) {
144
+ vm.zwplayer.appendDanmu(msgObj, setting);
145
+ }
146
+ },
147
+
148
+ setChapters(chapters) {
149
+ let vm = this;
150
+
151
+ if (vm.zwplayer) {
152
+ vm.zwplayer.setChapters(chapters);
153
+ }
154
+ },
155
+
156
+ addSubtitle(subtitleUrl, pos, title) {
157
+ let vm = this;
158
+
159
+ if (vm.zwplayer) {
160
+ vm.zwplayer.addSubtitle(subtitleUrl, pos, title);
161
+ }
162
+ },
163
+
164
+ removeSubtitle() {
165
+ let vm = this;
166
+
167
+ if (vm.zwplayer) {
168
+ vm.zwplayer.removeSubtitle();
169
+ }
170
+ },
171
+
172
+ buildDanmuControlbar(parentId, className) {
173
+ let vm = this;
174
+
175
+ if (vm.zwplayer) {
176
+ vm.zwplayer.buildDanmuControlbar(parentId, className);
177
+ }
178
+ },
179
+
180
+ notifyResize(width, height) {
181
+ let vm = this;
182
+
183
+ if (vm.zwplayer) {
184
+ vm.zwplayer.notifyResize(width, height);
185
+ }
186
+ },
187
+
188
+ setMute(bMute) {
189
+ let vm = this;
190
+
191
+ if (vm.zwplayer) {
192
+ vm.zwplayer.setMuted(bMute);
193
+ }
194
+ },
195
+
196
+ setullscr(bFullScr) {
197
+ let vm = this;
198
+
199
+ if (vm.zwplayer) {
200
+ vm.is_fullscr = bFullScr;
201
+ vm.zwplayer.setFullscreen(bFullScr);
202
+ }
203
+ },
204
+ },
205
+
206
+ render() {
207
+ let playerid;
208
+
209
+ // console.log('render');
210
+ if (this.nodeid) {
211
+ playerid = this.nodeid;
212
+ }
213
+ else {
214
+ let now = (new Date()).getTime();
215
+
216
+ if (!window.nextZWPlayerId) {
217
+ window.nextZWPlayerId = 1000;
218
+ }
219
+ else {
220
+ window.nextZWPlayerId++;
221
+ }
222
+ playerid = 'zwplayer-'+ window.nextZWPlayerId + '-' + now;
223
+ }
224
+
225
+ let playerWrap = h('div', {
226
+ class: {'zwplayer-vue': true},
227
+ id: playerid
228
+ }, []);
229
+
230
+ if (playerWrap) {
231
+ let vm = this;
232
+ vm.playerid = playerid;
233
+ }
234
+
235
+ if (this.zwplayer && this.murl !== this.old_murl) {
236
+ this.zwplayer.play(this.murl); // change movie url
237
+ this.old_murl = this.murl;
238
+ }
239
+
240
+ return playerWrap;
241
+ },
242
+
243
+ mounted() {
244
+ let vm = this;
245
+ // console.log('mounted');
246
+ let zwplayer_js;
247
+
248
+ if (vm.zwplayerlib)
249
+ zwplayer_js = vm.zwplayerlib;
250
+ else
251
+ zwplayer_js = zwplayer_js_def;
252
+
253
+ vm.rootElm = document.getElementById(vm.playerid);
254
+ if (vm.rootElm) {
255
+ vm.rootElm.style.width = '100%';
256
+ vm.rootElm.style.height = '100%';
257
+ vm.rootElm.style.margin = '0';
258
+ vm.rootElm.style.padding = '0';
259
+ }
260
+
261
+ zwplayer_loadjs('zwplayer-core', zwplayer_js, function(jsid) {
262
+ let url = '';
263
+
264
+ if (!jsid) {
265
+ console.log('zwplayer_loadjs failed!');
266
+ }
267
+
268
+ if (vm.murl)
269
+ url = vm.murl;
270
+ else if (vm.videoprop && typeof vm.videoprop.url !== 'undefined')
271
+ url = vm.videoprop.url;
272
+ let videostyle = "width:100%;height:100%;";
273
+ if (vm.videoprop && typeof vm.videoprop.videostyle !== 'undefined')
274
+ videostyle = vm.videoprop.videostyle;
275
+
276
+ let params = {
277
+ url: url,
278
+ playerElm: vm.rootElm,
279
+ videostyle: videostyle,
280
+ reconnect: vm.reconnect,
281
+ autoplay: vm.autoplay,
282
+ muted: vm.muted,
283
+ controlbar: vm.controlbar,
284
+ useProgressTooltip: vm.useProgressTooltip,
285
+ onready: function() {
286
+ vm.$emit('onready', this);
287
+ },
288
+ onnetclose: function() {
289
+ vm.$emit('onnetclose', this);
290
+ return true;
291
+ },
292
+ onneterror: function() {
293
+ vm.$emit('onneterror', this);
294
+ },
295
+ onmediaevent: function(event) {
296
+ vm.$emit('onmediaevent', event, this);
297
+ }
298
+ };
299
+
300
+ let props_list = availabe_props;
301
+ for (let prop in vm.$attrs) {
302
+ if (prop in props_list && typeof vm.$attrs[prop] === props_list[prop]) {
303
+ if (typeof vm.$attrs[prop] === 'object')
304
+ params[prop] = JSON.parse(JSON.stringify(vm.$attrs[prop]));
305
+ else
306
+ params[prop] = vm.$attrs[prop];
307
+ }
308
+ }
309
+
310
+ vm.zwplayer = new window.ZWPlayer(params);
311
+
312
+ if(params.danmuBarId) {
313
+ vm.zwplayer.buildDanmuControlbar(params.danmuBarId, 'vue-zwp-danmubar');
314
+ }
315
+
316
+ vm.old_murl = url;
317
+ })
318
+ },
319
+
320
+ beforeUnmount() {
321
+ let vm = this;
322
+ // console.log('beforeUnmount');
323
+ if (vm.zwplayer) {
324
+ vm.zwplayer.stop();
325
+ }
326
+ },
327
+
328
+ unmounted() {
329
+ let vm = this;
330
+ // console.log('unmounted');
331
+ if (vm.zwplayer) {
332
+ vm.zwplayer.destroy();
333
+ delete vm.zwplayer;
334
+ }
335
+ }
336
+ }
337
+ </script>
338
+