@viewlift/player-backup 1.0.1 → 1.0.2-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 (136) 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 +45 -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 +32 -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 +242 -0
  34. package/src/player-components/player-buttons/playerButtons.js +104 -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 +55 -0
  40. package/src/player-ui/player-ui.js +514 -0
  41. package/src/playerInitializer.js +335 -0
  42. package/src/styles/index.css +200 -0
  43. package/src/utilities/utilities.js +79 -0
  44. package/tsconfig.json +14 -0
  45. package/cjs/autoNextVideo-823821e8.js +0 -1
  46. package/cjs/bundle.css +0 -657
  47. package/cjs/caption-settings-67212c17.js +0 -1
  48. package/cjs/caption-settings-d42c056e.js +0 -1
  49. package/cjs/debugSelection-cbfdabb7.js +0 -1
  50. package/cjs/dvr_skin-f7f770ae.js +0 -1
  51. package/cjs/error-26d5a3c3.js +0 -1
  52. package/cjs/features-164c3cc6.js +0 -1
  53. package/cjs/generic-8b99b151.js +0 -1
  54. package/cjs/icons-7afb9c13.js +0 -1
  55. package/cjs/index-3dfe6459.js +0 -1
  56. package/cjs/index.js +0 -1
  57. package/cjs/keyboardShortcuts-cfd998c2.js +0 -1
  58. package/cjs/loader-393b838a.js +0 -1
  59. package/cjs/multicam-21c9a90b.js +0 -1
  60. package/cjs/multicam-a41fe4a6.js +0 -1
  61. package/cjs/multicamv2-76d8530b.js +0 -1
  62. package/cjs/multicamv2-c148fa24.js +0 -1
  63. package/cjs/mwebPotrait-3c11d7cf.js +0 -1
  64. package/cjs/mwebPotraitTray-b9d5d45a.js +0 -1
  65. package/cjs/nextEpisodeButton-300afadc.js +0 -1
  66. package/cjs/nextEpisodeButton-b6e6586f.js +0 -1
  67. package/cjs/nondvr_skin-ef2cb3b2.js +0 -1
  68. package/cjs/playlist-925f808b.js +0 -1
  69. package/cjs/playlist-df87ca90.js +0 -1
  70. package/cjs/renditions-bc841552.js +0 -1
  71. package/cjs/resolution-6a9adf54.js +0 -1
  72. package/cjs/series-82ec79d3.js +0 -1
  73. package/cjs/series-9c237975.js +0 -1
  74. package/cjs/series-v2-24855152.js +0 -1
  75. package/cjs/series-v2-70137d8c.js +0 -1
  76. package/cjs/settings-icon-a63f46fc.js +0 -1
  77. package/cjs/settings-icon-e6a8feee.js +0 -1
  78. package/cjs/skin-095cc078.js +0 -1
  79. package/cjs/skin-225252ff.js +0 -1
  80. package/cjs/skin-39ab30e2.js +0 -1
  81. package/cjs/skin-84083352.js +0 -1
  82. package/cjs/skin-93a3e5ae.js +0 -1
  83. package/cjs/skin-983a2ea7.js +0 -1
  84. package/cjs/skin-afbec6d7.js +0 -1
  85. package/cjs/skin-ec49b877.js +0 -1
  86. package/cjs/skin-f225a42e.js +0 -1
  87. package/cjs/skin-fb394911.js +0 -1
  88. package/cjs/util-fa21734a.js +0 -1
  89. package/cjs/videoSelector-01a9ef43.js +0 -1
  90. package/cjs/videoSelector-fcdf11eb.js +0 -1
  91. package/esm/autoNextVideo-1672740e.js +0 -1
  92. package/esm/bundle.css +0 -657
  93. package/esm/caption-settings-2e47813b.js +0 -1
  94. package/esm/caption-settings-3eacf3a0.js +0 -1
  95. package/esm/debugSelection-2601b8b3.js +0 -1
  96. package/esm/dvr_skin-9cc1b144.js +0 -1
  97. package/esm/error-2395864b.js +0 -1
  98. package/esm/features-f86404ce.js +0 -1
  99. package/esm/generic-7c43020f.js +0 -1
  100. package/esm/icons-c18c70b7.js +0 -1
  101. package/esm/index-9f022e82.js +0 -1
  102. package/esm/index.js +0 -1
  103. package/esm/keyboardShortcuts-c06f3c7b.js +0 -1
  104. package/esm/loader-580278fe.js +0 -1
  105. package/esm/multicam-94da3759.js +0 -1
  106. package/esm/multicam-de741974.js +0 -1
  107. package/esm/multicamv2-0105c40f.js +0 -1
  108. package/esm/multicamv2-d006cffa.js +0 -1
  109. package/esm/mwebPotrait-3c1805d8.js +0 -1
  110. package/esm/mwebPotraitTray-5ab39989.js +0 -1
  111. package/esm/nextEpisodeButton-2ea69b56.js +0 -1
  112. package/esm/nextEpisodeButton-a1556cdf.js +0 -1
  113. package/esm/nondvr_skin-64be70e5.js +0 -1
  114. package/esm/playlist-032fbbf3.js +0 -1
  115. package/esm/playlist-7ecf432a.js +0 -1
  116. package/esm/renditions-97276745.js +0 -1
  117. package/esm/resolution-38cd4f5c.js +0 -1
  118. package/esm/series-041152aa.js +0 -1
  119. package/esm/series-977edced.js +0 -1
  120. package/esm/series-v2-0727ee8c.js +0 -1
  121. package/esm/series-v2-516c91c2.js +0 -1
  122. package/esm/settings-icon-0125bffd.js +0 -1
  123. package/esm/settings-icon-2b713fbf.js +0 -1
  124. package/esm/skin-2c638dc1.js +0 -1
  125. package/esm/skin-42c2f81d.js +0 -1
  126. package/esm/skin-5e2fa9d4.js +0 -1
  127. package/esm/skin-6093bfb3.js +0 -1
  128. package/esm/skin-60a41d44.js +0 -1
  129. package/esm/skin-665ec17e.js +0 -1
  130. package/esm/skin-93e320fc.js +0 -1
  131. package/esm/skin-b939c35e.js +0 -1
  132. package/esm/skin-cd537931.js +0 -1
  133. package/esm/skin-d5510f70.js +0 -1
  134. package/esm/util-d9f5a7be.js +0 -1
  135. package/esm/videoSelector-8889c58e.js +0 -1
  136. package/esm/videoSelector-8e258d45.js +0 -1
