@viewlift/player-backup 1.0.2 → 1.0.3-lighteningjs

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 (134) hide show
  1. package/.babelrc +8 -0
  2. package/.browserslistrc +2 -0
  3. package/README.md +29 -0
  4. package/babel.config.json +8 -0
  5. package/dist/38afc79c94e0bcf0.png +0 -0
  6. package/dist/3bc8b7ff04e98d37.png +0 -0
  7. package/dist/522ea7c76ac4fd33.png +0 -0
  8. package/dist/a74cd46ed4277568.png +0 -0
  9. package/dist/b739faec1fde1346.png +0 -0
  10. package/dist/ed3d0a4d9de91460.png +0 -0
  11. package/dist/index.cjs.css +2 -0
  12. package/dist/index.cjs.css.map +1 -0
  13. package/dist/index.cjs.js +2 -0
  14. package/dist/index.d.ts +24 -0
  15. package/dist/index.esm.css +2 -0
  16. package/dist/index.esm.css.map +1 -0
  17. package/dist/index.esm.js +2 -0
  18. package/dist/main-player/player-ui.d.ts +19 -0
  19. package/dist/player-components/player-buttons/playerButtons.d.ts +38 -0
  20. package/dist/player-components/player-seekbar/playerSeekbar.d.ts +25 -0
  21. package/dist/player-ui/player-ui.d.ts +18 -0
  22. package/dist/playerInitializer.d.ts +13 -0
  23. package/index.html +49 -0
  24. package/package.json +35 -15
  25. package/rollup.config.mjs +45 -0
  26. package/src/ads-manager/ads-manager.js +120 -0
  27. package/src/assets/checkIcon.png +0 -0
  28. package/src/assets/pauseIcon.png +0 -0
  29. package/src/assets/pauseIconFocus.png +0 -0
  30. package/src/assets/playIcon.png +0 -0
  31. package/src/assets/playIconFocus.png +0 -0
  32. package/src/assets/settingsIcon.png +0 -0
  33. package/src/index.ts +74 -0
  34. package/src/player-components/player-buttons/playerButtons.js +106 -0
  35. package/src/player-components/player-seekbar/playerSeekbar.js +223 -0
  36. package/src/player-components/player-setting-option-wrapper/player-setting-option-one-wrapper.js +82 -0
  37. package/src/player-components/player-setting-option-wrapper/player-setting-option-two-wrapper.js +84 -0
  38. package/src/player-components/player-sidebar/player-sidebar.js +188 -0
  39. package/src/player-components/player-title/playerTitle.js +56 -0
  40. package/src/player-ui/player-ui.js +564 -0
  41. package/src/playerControls/playerControls.css +10 -0
  42. package/src/playerControls/playerControls.js +501 -0
  43. package/src/playerInitializer.js +335 -0
  44. package/src/styles/index.css +204 -0
  45. package/src/utilities/utilities.js +79 -0
  46. package/tsconfig.json +15 -0
  47. package/cjs/autoNextVideo-815419cb.js +0 -1
  48. package/cjs/bundle.css +0 -577
  49. package/cjs/caption-settings-67212c17.js +0 -1
  50. package/cjs/caption-settings-6e301004.js +0 -1
  51. package/cjs/dvr_skin-f7f770ae.js +0 -1
  52. package/cjs/error-26d5a3c3.js +0 -1
  53. package/cjs/features-fd1e9785.js +0 -1
  54. package/cjs/generic-81b1be69.js +0 -1
  55. package/cjs/icons-51594f89.js +0 -1
  56. package/cjs/index.js +0 -1
  57. package/cjs/keyboardShortcuts-1afbf18c.js +0 -1
  58. package/cjs/loader-393b838a.js +0 -1
  59. package/cjs/multicam-1647c428.js +0 -1
  60. package/cjs/multicam-a41fe4a6.js +0 -1
  61. package/cjs/multicamv2-76d8530b.js +0 -1
  62. package/cjs/multicamv2-f48d95fe.js +0 -1
  63. package/cjs/mwebPotrait-3c11d7cf.js +0 -1
  64. package/cjs/mwebPotraitTray-a3a2715b.js +0 -1
  65. package/cjs/nextEpisodeButton-b6e6586f.js +0 -1
  66. package/cjs/nextEpisodeButton-cc80609a.js +0 -1
  67. package/cjs/nondvr_skin-ef2cb3b2.js +0 -1
  68. package/cjs/playlist-a550a735.js +0 -1
  69. package/cjs/playlist-df87ca90.js +0 -1
  70. package/cjs/renditions-c3ea26e8.js +0 -1
  71. package/cjs/resolution-51b38a3e.js +0 -1
  72. package/cjs/series-6178964e.js +0 -1
  73. package/cjs/series-9c237975.js +0 -1
  74. package/cjs/series-v2-70137d8c.js +0 -1
  75. package/cjs/series-v2-a265ff17.js +0 -1
  76. package/cjs/settings-icon-b350b587.js +0 -1
  77. package/cjs/settings-icon-e6a8feee.js +0 -1
  78. package/cjs/skin-14da56f6.js +0 -1
  79. package/cjs/skin-225252ff.js +0 -1
  80. package/cjs/skin-286f52db.js +0 -1
  81. package/cjs/skin-534810ae.js +0 -1
  82. package/cjs/skin-638aecc2.js +0 -1
  83. package/cjs/skin-84083352.js +0 -1
  84. package/cjs/skin-983a2ea7.js +0 -1
  85. package/cjs/skin-9eba464b.js +0 -1
  86. package/cjs/skin-b703ef26.js +0 -1
  87. package/cjs/skin-f225a42e.js +0 -1
  88. package/cjs/util-ce8a4138.js +0 -1
  89. package/cjs/videoSelector-a4c00f50.js +0 -1
  90. package/cjs/videoSelector-fcdf11eb.js +0 -1
  91. package/esm/autoNextVideo-89ede579.js +0 -1
  92. package/esm/bundle.css +0 -577
  93. package/esm/caption-settings-2e47813b.js +0 -1
  94. package/esm/caption-settings-3f6b6163.js +0 -1
  95. package/esm/dvr_skin-9cc1b144.js +0 -1
  96. package/esm/error-2395864b.js +0 -1
  97. package/esm/features-05101ce6.js +0 -1
  98. package/esm/generic-4a3c0d6b.js +0 -1
  99. package/esm/icons-f5378bf3.js +0 -1
  100. package/esm/index.js +0 -1
  101. package/esm/keyboardShortcuts-7fa108ec.js +0 -1
  102. package/esm/loader-580278fe.js +0 -1
  103. package/esm/multicam-bc0aea8a.js +0 -1
  104. package/esm/multicam-de741974.js +0 -1
  105. package/esm/multicamv2-d006cffa.js +0 -1
  106. package/esm/multicamv2-fb91fa98.js +0 -1
  107. package/esm/mwebPotrait-3c1805d8.js +0 -1
  108. package/esm/mwebPotraitTray-0ff12233.js +0 -1
  109. package/esm/nextEpisodeButton-a1556cdf.js +0 -1
  110. package/esm/nextEpisodeButton-ec95417f.js +0 -1
  111. package/esm/nondvr_skin-64be70e5.js +0 -1
  112. package/esm/playlist-5d3f4436.js +0 -1
  113. package/esm/playlist-7ecf432a.js +0 -1
  114. package/esm/renditions-0fdb57ed.js +0 -1
  115. package/esm/resolution-57e7767a.js +0 -1
  116. package/esm/series-041152aa.js +0 -1
  117. package/esm/series-998e2084.js +0 -1
  118. package/esm/series-v2-0727ee8c.js +0 -1
  119. package/esm/series-v2-9bcd5d54.js +0 -1
  120. package/esm/settings-icon-0125bffd.js +0 -1
  121. package/esm/settings-icon-9bac9ef3.js +0 -1
  122. package/esm/skin-0aea7a56.js +0 -1
  123. package/esm/skin-2c638dc1.js +0 -1
  124. package/esm/skin-5a02ebe6.js +0 -1
  125. package/esm/skin-665ec17e.js +0 -1
  126. package/esm/skin-80957fd8.js +0 -1
  127. package/esm/skin-851ea2fb.js +0 -1
  128. package/esm/skin-bb73c15b.js +0 -1
  129. package/esm/skin-cd537931.js +0 -1
  130. package/esm/skin-d5510f70.js +0 -1
  131. package/esm/skin-fba79111.js +0 -1
  132. package/esm/util-9c9ee6b3.js +0 -1
  133. package/esm/videoSelector-8da87dd3.js +0 -1
  134. package/esm/videoSelector-8e258d45.js +0 -1
