myetv-player 1.0.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/.github/workflows/npm-publish.yml +30 -0
- package/LICENSE +21 -0
- package/README.md +866 -0
- package/build.js +189 -0
- package/css/README.md +1 -0
- package/css/myetv-player.css +13702 -0
- package/css/myetv-player.min.css +1 -0
- package/dist/README.md +1 -0
- package/dist/myetv-player.js +6408 -0
- package/dist/myetv-player.min.js +6183 -0
- package/package.json +27 -0
- package/plugins/README.md +1 -0
- package/plugins/google-analytics/README.md +1 -0
- package/plugins/google-analytics/myetv-player-g-analytics-plugin.js +548 -0
- package/plugins/youtube/README.md +1 -0
- package/plugins/youtube/myetv-player-youtube-plugin.js +418 -0
- package/scss/README.md +1 -0
- package/scss/_audio-player.scss +21 -0
- package/scss/_base.scss +131 -0
- package/scss/_controls.scss +30 -0
- package/scss/_loading.scss +111 -0
- package/scss/_menus.scss +4070 -0
- package/scss/_mixins.scss +112 -0
- package/scss/_poster.scss +8 -0
- package/scss/_progress-bar.scss +2203 -0
- package/scss/_resolution.scss +68 -0
- package/scss/_responsive.scss +1532 -0
- package/scss/_themes.scss +30 -0
- package/scss/_title-overlay.scss +2262 -0
- package/scss/_tooltips.scss +7 -0
- package/scss/_variables.scss +49 -0
- package/scss/_video.scss +2401 -0
- package/scss/_volume.scss +1981 -0
- package/scss/_watermark.scss +8 -0
- package/scss/myetv-player.scss +51 -0
- package/scss/package.json +16 -0
- package/src/README.md +1 -0
- package/src/chapters.js +521 -0
- package/src/controls.js +1005 -0
- package/src/core.js +1650 -0
- package/src/events.js +330 -0
- package/src/fullscreen.js +82 -0
- package/src/i18n.js +348 -0
- package/src/playlist.js +177 -0
- package/src/plugins.js +384 -0
- package/src/quality.js +921 -0
- package/src/streaming.js +346 -0
- package/src/subtitles.js +426 -0
- package/src/utils.js +51 -0
- package/src/watermark.js +195 -0
package/build.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// Build script for MYETV Video Player
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { exec } = require('child_process');
|
|
5
|
+
const util = require('util');
|
|
6
|
+
const execPromise = util.promisify(exec);
|
|
7
|
+
|
|
8
|
+
const srcDir = './src';
|
|
9
|
+
const outputFile = './dist/myetv-player.js';
|
|
10
|
+
const scssDir = './scss';
|
|
11
|
+
const cssOutputFile = './css/myetv-player.css';
|
|
12
|
+
const cssMinOutputFile = './css/myetv-player.min.css';
|
|
13
|
+
const scssMainFile = './scss/myetv-player.scss';
|
|
14
|
+
|
|
15
|
+
// Module order for correct concatenation
|
|
16
|
+
const moduleOrder = [
|
|
17
|
+
'core.js',
|
|
18
|
+
'events.js',
|
|
19
|
+
'controls.js',
|
|
20
|
+
'quality.js',
|
|
21
|
+
'subtitles.js',
|
|
22
|
+
'chapters.js',
|
|
23
|
+
'fullscreen.js',
|
|
24
|
+
'playlist.js',
|
|
25
|
+
'watermark.js',
|
|
26
|
+
'streaming.js',
|
|
27
|
+
'plugins.js',
|
|
28
|
+
'utils.js'
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// ===================================
|
|
32
|
+
// SCSS BUILD FUNCTION
|
|
33
|
+
// ===================================
|
|
34
|
+
async function buildSCSS() {
|
|
35
|
+
console.log('\nš¦ Building SCSS files...');
|
|
36
|
+
if (!fs.existsSync(scssDir)) {
|
|
37
|
+
console.log('ā ļø SCSS directory not found, skipping CSS build');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!fs.existsSync(scssMainFile)) {
|
|
41
|
+
console.log('ā ļø Main SCSS file not found, skipping CSS build');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const cssDir = path.dirname(cssOutputFile);
|
|
45
|
+
if (!fs.existsSync(cssDir)) {
|
|
46
|
+
fs.mkdirSync(cssDir, { recursive: true });
|
|
47
|
+
console.log(`ā Created directory: ${cssDir}`);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
console.log('Compiling SCSS to CSS (expanded)...');
|
|
51
|
+
await execPromise(`npx sass --style=expanded --no-source-map ${scssMainFile} ${cssOutputFile}`);
|
|
52
|
+
const stats1 = fs.statSync(cssOutputFile);
|
|
53
|
+
const fileSize1KB = (stats1.size / 1024).toFixed(2);
|
|
54
|
+
console.log(`ā CSS (expanded) created: ${cssOutputFile}`);
|
|
55
|
+
console.log(` File size: ${fileSize1KB} KB`);
|
|
56
|
+
console.log('Compiling SCSS to CSS (minified)...');
|
|
57
|
+
await execPromise(`npx sass --style=compressed --no-source-map ${scssMainFile} ${cssMinOutputFile}`);
|
|
58
|
+
const stats2 = fs.statSync(cssMinOutputFile);
|
|
59
|
+
const fileSize2KB = (stats2.size / 1024).toFixed(2);
|
|
60
|
+
const savings = ((1 - stats2.size / stats1.size) * 100).toFixed(1);
|
|
61
|
+
console.log(`ā CSS (minified) created: ${cssMinOutputFile}`);
|
|
62
|
+
console.log(` File size: ${fileSize2KB} KB (${savings}% smaller)`);
|
|
63
|
+
console.log('\nā SCSS build completed successfully!');
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.message.includes('sass: not found') || error.message.includes('command not found')) {
|
|
66
|
+
console.log('\nā ļø Sass compiler not found!');
|
|
67
|
+
console.log('Install with: npm install -g sass');
|
|
68
|
+
console.log('Or add to package.json: npm install --save-dev sass');
|
|
69
|
+
console.log('\nSkipping CSS build for now...\n');
|
|
70
|
+
} else {
|
|
71
|
+
console.error('ā SCSS build failed:', error.message);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ===================================
|
|
78
|
+
// JAVASCRIPT BUILD FUNCTION
|
|
79
|
+
// ===================================
|
|
80
|
+
function buildJavaScript() {
|
|
81
|
+
console.log('\nš¦ Building MYETV Video Player from modular source...');
|
|
82
|
+
let output = '// MYETV Video Player - Javascript\n';
|
|
83
|
+
output += '// Created by https://www.myetv.tv https://oskarcosimo.com\n\n';
|
|
84
|
+
const i18nPath = path.join(srcDir, 'i18n.js');
|
|
85
|
+
if (fs.existsSync(i18nPath)) {
|
|
86
|
+
console.log('Processing i18n.js...');
|
|
87
|
+
let i18nContent = fs.readFileSync(i18nPath, 'utf8');
|
|
88
|
+
i18nContent = i18nContent.replace(/^\/\/ i18n Module for MYETV Video Player[\s\S]*?Created by.*?\n\n/m, '')
|
|
89
|
+
.replace(/export default VideoPlayerI18n;\s*$/m, '').trim();
|
|
90
|
+
output += i18nContent + '\n\n';
|
|
91
|
+
}
|
|
92
|
+
let pluginsGlobalCode = '';
|
|
93
|
+
const pluginsPath = path.join(srcDir, 'plugins.js');
|
|
94
|
+
if (fs.existsSync(pluginsPath)) {
|
|
95
|
+
console.log('Extracting global plugin code...');
|
|
96
|
+
const pluginsContent = fs.readFileSync(pluginsPath, 'utf8');
|
|
97
|
+
const globalMatch = pluginsContent.match(/\/\* GLOBAL_START \*\/([\s\S]*?)\/\* GLOBAL_END \*\//);
|
|
98
|
+
if (globalMatch) {
|
|
99
|
+
pluginsGlobalCode = globalMatch[1].trim() + '\n\n';
|
|
100
|
+
console.log('ā Global plugin code extracted');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (pluginsGlobalCode) {
|
|
104
|
+
output += '// Plugin System - Global Code\n';
|
|
105
|
+
output += pluginsGlobalCode;
|
|
106
|
+
}
|
|
107
|
+
output += 'class MYETVvideoplayer {\n';
|
|
108
|
+
moduleOrder.forEach((moduleFile, index) => {
|
|
109
|
+
const filePath = path.join(srcDir, moduleFile);
|
|
110
|
+
if (fs.existsSync(filePath)) {
|
|
111
|
+
console.log(`Processing ${moduleFile}... (${index + 1}/${moduleOrder.length})`);
|
|
112
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
113
|
+
content = content.replace(/^\/\/.*Module for MYETV Video Player[\s\S]*?Created by.*?\n\n/m, '')
|
|
114
|
+
.replace(/\/\/ .*methods for main class[\s\S]*$/m, '').trim();
|
|
115
|
+
if (moduleFile === 'plugins.js') {
|
|
116
|
+
content = content.replace(/\/\* GLOBAL_START \*\/[\s\S]*?\/\* GLOBAL_END \*\//m, '').trim();
|
|
117
|
+
}
|
|
118
|
+
if (content.length > 0) {
|
|
119
|
+
output += '\n' + content + '\n';
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
console.warn(`Warning: ${moduleFile} not found, skipping...`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
output += '\n}\n\n';
|
|
126
|
+
output += '// Export for module systems\n';
|
|
127
|
+
output += 'if (typeof module !== \"undefined\" && module.exports) {\n';
|
|
128
|
+
output += ' module.exports = MYETVvideoplayer;\n';
|
|
129
|
+
output += '}\n';
|
|
130
|
+
output += 'if (typeof define === \"function\" && define.amd) {\n';
|
|
131
|
+
output += ' define([], function() { return MYETVvideoplayer; });\n';
|
|
132
|
+
output += '}\n';
|
|
133
|
+
const distDir = path.dirname(outputFile);
|
|
134
|
+
if (!fs.existsSync(distDir)) {
|
|
135
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
136
|
+
}
|
|
137
|
+
fs.writeFileSync(outputFile, output);
|
|
138
|
+
console.log('ā JavaScript build completed successfully!');
|
|
139
|
+
console.log(`ā Output file: ${outputFile}`);
|
|
140
|
+
console.log(`ā File size: ${(output.length / 1024).toFixed(2)} KB`);
|
|
141
|
+
console.log(`ā Total lines: ${output.split('\\n').length.toLocaleString()}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ===================================
|
|
145
|
+
// NATIVE JS MINIFICATION FUNCTION
|
|
146
|
+
// ===================================
|
|
147
|
+
function minifyJSNative() {
|
|
148
|
+
const jsFile = './dist/myetv-player.js';
|
|
149
|
+
const minFile = './dist/myetv-player.min.js';
|
|
150
|
+
try {
|
|
151
|
+
let code = fs.readFileSync(jsFile, 'utf8');
|
|
152
|
+
code = code.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
153
|
+
code = code.replace(/(^|\s)\/\/.*$/gm, '');
|
|
154
|
+
code = code.split('\\n').map(line => line.trim()).filter(line => line.length > 0).join(' ');
|
|
155
|
+
fs.writeFileSync(minFile, code);
|
|
156
|
+
console.log(`ā JS (minified native) created: ${minFile}`);
|
|
157
|
+
console.log(` File size: ${(code.length / 1024).toFixed(2)} KB`);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
console.log('ā Native JS minification failed:', err.message);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ===================================
|
|
164
|
+
// MAIN BUILD PROCESS
|
|
165
|
+
// ===================================
|
|
166
|
+
async function build() {
|
|
167
|
+
console.log('\\n========================================');
|
|
168
|
+
console.log(' MYETV Video Player - Build Script');
|
|
169
|
+
console.log('========================================\\n');
|
|
170
|
+
try {
|
|
171
|
+
buildJavaScript();
|
|
172
|
+
minifyJSNative();
|
|
173
|
+
await buildSCSS();
|
|
174
|
+
console.log('\\n========================================');
|
|
175
|
+
console.log(' ⨠Build completed successfully!');
|
|
176
|
+
console.log('========================================');
|
|
177
|
+
console.log('\\nš Generated files:');
|
|
178
|
+
console.log(' JavaScript: dist/myetv-player.js');
|
|
179
|
+
console.log(' JavaScript: dist/myetv-player.min.js');
|
|
180
|
+
console.log(' CSS (dev): css/myetv-player.css');
|
|
181
|
+
console.log(' CSS (prod): css/myetv-player.min.css\\n');
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.error('\\nā Build failed:', error.message);
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Run the build
|
|
189
|
+
build();
|
package/css/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|