@@ -0,0 +1,514 @@
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
+ if (!config || typeof config !== 'object') {
17
+ throw new Error('VideoPlayerUI: config must be a valid object');
18
+ }
19
+
20
+ this.player = player;
21
+ this.videoTitleConfig = config.videoTitleConfig || {};
22
+ this.drmEnabled = config.drmEnabled;
23
+ this.selectedVideoQuality = "auto";
24
+ this.selectedPlaybackCaption = "";
25
+ this.selectedAudioQuality = "";
26
+
27
+ this.container = document.createElement('div');
28
+ this.container.className = 'video-player-ui';
29
+ this.rightSideContainer = document.createElement('div');
30
+ this.rightSideContainer.className = 'right-side-container';
31
+ this.leftSideContainer = document.createElement('div');
32
+ this.leftSideContainer.className = 'left-side-container';
33
+ this.container.appendChild(this.rightSideContainer);
34
+ this.container.appendChild(this.leftSideContainer);
35
+ this.createControls();
36
+ }
37
+
38
+ createControls() {
39
+ this.createPlayPauseBtn();
40
+ this.createSeekbar();
41
+ this.createSettingsBtn();
42
+ this.createRestartVideoBtn();
43
+ this.createTextContent();
44
+ this.addEventListeners();
45
+
46
+ // Attach the video element
47
+ this.container.appendChild(this.player.video);
48
+ }
49
+
50
+ createPlayPauseBtn() {
51
+ this.playPauseBtn = new Button({
52
+ imgSrc: playIconFocus,
53
+ imgAltText: 'Play/Pause',
54
+ buttonText: 'Play',
55
+ width: 70,
56
+ height: 70,
57
+ klassname: 'play-pause-btn',
58
+ focused: false,
59
+ disabled: false,
60
+ handleClick: () => {
61
+ if (this.player.video.paused) {
62
+ this.player.play();
63
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
64
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', pauseIconFocus);
65
+ } else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
66
+ this.playPauseBtn.buttonElement.textContent = 'Pause';
67
+ }
68
+ } else {
69
+ this.player.pause();
70
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
71
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', playIconFocus);
72
+ } else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
73
+ this.playPauseBtn.buttonElement.textContent = 'Play';
74
+ }
75
+ }
76
+ }
77
+ });
78
+ this.playPauseBtn.mount(this.container);
79
+
80
+ requestAnimationFrame(() => {
81
+ if (this.playPauseBtn) this.playPauseBtn.focus();
82
+ });
83
+
84
+ this.createPlayPauseBtnEventListeners();
85
+ }
86
+
87
+ createPlayPauseBtnEventListeners() {
88
+ if (!this.playPauseBtn || !this.playPauseBtn.buttonElement) return;
89
+
90
+ this.playPauseBtn.buttonElement.addEventListener('focus', () => {
91
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
92
+ const iconSrc = this.player.video.paused ? playIconFocus : pauseIconFocus;
93
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
94
+ this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255)';
95
+ }
96
+ });
97
+
98
+ this.playPauseBtn.buttonElement.addEventListener('blur', () => {
99
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
100
+ const iconSrc = this.player.video.paused ? playIcon : pauseIcon;
101
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
102
+ this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255, 0.5)';
103
+ }
104
+ });
105
+ }
106
+
107
+ updatePlayPauseButton() {
108
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.seekbar.focused) {
109
+ const iconSrc = this.player.video.paused ? playIcon : pauseIcon;
110
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
111
+ }
112
+ }
113
+
114
+ createSeekbar() {
115
+ if (!this.player.video) return;
116
+
117
+ this.seekbar = new PlayerSeekbar(this.player.video);
118
+ this.seekbar.mount(this.container);
119
+
120
+ this.player.video.addEventListener('play', () => this.updatePlayPauseButton());
121
+ this.player.video.addEventListener('pause', () => this.updatePlayPauseButton());
122
+ }
123
+
124
+ addEventListeners() {
125
+ if (!this.playPauseBtn || !this.playPauseBtn.buttonElement) return;
126
+
127
+ this.playPauseBtn.buttonElement.addEventListener('keydown', (e) => {
128
+ if (e.key === 'ArrowDown') {
129
+ e.preventDefault();
130
+ e.stopPropagation();
131
+
132
+ if (this.settingsBtn) this.settingsBtn.focus();
133
+ else if (this.restartVideoBtn) this.restartVideoBtn.focus();
134
+ else if (this.seekbar) this.seekbar.focus();
135
+ }
136
+ });
137
+
138
+ if (this.settingsBtn && this.settingsBtn.buttonElement) {
139
+ this.settingsBtn.buttonElement.addEventListener('keydown', (e) => {
140
+ if (e.key === 'ArrowDown') {
141
+ e.preventDefault();
142
+ e.stopPropagation();
143
+ if (this.seekbar) this.seekbar.focus();
144
+ } else if (e.key === 'ArrowUp') {
145
+ e.preventDefault();
146
+ e.stopPropagation();
147
+ if (this.playPauseBtn) this.playPauseBtn.focus();
148
+ } else if (e.key === 'ArrowRight') {
149
+ e.preventDefault();
150
+ e.stopPropagation();
151
+ if (this.restartVideoBtn) this.restartVideoBtn.focus();
152
+ }
153
+ });
154
+ }
155
+
156
+ if (this.restartVideoBtn && this.restartVideoBtn.buttonElement) {
157
+ this.restartVideoBtn.buttonElement.addEventListener('keydown', (e) => {
158
+ if (e.key === 'ArrowDown') {
159
+ e.preventDefault();
160
+ e.stopPropagation();
161
+ if (this.seekbar) this.seekbar.focus();
162
+ } else if (e.key === 'ArrowUp') {
163
+ e.preventDefault();
164
+ e.stopPropagation();
165
+ if (this.playPauseBtn) this.playPauseBtn.focus();
166
+ } else if (e.key === 'ArrowLeft') {
167
+ e.preventDefault();
168
+ e.stopPropagation();
169
+ if (this.settingsBtn) this.settingsBtn.focus();
170
+ }
171
+ });
172
+ }
173
+
174
+ const seekbarElement = this.seekbar.getElement && this.seekbar.getElement();
175
+ if (seekbarElement) {
176
+ seekbarElement.addEventListener('keydown', (e) => {
177
+ if (e.key === 'ArrowUp') {
178
+ e.preventDefault();
179
+ e.stopPropagation();
180
+
181
+ if (this.settingsBtn) this.settingsBtn.focus();
182
+ else if (this.restartVideoBtn) this.restartVideoBtn.focus();
183
+ else if (this.playPauseBtn) this.playPauseBtn.focus();
184
+ }
185
+ });
186
+ }
187
+ }
188
+
189
+ createSettingsBtn() {
190
+ this.settingsBtn = new Button({
191
+ imgSrc: settingsIcon,
192
+ imgAltText: 'Settings',
193
+ buttonText: 'Settings',
194
+ width: 40,
195
+ height: 40,
196
+ klassname: 'settings-btn',
197
+ focused: false,
198
+ disabled: false,
199
+ handleClick: () => {
200
+ this.createSideBar();
201
+ }
202
+ });
203
+ this.settingsBtn.mount(this.rightSideContainer);
204
+ }
205
+
206
+ createRestartVideoBtn() {
207
+ this.restartVideoBtn = new Button({
208
+ imgSrc: '',
209
+ imgAltText: 'Start From Beginning',
210
+ buttonText: 'Start From Beginning',
211
+ width: 150,
212
+ height: 35,
213
+ klassname: 'restart-btn',
214
+ focused: false,
215
+ disabled: false,
216
+ handleClick: () => {
217
+ if (this.player.video) {
218
+ this.player.video.currentTime = 0;
219
+ }
220
+ }
221
+ });
222
+ this.restartVideoBtn.mount(this.rightSideContainer);
223
+ }
224
+
225
+ createTextContent() {
226
+ this.textContent = new TextContent({
227
+ text: this.videoTitleConfig.text,
228
+ fontSize: this.videoTitleConfig.fontSize,
229
+ color: this.videoTitleConfig.color,
230
+ fontWeight: this.videoTitleConfig.bold,
231
+ });
232
+ this.textContent.mount(this.leftSideContainer);
233
+ }
234
+
235
+ changePlayBackQuality(id) {
236
+ this.selectedPlaybackQuality = id;
237
+ let videoLevels = this.player.videoResolutions();
238
+
239
+ if (!videoLevels || videoLevels.length === 0) {
240
+ console.warn('No video resolutions available to change playback quality.');
241
+ return;
242
+ }
243
+
244
+ if (id == "auto") {
245
+ this.selectedVideoQuality = "auto";
246
+ if (this.drmEnabled) {
247
+
248
+ } else {
249
+ this.player.playerInstance.currentLevel = -1;
250
+ }
251
+ } else {
252
+ for (let i = 0; i < videoLevels?.length; i++) {
253
+ if (videoLevels[i].height == id) {
254
+ this.selectedVideoQuality = videoLevels[i].height;
255
+ if (this.drmEnabled) {
256
+ this.player.playerInstance.setQualityFor('video', i);
257
+ } else {
258
+ this.player.playerInstance.currentLevel = i;
259
+ }
260
+ break;
261
+ }
262
+ }
263
+ }
264
+ }
265
+
266
+ changePlaybackCaptions(id) {
267
+ let textTracks = this.player.captionsOptions();
268
+
269
+ if (!textTracks || textTracks.length === 0) {
270
+ console.warn('No text tracks available to change playback captions.');
271
+ return;
272
+ }
273
+ const validTextTracksType = ['captions', 'subtitles', 'caption', 'subtitle'];
274
+
275
+ for (let i = 0; i < textTracks.length; i++) {
276
+ if(validTextTracksType.includes(textTracks[i].kind.toLowerCase())){
277
+ if (textTracks[i].language === id) {
278
+ this.selectedPlaybackCaption = id;
279
+ textTracks[i].mode = 'showing';
280
+ } else {
281
+ textTracks[i].mode = 'disabled';
282
+ }
283
+ }
284
+ }
285
+ }
286
+
287
+
288
+ changePlaybackAudio(id){
289
+ let audioTracks = this.player.audioTracks();
290
+
291
+ if (!audioTracks || audioTracks.length === 0) {
292
+ console.warn('No audio tracks available to change playback audio.');
293
+ return;
294
+ }
295
+
296
+ for (let i = 0; i < audioTracks.length; i++) {
297
+ if (audioTracks[i].id == id || audioTracks[i].lang == id) {
298
+ this.selectedAudioQuality = id;
299
+ if(this.drmEnabled){
300
+ this.player.playerInstance.setCurrentTrack(audioTracks[i]);
301
+ } else{
302
+ this.player.playerInstance.audioTrack = i;
303
+ }
304
+ break;
305
+ }
306
+ }
307
+ }
308
+
309
+ videoQualitySelector() {
310
+ if (!this.mainSidebar) return;
311
+
312
+ const resolutions = this.player.videoResolutions();
313
+ const currentQuality = this.selectedVideoQuality;
314
+
315
+ const items = [
316
+ {
317
+ text: 'Auto',
318
+ id: 'auto',
319
+ isSelected: currentQuality === 'auto',
320
+ callback: () => {
321
+ this.mainSidebar.currentFocusedOption.focus();
322
+ this.sidebar.unmount();
323
+ }
324
+ },
325
+ ...resolutions.map(resolution => ({
326
+ text: `${resolution.height}p`,
327
+ id: resolution.height,
328
+ isSelected: currentQuality === resolution.height,
329
+ callback: () => {
330
+ this.mainSidebar.currentFocusedOption.focus();
331
+ this.sidebar.unmount();
332
+ }
333
+ }))
334
+ ];
335
+
336
+
337
+ this.sidebar = new Sidebar({
338
+ title: 'Video Quality',
339
+ items: items,
340
+ klassname: 'default-sidebar',
341
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
342
+ type: 'selection',
343
+ focused: true,
344
+ onselect: (data) => {
345
+ this.changePlayBackQuality(data.id);
346
+ },
347
+ callback: () => {
348
+ if (this.mainSidebar.sidebarElement) {
349
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
350
+ }
351
+ }
352
+ });
353
+ this.sidebar.mount(this.container);
354
+ }
355
+
356
+ audioLanguageSelector() {
357
+ if (!this.mainSidebar) return;
358
+ const audioTracks = this.player.audioTracks();
359
+ const currentAudioQuality = this.selectedAudioQuality;
360
+
361
+ this.sidebar = new Sidebar({
362
+ title: 'Audio Language',
363
+ items: audioTracks.map((audio, idx) => ({
364
+ id: audio.id || audio.lang,
365
+ text: audio.name || audio.lang,
366
+ isSelected: (audioTracks.length === 1) || (currentAudioQuality ? currentAudioQuality === audio.id : audio.default),
367
+ callback: () => {
368
+ this.mainSidebar.currentFocusedOption.focus();
369
+ this.sidebar.unmount();
370
+ }
371
+ })),
372
+ klassname: 'default-sidebar',
373
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
374
+ type: 'selection',
375
+ focused: true,
376
+ onselect: (data) => {
377
+ this.changePlaybackAudio(data.id);
378
+ },
379
+ callback: () => {
380
+ if (this.mainSidebar.sidebarElement) {
381
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
382
+ }
383
+ }
384
+ });
385
+ this.sidebar.mount(this.container);
386
+ }
387
+
388
+ subtitlesSelector() {
389
+ if (!this.mainSidebar) return;
390
+
391
+ const captions = this.player.captionsOptions();
392
+ const currentCaption = this.selectedPlaybackCaption;
393
+
394
+
395
+ const items = [
396
+ {
397
+ id: 'off',
398
+ text: 'Off',
399
+ isSelected: currentCaption === 'off', // You can enhance this by checking if all tracks are disabled
400
+ callback: () => {
401
+ this.mainSidebar.currentFocusedOption.focus();
402
+ this.sidebar.unmount();
403
+ }
404
+ },
405
+ ...captions.map(subtitle => ({
406
+ id: subtitle.language,
407
+ text: subtitle.label,
408
+ isSelected: currentCaption === subtitle.language || subtitle.mode === 'showing',
409
+ callback: () => {
410
+ this.mainSidebar.currentFocusedOption.focus();
411
+ this.sidebar.unmount();
412
+ }
413
+ }))
414
+ ];
415
+
416
+
417
+ this.sidebar = new Sidebar({
418
+ title: 'Subtitles',
419
+ items: items,
420
+ klassname: 'default-sidebar',
421
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
422
+ type: 'selection',
423
+ focused: true,
424
+ callback: () => {
425
+ if (this.mainSidebar.sidebarElement) {
426
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
427
+ }
428
+ },
429
+ onselect: (data) => {
430
+ this.changePlaybackCaptions(data.id);
431
+ }
432
+ });
433
+ this.sidebar.mount(this.container);
434
+ }
435
+
436
+ createSideBar() {
437
+ let items = [
438
+ {
439
+ text: 'Video Quality', isSelected: true, callback: () => {
440
+ if (this.mainSidebar.sidebarElement) {
441
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
442
+ }
443
+ this.videoQualitySelector();
444
+ }
445
+ }
446
+ ]
447
+
448
+ if (this.player.audioTracks() && this.player.audioTracks().length > 0) {
449
+ items.push(
450
+ {
451
+ text: 'Audio Language', isSelected: false, callback: () => {
452
+ if (this.mainSidebar.sidebarElement) {
453
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
454
+ }
455
+ this.audioLanguageSelector();
456
+ }
457
+ }
458
+ )
459
+ }
460
+
461
+ if (this.player.captionsOptions() && this.player.captionsOptions().length > 0) {
462
+ items.push(
463
+ {
464
+ text: 'Subtitles', isSelected: false, callback: () => {
465
+ if (this.mainSidebar.sidebarElement) {
466
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
467
+ }
468
+ this.subtitlesSelector();
469
+ }
470
+ }
471
+ )
472
+ }
473
+
474
+ this.mainSidebar = new Sidebar({
475
+ title: 'Settings',
476
+ items: items,
477
+ klassname: 'default-sidebar',
478
+ lastFocusedElement: this.settingsBtn.buttonElement,
479
+ type: 'navigation',
480
+ focused: true
481
+ });
482
+ this.mainSidebar.mount(this.container);
483
+ }
484
+
485
+ attachTo(parent) {
486
+ if (!parent || !(parent instanceof HTMLElement)) {
487
+ throw new Error('VideoPlayerUI: parent must be a valid DOM element');
488
+ }
489
+ parent.appendChild(this.container);
490
+ }
491
+
492
+ getElement() {
493
+ return this.container;
494
+ }
495
+
496
+ unmount() {
497
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
498
+ this.playPauseBtn.buttonElement.removeEventListener('focus', this.updatePlayPauseButton);
499
+ this.playPauseBtn.buttonElement.removeEventListener('blur', this.updatePlayPauseButton);
500
+ this.playPauseBtn.buttonElement.removeEventListener('keydown', this.handlePlayPauseKeydown);
501
+ }
502
+
503
+ if (this.player.video) {
504
+ this.player.video.removeEventListener('play', this.updatePlayPauseButton);
505
+ this.player.video.removeEventListener('pause', this.updatePlayPauseButton);
506
+ }
507
+
508
+ if (this.container) {
509
+ this.container.remove();
510
+ }
511
+ }
512
+ }
513
+
514
+ export default VideoPlayerUI;