@@ -0,0 +1,564 @@
1
+ import { Button } from '../player-components/player-buttons/playerButtons.js';
2
+ import { PlayerSeekbar } from '../player-components/player-seekbar/playerSeekbar.js';
3
+ import { TextContent } from '../player-components/player-title/playerTitle.js';
4
+ import { Sidebar } from '../player-components/player-sidebar/player-sidebar.js';
5
+ import playIcon from '../assets/playIcon.png';
6
+ import pauseIcon from '../assets/pauseIcon.png';
7
+ import playIconFocus from '../assets/playIconFocus.png';
8
+ import pauseIconFocus from '../assets/pauseIconFocus.png';
9
+ import settingsIcon from '../assets/settingsIcon.png';
10
+
11
+ class VideoPlayerUI {
12
+ constructor({ player, config }) {
13
+ if (!player || typeof player !== 'object' || !player.video) {
14
+ throw new Error('VideoPlayerUI: player must be a valid object with a video property');
15
+ }
16
+ this.player = player;
17
+ this.videoTitleConfig = config.videoTitleConfig || {};
18
+
19
+ this.selectedVideoQuality = "auto";
20
+ this.selectedPlaybackCaption = "";
21
+ this.selectedAudioQuality = "";
22
+
23
+ this.container = document.createElement('div');
24
+ this.container.className = 'video-player-ui';
25
+ this.rightSideContainer = document.createElement('div');
26
+ this.rightSideContainer.className = 'right-side-container';
27
+ this.leftSideContainer = document.createElement('div');
28
+ this.leftSideContainer.className = 'left-side-container';
29
+ this.container.appendChild(this.rightSideContainer);
30
+ this.container.appendChild(this.leftSideContainer);
31
+ this.createControls();
32
+ }
33
+
34
+ createControls() {
35
+ this.createPlayPauseBtn();
36
+ this.createSeekbar();
37
+ this.createSettingsBtn();
38
+ this.createRestartVideoBtn();
39
+ this.createTextContent();
40
+ this.addEventListeners();
41
+
42
+ // Attach the video element
43
+ this.container.appendChild(this.player.video);
44
+ }
45
+
46
+ createPlayPauseBtn() {
47
+ this.playPauseBtn = new Button({
48
+ imgSrc: playIconFocus,
49
+ imgAltText: 'Play/Pause',
50
+ buttonText: 'Play',
51
+ width: 70,
52
+ height: 70,
53
+ klassname: 'play-pause-btn',
54
+ focused: false,
55
+ disabled: false,
56
+ handleClick: () => {
57
+ if (this.player.video.paused) {
58
+ this.player.play();
59
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
60
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', pauseIconFocus);
61
+ } else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
62
+ this.playPauseBtn.buttonElement.textContent = 'Pause';
63
+ }
64
+ } else {
65
+ this.player.pause();
66
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
67
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', playIconFocus);
68
+ } else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
69
+ this.playPauseBtn.buttonElement.textContent = 'Play';
70
+ }
71
+ }
72
+ }
73
+ });
74
+ this.playPauseBtn.mount(this.container);
75
+
76
+ requestAnimationFrame(() => {
77
+ if (this.playPauseBtn) this.playPauseBtn.focus();
78
+ });
79
+
80
+ this.addPlayPauseBtnEventListeners();
81
+ }
82
+
83
+ addPlayPauseBtnEventListeners() {
84
+ if (!this.playPauseBtn || !this.playPauseBtn.buttonElement) return;
85
+
86
+ this.playPauseBtn.buttonElement.addEventListener('focus', () => {
87
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
88
+ const iconSrc = this.player.video.paused ? playIconFocus : pauseIconFocus;
89
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
90
+ this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255)';
91
+ }
92
+ });
93
+
94
+ this.playPauseBtn.buttonElement.addEventListener('blur', () => {
95
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
96
+ const iconSrc = this.player.video.paused ? playIcon : pauseIcon;
97
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
98
+ this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255, 0.5)';
99
+ }
100
+ });
101
+ }
102
+
103
+ addSettingsBtnEventListeners() {
104
+ if (!this.settingsBtn || !this.settingsBtn.buttonElement) return;
105
+
106
+ this.settingsBtn.buttonElement.addEventListener('focus', () => {
107
+ if (this.settingsBtn && this.settingsBtn.buttonElement && this.settingsBtn.buttonElement.querySelector('img')) {
108
+ const iconSrc = this.player.video.paused ? playIconFocus : pauseIconFocus;
109
+ this.settingsBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
110
+ this.settingsBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255)';
111
+ }
112
+ });
113
+
114
+ this.settingsBtn.buttonElement.addEventListener('blur', () => {
115
+ if (this.settingsBtn && this.settingsBtn.buttonElement && this.settingsBtn.buttonElement.querySelector('img')) {
116
+ const iconSrc = this.player.video.paused ? playIcon : pauseIcon;
117
+ this.settingsBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
118
+ this.settingsBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255, 0.5)';
119
+ }
120
+ });
121
+ }
122
+
123
+ updatePlayPauseButton() {
124
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.seekbar.focused) {
125
+ const iconSrc = this.player.video.paused ? playIcon : pauseIcon;
126
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
127
+ }
128
+ }
129
+
130
+ createSeekbar() {
131
+ if (!this.player.video) return;
132
+
133
+ this.seekbar = new PlayerSeekbar(this.player.video);
134
+ this.seekbar.mount(this.container);
135
+
136
+ this.player.video.addEventListener('play', () => this.updatePlayPauseButton());
137
+ this.player.video.addEventListener('pause', () => this.updatePlayPauseButton());
138
+ }
139
+
140
+ addEventListeners() {
141
+ if (!this.playPauseBtn || !this.playPauseBtn.buttonElement) return;
142
+
143
+ this.playPauseBtn.buttonElement.addEventListener('keydown', (e) => {
144
+ if (e.key === 'ArrowDown') {
145
+ e.preventDefault();
146
+ e.stopPropagation();
147
+
148
+ if (this.settingsBtn) this.settingsBtn.focus();
149
+ else if (this.restartVideoBtn) this.restartVideoBtn.focus();
150
+ else if (this.seekbar) this.seekbar.focus();
151
+ }
152
+ });
153
+
154
+ if (this.settingsBtn && this.settingsBtn.buttonElement) {
155
+ this.settingsBtn.buttonElement.addEventListener('keydown', (e) => {
156
+ if (e.key === 'ArrowDown') {
157
+ e.preventDefault();
158
+ e.stopPropagation();
159
+ if (this.seekbar) this.seekbar.focus();
160
+ } else if (e.key === 'ArrowUp') {
161
+ e.preventDefault();
162
+ e.stopPropagation();
163
+ if (this.playPauseBtn) this.playPauseBtn.focus();
164
+ } else if (e.key === 'ArrowRight') {
165
+ e.preventDefault();
166
+ e.stopPropagation();
167
+ if (this.restartVideoBtn) this.restartVideoBtn.focus();
168
+ }
169
+ });
170
+ }
171
+
172
+ if (this.restartVideoBtn && this.restartVideoBtn.buttonElement) {
173
+ this.restartVideoBtn.buttonElement.addEventListener('keydown', (e) => {
174
+ if (e.key === 'ArrowDown') {
175
+ e.preventDefault();
176
+ e.stopPropagation();
177
+ if (this.seekbar) this.seekbar.focus();
178
+ } else if (e.key === 'ArrowUp') {
179
+ e.preventDefault();
180
+ e.stopPropagation();
181
+ if (this.playPauseBtn) this.playPauseBtn.focus();
182
+ } else if (e.key === 'ArrowLeft') {
183
+ e.preventDefault();
184
+ e.stopPropagation();
185
+ if (this.settingsBtn) this.settingsBtn.focus();
186
+ }
187
+ });
188
+ }
189
+
190
+ const seekbarElement = this.seekbar.getElement && this.seekbar.getElement();
191
+ if (seekbarElement) {
192
+ seekbarElement.addEventListener('keydown', (e) => {
193
+ if (e.key === 'ArrowUp') {
194
+ e.preventDefault();
195
+ e.stopPropagation();
196
+
197
+ if (this.settingsBtn) this.settingsBtn.focus();
198
+ else if (this.restartVideoBtn) this.restartVideoBtn.focus();
199
+ else if (this.playPauseBtn) this.playPauseBtn.focus();
200
+ }
201
+ });
202
+ }
203
+ }
204
+
205
+ createSettingsBtn() {
206
+ this.settingsBtn = new Button({
207
+ imgSrc: settingsIcon,
208
+ imgAltText: 'Settings',
209
+ buttonText: 'Settings',
210
+ width: 40,
211
+ height: 40,
212
+ klassname: 'settings-btn',
213
+ focused: false,
214
+ disabled: false,
215
+ handleClick: () => {
216
+ this.createSideBar();
217
+ this.hidePlayerControls();
218
+ }
219
+ });
220
+ // this.addSettingsBtnEventListeners();
221
+ this.settingsBtn.mount(this.rightSideContainer);
222
+ }
223
+
224
+ createRestartVideoBtn() {
225
+ this.restartVideoBtn = new Button({
226
+ imgSrc: '',
227
+ imgAltText: 'Start From Beginning',
228
+ buttonText: 'Start From Beginning',
229
+ width: undefined,
230
+ height: 35,
231
+ fontWeight: 700,
232
+ klassname: 'restart-btn',
233
+ focused: false,
234
+ disabled: false,
235
+ handleClick: () => {
236
+ if (this.player.video) {
237
+ this.player.video.currentTime = 0;
238
+ }
239
+ }
240
+ });
241
+ this.restartVideoBtn.mount(this.rightSideContainer);
242
+ }
243
+
244
+ createTextContent() {
245
+ this.textContent = new TextContent({
246
+ text: this.videoTitleConfig.text,
247
+ fontSize: this.videoTitleConfig.fontSize,
248
+ color: this.videoTitleConfig.color,
249
+ fontWeight: this.videoTitleConfig.fontWeight,
250
+ });
251
+ this.textContent.mount(this.leftSideContainer);
252
+ }
253
+
254
+ changePlayBackQuality(id) {
255
+ this.selectedPlaybackQuality = id;
256
+ let videoLevels = this.player.videoResolutions();
257
+
258
+ if (!videoLevels || videoLevels.length === 0) {
259
+ console.warn('No video resolutions available to change playback quality.');
260
+ return;
261
+ }
262
+
263
+ if (id == "auto") {
264
+ this.selectedVideoQuality = "auto";
265
+ if (this.drmEnabled) {
266
+
267
+ } else {
268
+ this.player.playerInstance.currentLevel = -1;
269
+ }
270
+ } else {
271
+ for (let i = 0; i < videoLevels?.length; i++) {
272
+ if (videoLevels[i].height == id) {
273
+ this.selectedVideoQuality = videoLevels[i].height;
274
+ if (this.drmEnabled) {
275
+ this.player.playerInstance.setQualityFor('video', i);
276
+ } else {
277
+ this.player.playerInstance.currentLevel = i;
278
+ }
279
+ break;
280
+ }
281
+ }
282
+ }
283
+ }
284
+
285
+ changePlaybackCaptions(id) {
286
+ let textTracks = this.player.captionsOptions();
287
+
288
+ if (!textTracks || textTracks.length === 0) {
289
+ console.warn('No text tracks available to change playback captions.');
290
+ return;
291
+ }
292
+ const validTextTracksType = ['captions', 'subtitles', 'caption', 'subtitle'];
293
+
294
+ for (let i = 0; i < textTracks.length; i++) {
295
+ if(validTextTracksType.includes(textTracks[i].kind.toLowerCase())){
296
+ if (textTracks[i].language === id) {
297
+ this.selectedPlaybackCaption = id;
298
+ textTracks[i].mode = 'showing';
299
+ } else {
300
+ textTracks[i].mode = 'disabled';
301
+ }
302
+ }
303
+ }
304
+ }
305
+
306
+
307
+ changePlaybackAudio(id){
308
+ let audioTracks = this.player.audioTracks();
309
+
310
+ if (!audioTracks || audioTracks.length === 0) {
311
+ console.warn('No audio tracks available to change playback audio.');
312
+ return;
313
+ }
314
+
315
+ for (let i = 0; i < audioTracks.length; i++) {
316
+ if (audioTracks[i].id == id || audioTracks[i].lang == id) {
317
+ this.selectedAudioQuality = id;
318
+ if(this.drmEnabled){
319
+ this.player.playerInstance.setCurrentTrack(audioTracks[i]);
320
+ } else{
321
+ this.player.playerInstance.audioTrack = i;
322
+ }
323
+ break;
324
+ }
325
+ }
326
+ }
327
+
328
+ videoQualitySelector() {
329
+ if (!this.mainSidebar) return;
330
+
331
+ const resolutions = this.player.videoResolutions();
332
+ const currentQuality = this.selectedVideoQuality;
333
+
334
+ const items = [
335
+ {
336
+ text: 'Auto',
337
+ id: 'auto',
338
+ isSelected: currentQuality === 'auto',
339
+ callback: () => {
340
+ this.mainSidebar.currentFocusedOption.focus();
341
+ this.sidebar.unmount();
342
+ }
343
+ },
344
+ ...resolutions.map(resolution => ({
345
+ text: `${resolution.height}p`,
346
+ id: resolution.height,
347
+ isSelected: currentQuality === resolution.height,
348
+ callback: () => {
349
+ this.mainSidebar.currentFocusedOption.focus();
350
+ this.sidebar.unmount();
351
+ }
352
+ }))
353
+ ];
354
+
355
+
356
+ this.sidebar = new Sidebar({
357
+ title: 'Video Quality',
358
+ items: items,
359
+ klassname: 'default-sidebar',
360
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
361
+ type: 'selection',
362
+ focused: true,
363
+ onselect: (data) => {
364
+ this.changePlayBackQuality(data.id);
365
+ },
366
+ callback: () => {
367
+ if (this.mainSidebar.sidebarElement) {
368
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
369
+ }
370
+ }
371
+ });
372
+ this.sidebar.mount(this.container);
373
+ }
374
+
375
+ audioLanguageSelector() {
376
+ if (!this.mainSidebar) return;
377
+ const audioTracks = this.player.audioTracks();
378
+ const currentAudioQuality = this.selectedAudioQuality;
379
+
380
+ this.sidebar = new Sidebar({
381
+ title: 'Audio Language',
382
+ items: audioTracks.map((audio, idx) => ({
383
+ id: audio.id || audio.lang,
384
+ text: audio.name || audio.lang,
385
+ isSelected: (audioTracks.length === 1) || (currentAudioQuality ? currentAudioQuality === audio.id : audio.default),
386
+ callback: () => {
387
+ this.mainSidebar.currentFocusedOption.focus();
388
+ this.sidebar.unmount();
389
+ }
390
+ })),
391
+ klassname: 'default-sidebar',
392
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
393
+ type: 'selection',
394
+ focused: true,
395
+ onselect: (data) => {
396
+ this.changePlaybackAudio(data.id);
397
+ },
398
+ callback: () => {
399
+ if (this.mainSidebar.sidebarElement) {
400
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
401
+ }
402
+ }
403
+ });
404
+ this.sidebar.mount(this.container);
405
+ }
406
+
407
+ subtitlesSelector() {
408
+ if (!this.mainSidebar) return;
409
+
410
+ const captions = this.player.captionsOptions();
411
+ const currentCaption = this.selectedPlaybackCaption;
412
+
413
+
414
+ const items = [
415
+ {
416
+ id: 'off',
417
+ text: 'Off',
418
+ isSelected: currentCaption === 'off', // You can enhance this by checking if all tracks are disabled
419
+ callback: () => {
420
+ this.mainSidebar.currentFocusedOption.focus();
421
+ this.sidebar.unmount();
422
+ }
423
+ },
424
+ ...captions.map(subtitle => ({
425
+ id: subtitle.language,
426
+ text: subtitle.label,
427
+ isSelected: currentCaption === subtitle.language || subtitle.mode === 'showing',
428
+ callback: () => {
429
+ this.mainSidebar.currentFocusedOption.focus();
430
+ this.sidebar.unmount();
431
+ }
432
+ }))
433
+ ];
434
+
435
+
436
+ this.sidebar = new Sidebar({
437
+ title: 'Subtitles',
438
+ items: items,
439
+ klassname: 'default-sidebar',
440
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
441
+ type: 'selection',
442
+ focused: true,
443
+ callback: () => {
444
+ if (this.mainSidebar.sidebarElement) {
445
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
446
+ }
447
+ },
448
+ onselect: (data) => {
449
+ this.changePlaybackCaptions(data.id);
450
+ }
451
+ });
452
+ this.sidebar.mount(this.container);
453
+ }
454
+
455
+ createSideBar() {
456
+ let items = [
457
+ {
458
+ text: 'Video Quality', isSelected: true, callback: () => {
459
+ if (this.mainSidebar.sidebarElement) {
460
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
461
+ }
462
+ this.videoQualitySelector();
463
+ }
464
+ }
465
+ ]
466
+
467
+ if (this.player.audioTracks() && this.player.audioTracks().length > 0) {
468
+ items.push(
469
+ {
470
+ text: 'Audio Language', isSelected: false, callback: () => {
471
+ if (this.mainSidebar.sidebarElement) {
472
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
473
+ }
474
+ this.audioLanguageSelector();
475
+ }
476
+ }
477
+ )
478
+ }
479
+
480
+ if (this.player.captionsOptions() && this.player.captionsOptions().length > 0) {
481
+ items.push(
482
+ {
483
+ text: 'Subtitles', isSelected: false, callback: () => {
484
+ if (this.mainSidebar.sidebarElement) {
485
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
486
+ }
487
+ this.subtitlesSelector();
488
+ }
489
+ }
490
+ )
491
+ }
492
+
493
+ this.mainSidebar = new Sidebar({
494
+ title: 'Settings',
495
+ items: items,
496
+ klassname: 'default-sidebar',
497
+ lastFocusedElement: this.settingsBtn.buttonElement,
498
+ type: 'navigation',
499
+ focused: true,
500
+ callback: () => {
501
+ this.showPlayerControls();
502
+ }
503
+ });
504
+ this.mainSidebar.mount(this.container);
505
+ }
506
+
507
+ hidePlayerControls() {
508
+ if (this.rightSideContainer) {
509
+ this.rightSideContainer.style.visibility = 'hidden';
510
+ }
511
+
512
+ if (this.seekbar) {
513
+ this.seekbar.container.style.visibility = 'hidden';
514
+ }
515
+
516
+ if (this.leftSideContainer) {
517
+ this.leftSideContainer.style.visibility = 'hidden';
518
+ }
519
+ }
520
+
521
+ showPlayerControls() {
522
+ if (this.rightSideContainer) {
523
+ this.rightSideContainer.style.visibility = 'visible';
524
+ }
525
+
526
+ if (this.seekbar) {
527
+ this.seekbar.container.style.visibility = 'visible';
528
+ }
529
+
530
+ if (this.leftSideContainer) {
531
+ this.leftSideContainer.style.visibility = 'visible';
532
+ }
533
+ }
534
+
535
+ attachTo(parent) {
536
+ if (!parent || !(parent instanceof HTMLElement)) {
537
+ throw new Error('VideoPlayerUI: parent must be a valid DOM element');
538
+ }
539
+ parent.appendChild(this.container);
540
+ }
541
+
542
+ getElement() {
543
+ return this.container;
544
+ }
545
+
546
+ unmount() {
547
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
548
+ this.playPauseBtn.buttonElement.removeEventListener('focus', this.updatePlayPauseButton);
549
+ this.playPauseBtn.buttonElement.removeEventListener('blur', this.updatePlayPauseButton);
550
+ this.playPauseBtn.buttonElement.removeEventListener('keydown', this.handlePlayPauseKeydown);
551
+ }
552
+
553
+ if (this.player.video) {
554
+ this.player.video.removeEventListener('play', this.updatePlayPauseButton);
555
+ this.player.video.removeEventListener('pause', this.updatePlayPauseButton);
556
+ }
557
+
558
+ if (this.container) {
559
+ this.container.remove();
560
+ }
561
+ }
562
+ }
563
+
564
+ export default VideoPlayerUI;
@@ -0,0 +1,10 @@
1
+ #playerControlsContainer {
2
+ width: 100%;
3
+ height: 225px;
4
+ bottom: 0px;
5
+ position: absolute;
6
+ outline-width: 0px;
7
+ border-width: 0px;
8
+ z-index: 1000;
9
+ background: linear-gradient(0deg, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%);
10
+ }