@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,501 @@
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
+ import './playerControls.css';
11
+ class PlayerControls {
12
+ constructor(entitlementResponse) {
13
+ this.container = document.createElement('div');
14
+ this.container.id = 'playerControlsContainer';
15
+ this.container.className = 'video-player-ui';
16
+ this.rightSideContainer = document.createElement('div');
17
+ this.rightSideContainer.className = 'right-side-container';
18
+ this.leftSideContainer = document.createElement('div');
19
+ this.leftSideContainer.className = 'left-side-container';
20
+ this.container.appendChild(this.rightSideContainer);
21
+ this.container.appendChild(this.leftSideContainer);
22
+ this.createControls();
23
+ }
24
+
25
+ createControls() {
26
+ this.createPlayPauseBtn();
27
+ this.createSeekbar();
28
+ this.createSettingsBtn();
29
+ this.createRestartVideoBtn();
30
+ this.createTextContent();
31
+ this.addEventListeners();
32
+
33
+ // Attach the video element
34
+ this.container.appendChild(this.player.video);
35
+ }
36
+
37
+ createPlayPauseBtn() {
38
+ this.playPauseBtn = new Button({
39
+ imgSrc: playIconFocus,
40
+ imgAltText: 'Play/Pause',
41
+ buttonText: 'Play',
42
+ width: 70,
43
+ height: 70,
44
+ klassname: 'play-pause-btn',
45
+ focused: false,
46
+ disabled: false,
47
+ handleClick: () => {
48
+ if (this.player.video.paused) {
49
+ this.player.play();
50
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
51
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', pauseIconFocus);
52
+ } else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
53
+ this.playPauseBtn.buttonElement.textContent = 'Pause';
54
+ }
55
+ } else {
56
+ this.player.pause();
57
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
58
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', playIconFocus);
59
+ } else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
60
+ this.playPauseBtn.buttonElement.textContent = 'Play';
61
+ }
62
+ }
63
+ }
64
+ });
65
+ this.playPauseBtn.mount(this.container);
66
+
67
+ requestAnimationFrame(() => {
68
+ if (this.playPauseBtn) this.playPauseBtn.focus();
69
+ });
70
+
71
+ this.createPlayPauseBtnEventListeners();
72
+ }
73
+
74
+ createPlayPauseBtnEventListeners() {
75
+ if (!this.playPauseBtn || !this.playPauseBtn.buttonElement) return;
76
+
77
+ this.playPauseBtn.buttonElement.addEventListener('focus', () => {
78
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
79
+ const iconSrc = this.player.video.paused ? playIconFocus : pauseIconFocus;
80
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
81
+ this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255)';
82
+ }
83
+ });
84
+
85
+ this.playPauseBtn.buttonElement.addEventListener('blur', () => {
86
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
87
+ const iconSrc = this.player.video.paused ? playIcon : pauseIcon;
88
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
89
+ this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255, 0.5)';
90
+ }
91
+ });
92
+ }
93
+
94
+ updatePlayPauseButton() {
95
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.seekbar.focused) {
96
+ const iconSrc = this.player.video.paused ? playIcon : pauseIcon;
97
+ this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
98
+ }
99
+ }
100
+
101
+ createSeekbar() {
102
+ if (!this.player.video) return;
103
+
104
+ this.seekbar = new PlayerSeekbar(this.player.video);
105
+ this.seekbar.mount(this.container);
106
+
107
+ this.player.video.addEventListener('play', () => this.updatePlayPauseButton());
108
+ this.player.video.addEventListener('pause', () => this.updatePlayPauseButton());
109
+ }
110
+
111
+ addEventListeners() {
112
+ if (!this.playPauseBtn || !this.playPauseBtn.buttonElement) return;
113
+
114
+ this.playPauseBtn.buttonElement.addEventListener('keydown', (e) => {
115
+ if (e.key === 'ArrowDown') {
116
+ e.preventDefault();
117
+ e.stopPropagation();
118
+
119
+ if (this.settingsBtn) this.settingsBtn.focus();
120
+ else if (this.restartVideoBtn) this.restartVideoBtn.focus();
121
+ else if (this.seekbar) this.seekbar.focus();
122
+ }
123
+ });
124
+
125
+ if (this.settingsBtn && this.settingsBtn.buttonElement) {
126
+ this.settingsBtn.buttonElement.addEventListener('keydown', (e) => {
127
+ if (e.key === 'ArrowDown') {
128
+ e.preventDefault();
129
+ e.stopPropagation();
130
+ if (this.seekbar) this.seekbar.focus();
131
+ } else if (e.key === 'ArrowUp') {
132
+ e.preventDefault();
133
+ e.stopPropagation();
134
+ if (this.playPauseBtn) this.playPauseBtn.focus();
135
+ } else if (e.key === 'ArrowRight') {
136
+ e.preventDefault();
137
+ e.stopPropagation();
138
+ if (this.restartVideoBtn) this.restartVideoBtn.focus();
139
+ }
140
+ });
141
+ }
142
+
143
+ if (this.restartVideoBtn && this.restartVideoBtn.buttonElement) {
144
+ this.restartVideoBtn.buttonElement.addEventListener('keydown', (e) => {
145
+ if (e.key === 'ArrowDown') {
146
+ e.preventDefault();
147
+ e.stopPropagation();
148
+ if (this.seekbar) this.seekbar.focus();
149
+ } else if (e.key === 'ArrowUp') {
150
+ e.preventDefault();
151
+ e.stopPropagation();
152
+ if (this.playPauseBtn) this.playPauseBtn.focus();
153
+ } else if (e.key === 'ArrowLeft') {
154
+ e.preventDefault();
155
+ e.stopPropagation();
156
+ if (this.settingsBtn) this.settingsBtn.focus();
157
+ }
158
+ });
159
+ }
160
+
161
+ const seekbarElement = this.seekbar.getElement && this.seekbar.getElement();
162
+ if (seekbarElement) {
163
+ seekbarElement.addEventListener('keydown', (e) => {
164
+ if (e.key === 'ArrowUp') {
165
+ e.preventDefault();
166
+ e.stopPropagation();
167
+
168
+ if (this.settingsBtn) this.settingsBtn.focus();
169
+ else if (this.restartVideoBtn) this.restartVideoBtn.focus();
170
+ else if (this.playPauseBtn) this.playPauseBtn.focus();
171
+ }
172
+ });
173
+ }
174
+ }
175
+
176
+ createSettingsBtn() {
177
+ this.settingsBtn = new Button({
178
+ imgSrc: settingsIcon,
179
+ imgAltText: 'Settings',
180
+ buttonText: 'Settings',
181
+ width: 40,
182
+ height: 40,
183
+ klassname: 'settings-btn',
184
+ focused: false,
185
+ disabled: false,
186
+ handleClick: () => {
187
+ this.createSideBar();
188
+ }
189
+ });
190
+ this.settingsBtn.mount(this.rightSideContainer);
191
+ }
192
+
193
+ createRestartVideoBtn() {
194
+ this.restartVideoBtn = new Button({
195
+ imgSrc: '',
196
+ imgAltText: 'Start From Beginning',
197
+ buttonText: 'Start From Beginning',
198
+ width: 150,
199
+ height: 35,
200
+ klassname: 'restart-btn',
201
+ focused: false,
202
+ disabled: false,
203
+ handleClick: () => {
204
+ if (this.player.video) {
205
+ this.player.video.currentTime = 0;
206
+ }
207
+ }
208
+ });
209
+ this.restartVideoBtn.mount(this.rightSideContainer);
210
+ }
211
+
212
+ createTextContent() {
213
+ this.textContent = new TextContent({
214
+ text: this.videoTitleConfig.text,
215
+ fontSize: this.videoTitleConfig.fontSize,
216
+ color: this.videoTitleConfig.color,
217
+ fontWeight: this.videoTitleConfig.bold,
218
+ });
219
+ this.textContent.mount(this.leftSideContainer);
220
+ }
221
+
222
+ changePlayBackQuality(id) {
223
+ this.selectedPlaybackQuality = id;
224
+ let videoLevels = this.player.videoResolutions();
225
+
226
+ if (!videoLevels || videoLevels.length === 0) {
227
+ console.warn('No video resolutions available to change playback quality.');
228
+ return;
229
+ }
230
+
231
+ if (id == "auto") {
232
+ this.selectedVideoQuality = "auto";
233
+ if (this.drmEnabled) {
234
+
235
+ } else {
236
+ this.player.playerInstance.currentLevel = -1;
237
+ }
238
+ } else {
239
+ for (let i = 0; i < videoLevels?.length; i++) {
240
+ if (videoLevels[i].height == id) {
241
+ this.selectedVideoQuality = videoLevels[i].height;
242
+ if (this.drmEnabled) {
243
+ this.player.playerInstance.setQualityFor('video', i);
244
+ } else {
245
+ this.player.playerInstance.currentLevel = i;
246
+ }
247
+ break;
248
+ }
249
+ }
250
+ }
251
+ }
252
+
253
+ changePlaybackCaptions(id) {
254
+ let textTracks = this.player.captionsOptions();
255
+
256
+ if (!textTracks || textTracks.length === 0) {
257
+ console.warn('No text tracks available to change playback captions.');
258
+ return;
259
+ }
260
+ const validTextTracksType = ['captions', 'subtitles', 'caption', 'subtitle'];
261
+
262
+ for (let i = 0; i < textTracks.length; i++) {
263
+ if(validTextTracksType.includes(textTracks[i].kind.toLowerCase())){
264
+ if (textTracks[i].language === id) {
265
+ this.selectedPlaybackCaption = id;
266
+ textTracks[i].mode = 'showing';
267
+ } else {
268
+ textTracks[i].mode = 'disabled';
269
+ }
270
+ }
271
+ }
272
+ }
273
+
274
+
275
+ changePlaybackAudio(id){
276
+ let audioTracks = this.player.audioTracks();
277
+
278
+ if (!audioTracks || audioTracks.length === 0) {
279
+ console.warn('No audio tracks available to change playback audio.');
280
+ return;
281
+ }
282
+
283
+ for (let i = 0; i < audioTracks.length; i++) {
284
+ if (audioTracks[i].id == id || audioTracks[i].lang == id) {
285
+ this.selectedAudioQuality = id;
286
+ if(this.drmEnabled){
287
+ this.player.playerInstance.setCurrentTrack(audioTracks[i]);
288
+ } else{
289
+ this.player.playerInstance.audioTrack = i;
290
+ }
291
+ break;
292
+ }
293
+ }
294
+ }
295
+
296
+ videoQualitySelector() {
297
+ if (!this.mainSidebar) return;
298
+
299
+ const resolutions = this.player.videoResolutions();
300
+ const currentQuality = this.selectedVideoQuality;
301
+
302
+ const items = [
303
+ {
304
+ text: 'Auto',
305
+ id: 'auto',
306
+ isSelected: currentQuality === 'auto',
307
+ callback: () => {
308
+ this.mainSidebar.currentFocusedOption.focus();
309
+ this.sidebar.unmount();
310
+ }
311
+ },
312
+ ...resolutions.map(resolution => ({
313
+ text: `${resolution.height}p`,
314
+ id: resolution.height,
315
+ isSelected: currentQuality === resolution.height,
316
+ callback: () => {
317
+ this.mainSidebar.currentFocusedOption.focus();
318
+ this.sidebar.unmount();
319
+ }
320
+ }))
321
+ ];
322
+
323
+
324
+ this.sidebar = new Sidebar({
325
+ title: 'Video Quality',
326
+ items: items,
327
+ klassname: 'default-sidebar',
328
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
329
+ type: 'selection',
330
+ focused: true,
331
+ onselect: (data) => {
332
+ this.changePlayBackQuality(data.id);
333
+ },
334
+ callback: () => {
335
+ if (this.mainSidebar.sidebarElement) {
336
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
337
+ }
338
+ }
339
+ });
340
+ this.sidebar.mount(this.container);
341
+ }
342
+
343
+ audioLanguageSelector() {
344
+ if (!this.mainSidebar) return;
345
+ const audioTracks = this.player.audioTracks();
346
+ const currentAudioQuality = this.selectedAudioQuality;
347
+
348
+ this.sidebar = new Sidebar({
349
+ title: 'Audio Language',
350
+ items: audioTracks.map((audio, idx) => ({
351
+ id: audio.id || audio.lang,
352
+ text: audio.name || audio.lang,
353
+ isSelected: (audioTracks.length === 1) || (currentAudioQuality ? currentAudioQuality === audio.id : audio.default),
354
+ callback: () => {
355
+ this.mainSidebar.currentFocusedOption.focus();
356
+ this.sidebar.unmount();
357
+ }
358
+ })),
359
+ klassname: 'default-sidebar',
360
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
361
+ type: 'selection',
362
+ focused: true,
363
+ onselect: (data) => {
364
+ this.changePlaybackAudio(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
+ subtitlesSelector() {
376
+ if (!this.mainSidebar) return;
377
+
378
+ const captions = this.player.captionsOptions();
379
+ const currentCaption = this.selectedPlaybackCaption;
380
+
381
+
382
+ const items = [
383
+ {
384
+ id: 'off',
385
+ text: 'Off',
386
+ isSelected: currentCaption === 'off', // You can enhance this by checking if all tracks are disabled
387
+ callback: () => {
388
+ this.mainSidebar.currentFocusedOption.focus();
389
+ this.sidebar.unmount();
390
+ }
391
+ },
392
+ ...captions.map(subtitle => ({
393
+ id: subtitle.language,
394
+ text: subtitle.label,
395
+ isSelected: currentCaption === subtitle.language || subtitle.mode === 'showing',
396
+ callback: () => {
397
+ this.mainSidebar.currentFocusedOption.focus();
398
+ this.sidebar.unmount();
399
+ }
400
+ }))
401
+ ];
402
+
403
+
404
+ this.sidebar = new Sidebar({
405
+ title: 'Subtitles',
406
+ items: items,
407
+ klassname: 'default-sidebar',
408
+ lastFocusedElement: this.mainSidebar.currentFocusedOption,
409
+ type: 'selection',
410
+ focused: true,
411
+ callback: () => {
412
+ if (this.mainSidebar.sidebarElement) {
413
+ this.mainSidebar.sidebarElement.style.visibility = 'visible';
414
+ }
415
+ },
416
+ onselect: (data) => {
417
+ this.changePlaybackCaptions(data.id);
418
+ }
419
+ });
420
+ this.sidebar.mount(this.container);
421
+ }
422
+
423
+ createSideBar() {
424
+ let items = [
425
+ {
426
+ text: 'Video Quality', isSelected: true, callback: () => {
427
+ if (this.mainSidebar.sidebarElement) {
428
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
429
+ }
430
+ this.videoQualitySelector();
431
+ }
432
+ }
433
+ ]
434
+
435
+ if (this.player.audioTracks() && this.player.audioTracks().length > 0) {
436
+ items.push(
437
+ {
438
+ text: 'Audio Language', isSelected: false, callback: () => {
439
+ if (this.mainSidebar.sidebarElement) {
440
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
441
+ }
442
+ this.audioLanguageSelector();
443
+ }
444
+ }
445
+ )
446
+ }
447
+
448
+ if (this.player.captionsOptions() && this.player.captionsOptions().length > 0) {
449
+ items.push(
450
+ {
451
+ text: 'Subtitles', isSelected: false, callback: () => {
452
+ if (this.mainSidebar.sidebarElement) {
453
+ this.mainSidebar.sidebarElement.style.visibility = 'hidden';
454
+ }
455
+ this.subtitlesSelector();
456
+ }
457
+ }
458
+ )
459
+ }
460
+
461
+ this.mainSidebar = new Sidebar({
462
+ title: 'Settings',
463
+ items: items,
464
+ klassname: 'default-sidebar',
465
+ lastFocusedElement: this.settingsBtn.buttonElement,
466
+ type: 'navigation',
467
+ focused: true
468
+ });
469
+ this.mainSidebar.mount(this.container);
470
+ }
471
+
472
+ attachTo(parent) {
473
+ if (!parent || !(parent instanceof HTMLElement)) {
474
+ throw new Error('VideoPlayerUI: parent must be a valid DOM element');
475
+ }
476
+ parent.appendChild(this.container);
477
+ }
478
+
479
+ getElement() {
480
+ return this.container;
481
+ }
482
+
483
+ unmount() {
484
+ if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
485
+ this.playPauseBtn.buttonElement.removeEventListener('focus', this.updatePlayPauseButton);
486
+ this.playPauseBtn.buttonElement.removeEventListener('blur', this.updatePlayPauseButton);
487
+ this.playPauseBtn.buttonElement.removeEventListener('keydown', this.handlePlayPauseKeydown);
488
+ }
489
+
490
+ if (this.player.video) {
491
+ this.player.video.removeEventListener('play', this.updatePlayPauseButton);
492
+ this.player.video.removeEventListener('pause', this.updatePlayPauseButton);
493
+ }
494
+
495
+ if (this.container) {
496
+ this.container.remove();
497
+ }
498
+ }
499
+ }
500
+
501
+ export default VideoPlayerUI;