vidply 1.0.6 → 1.0.8
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/README.md +19 -4
- package/dist/vidply.css +640 -25
- package/dist/vidply.esm.js +2208 -177
- package/dist/vidply.esm.js.map +4 -4
- package/dist/vidply.esm.min.js +6 -6
- package/dist/vidply.esm.min.meta.json +38 -15
- package/dist/vidply.js +2208 -177
- package/dist/vidply.js.map +4 -4
- package/dist/vidply.min.css +1 -1
- package/dist/vidply.min.js +6 -6
- package/dist/vidply.min.meta.json +38 -15
- package/package.json +2 -2
- package/src/controls/CaptionManager.js +30 -0
- package/src/controls/ControlBar.js +11 -4
- package/src/controls/SettingsDialog.js +3 -3
- package/src/controls/TranscriptManager.js +1147 -72
- package/src/core/Player.js +1435 -26
- package/src/i18n/translations.js +70 -15
- package/src/icons/Icons.js +8 -4
- package/src/styles/vidply.css +640 -25
- package/src/utils/StorageManager.js +156 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StorageManager - Handles persistent storage of user preferences
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export class StorageManager {
|
|
6
|
+
constructor(namespace = 'vidply') {
|
|
7
|
+
this.namespace = namespace;
|
|
8
|
+
this.storage = this.isStorageAvailable() ? localStorage : null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Check if localStorage is available
|
|
13
|
+
*/
|
|
14
|
+
isStorageAvailable() {
|
|
15
|
+
try {
|
|
16
|
+
const test = '__storage_test__';
|
|
17
|
+
localStorage.setItem(test, test);
|
|
18
|
+
localStorage.removeItem(test);
|
|
19
|
+
return true;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get a namespaced key
|
|
27
|
+
*/
|
|
28
|
+
getKey(key) {
|
|
29
|
+
return `${this.namespace}_${key}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Save a value to storage
|
|
34
|
+
*/
|
|
35
|
+
set(key, value) {
|
|
36
|
+
if (!this.storage) return false;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const namespacedKey = this.getKey(key);
|
|
40
|
+
this.storage.setItem(namespacedKey, JSON.stringify(value));
|
|
41
|
+
return true;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.warn('Failed to save to localStorage:', e);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get a value from storage
|
|
50
|
+
*/
|
|
51
|
+
get(key, defaultValue = null) {
|
|
52
|
+
if (!this.storage) return defaultValue;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const namespacedKey = this.getKey(key);
|
|
56
|
+
const value = this.storage.getItem(namespacedKey);
|
|
57
|
+
return value ? JSON.parse(value) : defaultValue;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.warn('Failed to read from localStorage:', e);
|
|
60
|
+
return defaultValue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Remove a value from storage
|
|
66
|
+
*/
|
|
67
|
+
remove(key) {
|
|
68
|
+
if (!this.storage) return false;
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const namespacedKey = this.getKey(key);
|
|
72
|
+
this.storage.removeItem(namespacedKey);
|
|
73
|
+
return true;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
console.warn('Failed to remove from localStorage:', e);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Clear all namespaced values
|
|
82
|
+
*/
|
|
83
|
+
clear() {
|
|
84
|
+
if (!this.storage) return false;
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const keys = Object.keys(this.storage);
|
|
88
|
+
keys.forEach(key => {
|
|
89
|
+
if (key.startsWith(this.namespace)) {
|
|
90
|
+
this.storage.removeItem(key);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return true;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.warn('Failed to clear localStorage:', e);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Save transcript preferences
|
|
102
|
+
*/
|
|
103
|
+
saveTranscriptPreferences(preferences) {
|
|
104
|
+
return this.set('transcript_preferences', preferences);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get transcript preferences
|
|
109
|
+
*/
|
|
110
|
+
getTranscriptPreferences() {
|
|
111
|
+
return this.get('transcript_preferences', null);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Save caption preferences
|
|
116
|
+
*/
|
|
117
|
+
saveCaptionPreferences(preferences) {
|
|
118
|
+
return this.set('caption_preferences', preferences);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get caption preferences
|
|
123
|
+
*/
|
|
124
|
+
getCaptionPreferences() {
|
|
125
|
+
return this.get('caption_preferences', null);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Save player preferences (volume, speed, etc.)
|
|
130
|
+
*/
|
|
131
|
+
savePlayerPreferences(preferences) {
|
|
132
|
+
return this.set('player_preferences', preferences);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get player preferences
|
|
137
|
+
*/
|
|
138
|
+
getPlayerPreferences() {
|
|
139
|
+
return this.get('player_preferences', null);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Save sign language preferences (position and size)
|
|
144
|
+
*/
|
|
145
|
+
saveSignLanguagePreferences(preferences) {
|
|
146
|
+
return this.set('sign_language_preferences', preferences);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get sign language preferences
|
|
151
|
+
*/
|
|
152
|
+
getSignLanguagePreferences() {
|
|
153
|
+
return this.get('sign_language_preferences', null);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|