vidply 1.0.5 → 1.0.7
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/LICENSE +22 -22
- package/README.md +608 -593
- package/dist/vidply.css +2422 -1807
- package/dist/vidply.esm.js +1480 -93
- package/dist/vidply.esm.js.map +3 -3
- package/dist/vidply.esm.min.js +3 -3
- package/dist/vidply.esm.min.meta.json +48 -25
- package/dist/vidply.js +1480 -93
- package/dist/vidply.js.map +3 -3
- package/dist/vidply.min.css +1 -1
- package/dist/vidply.min.js +3 -3
- package/dist/vidply.min.meta.json +48 -25
- package/package.json +2 -2
- package/src/controls/CaptionManager.js +278 -248
- package/src/controls/ControlBar.js +2033 -2026
- package/src/controls/KeyboardManager.js +233 -233
- package/src/controls/SettingsDialog.js +417 -417
- package/src/controls/TranscriptManager.js +1803 -728
- package/src/core/Player.js +1616 -1134
- package/src/i18n/i18n.js +66 -66
- package/src/i18n/translations.js +616 -561
- package/src/icons/Icons.js +187 -183
- package/src/index.js +95 -95
- package/src/renderers/HLSRenderer.js +302 -302
- package/src/renderers/HTML5Renderer.js +298 -298
- package/src/renderers/VimeoRenderer.js +257 -257
- package/src/renderers/YouTubeRenderer.js +274 -274
- package/src/styles/vidply.css +2422 -1807
- package/src/utils/DOMUtils.js +154 -154
- package/src/utils/EventEmitter.js +53 -53
- package/src/utils/StorageManager.js +156 -0
- package/src/utils/TimeUtils.js +87 -87
package/src/utils/TimeUtils.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Time formatting and conversion utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {i18n} from '../i18n/i18n.js';
|
|
6
|
-
|
|
7
|
-
export const TimeUtils = {
|
|
8
|
-
/**
|
|
9
|
-
* Format seconds to time string (HH:MM:SS or MM:SS)
|
|
10
|
-
*/
|
|
11
|
-
formatTime(seconds, alwaysShowHours = false) {
|
|
12
|
-
if (!isFinite(seconds) || seconds < 0) {
|
|
13
|
-
return alwaysShowHours ? '00:00:00' : '00:00';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const hours = Math.floor(seconds / 3600);
|
|
17
|
-
const minutes = Math.floor((seconds % 3600) / 60);
|
|
18
|
-
const secs = Math.floor(seconds % 60);
|
|
19
|
-
|
|
20
|
-
const pad = (num) => String(num).padStart(2, '0');
|
|
21
|
-
|
|
22
|
-
if (hours > 0 || alwaysShowHours) {
|
|
23
|
-
return `${pad(hours)}:${pad(minutes)}:${pad(secs)}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return `${pad(minutes)}:${pad(secs)}`;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Parse time string to seconds
|
|
31
|
-
*/
|
|
32
|
-
parseTime(timeString) {
|
|
33
|
-
const parts = timeString.split(':').map(p => parseInt(p, 10));
|
|
34
|
-
|
|
35
|
-
if (parts.length === 3) {
|
|
36
|
-
// HH:MM:SS
|
|
37
|
-
return parts[0] * 3600 + parts[1] * 60 + parts[2];
|
|
38
|
-
} else if (parts.length === 2) {
|
|
39
|
-
// MM:SS
|
|
40
|
-
return parts[0] * 60 + parts[1];
|
|
41
|
-
} else if (parts.length === 1) {
|
|
42
|
-
// SS
|
|
43
|
-
return parts[0];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return 0;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Format seconds to readable duration
|
|
51
|
-
*/
|
|
52
|
-
formatDuration(seconds) {
|
|
53
|
-
if (!isFinite(seconds) || seconds < 0) {
|
|
54
|
-
return i18n.t('time.seconds', { count: 0 });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const hours = Math.floor(seconds / 3600);
|
|
58
|
-
const minutes = Math.floor((seconds % 3600) / 60);
|
|
59
|
-
const secs = Math.floor(seconds % 60);
|
|
60
|
-
|
|
61
|
-
const parts = [];
|
|
62
|
-
|
|
63
|
-
if (hours > 0) {
|
|
64
|
-
const key = hours === 1 ? 'time.hour' : 'time.hours';
|
|
65
|
-
parts.push(i18n.t(key, { count: hours }));
|
|
66
|
-
}
|
|
67
|
-
if (minutes > 0) {
|
|
68
|
-
const key = minutes === 1 ? 'time.minute' : 'time.minutes';
|
|
69
|
-
parts.push(i18n.t(key, { count: minutes }));
|
|
70
|
-
}
|
|
71
|
-
if (secs > 0 || parts.length === 0) {
|
|
72
|
-
const key = secs === 1 ? 'time.second' : 'time.seconds';
|
|
73
|
-
parts.push(i18n.t(key, { count: secs }));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return parts.join(', ');
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Format percentage
|
|
81
|
-
*/
|
|
82
|
-
formatPercentage(value, total) {
|
|
83
|
-
if (total === 0) return 0;
|
|
84
|
-
return Math.round((value / total) * 100);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Time formatting and conversion utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {i18n} from '../i18n/i18n.js';
|
|
6
|
+
|
|
7
|
+
export const TimeUtils = {
|
|
8
|
+
/**
|
|
9
|
+
* Format seconds to time string (HH:MM:SS or MM:SS)
|
|
10
|
+
*/
|
|
11
|
+
formatTime(seconds, alwaysShowHours = false) {
|
|
12
|
+
if (!isFinite(seconds) || seconds < 0) {
|
|
13
|
+
return alwaysShowHours ? '00:00:00' : '00:00';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const hours = Math.floor(seconds / 3600);
|
|
17
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
18
|
+
const secs = Math.floor(seconds % 60);
|
|
19
|
+
|
|
20
|
+
const pad = (num) => String(num).padStart(2, '0');
|
|
21
|
+
|
|
22
|
+
if (hours > 0 || alwaysShowHours) {
|
|
23
|
+
return `${pad(hours)}:${pad(minutes)}:${pad(secs)}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return `${pad(minutes)}:${pad(secs)}`;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Parse time string to seconds
|
|
31
|
+
*/
|
|
32
|
+
parseTime(timeString) {
|
|
33
|
+
const parts = timeString.split(':').map(p => parseInt(p, 10));
|
|
34
|
+
|
|
35
|
+
if (parts.length === 3) {
|
|
36
|
+
// HH:MM:SS
|
|
37
|
+
return parts[0] * 3600 + parts[1] * 60 + parts[2];
|
|
38
|
+
} else if (parts.length === 2) {
|
|
39
|
+
// MM:SS
|
|
40
|
+
return parts[0] * 60 + parts[1];
|
|
41
|
+
} else if (parts.length === 1) {
|
|
42
|
+
// SS
|
|
43
|
+
return parts[0];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return 0;
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Format seconds to readable duration
|
|
51
|
+
*/
|
|
52
|
+
formatDuration(seconds) {
|
|
53
|
+
if (!isFinite(seconds) || seconds < 0) {
|
|
54
|
+
return i18n.t('time.seconds', { count: 0 });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const hours = Math.floor(seconds / 3600);
|
|
58
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
59
|
+
const secs = Math.floor(seconds % 60);
|
|
60
|
+
|
|
61
|
+
const parts = [];
|
|
62
|
+
|
|
63
|
+
if (hours > 0) {
|
|
64
|
+
const key = hours === 1 ? 'time.hour' : 'time.hours';
|
|
65
|
+
parts.push(i18n.t(key, { count: hours }));
|
|
66
|
+
}
|
|
67
|
+
if (minutes > 0) {
|
|
68
|
+
const key = minutes === 1 ? 'time.minute' : 'time.minutes';
|
|
69
|
+
parts.push(i18n.t(key, { count: minutes }));
|
|
70
|
+
}
|
|
71
|
+
if (secs > 0 || parts.length === 0) {
|
|
72
|
+
const key = secs === 1 ? 'time.second' : 'time.seconds';
|
|
73
|
+
parts.push(i18n.t(key, { count: secs }));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return parts.join(', ');
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Format percentage
|
|
81
|
+
*/
|
|
82
|
+
formatPercentage(value, total) {
|
|
83
|
+
if (total === 0) return 0;
|
|
84
|
+
return Math.round((value / total) * 100);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|