@viewlift/player-backup 1.0.2-lighteningjs → 1.0.2
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/cjs/autoNextVideo-815419cb.js +1 -0
- package/cjs/bundle.css +577 -0
- package/cjs/caption-settings-67212c17.js +1 -0
- package/cjs/caption-settings-6e301004.js +1 -0
- package/cjs/dvr_skin-f7f770ae.js +1 -0
- package/cjs/error-26d5a3c3.js +1 -0
- package/cjs/features-fd1e9785.js +1 -0
- package/cjs/generic-81b1be69.js +1 -0
- package/cjs/icons-51594f89.js +1 -0
- package/cjs/index.js +1 -0
- package/cjs/keyboardShortcuts-1afbf18c.js +1 -0
- package/cjs/loader-393b838a.js +1 -0
- package/cjs/multicam-1647c428.js +1 -0
- package/cjs/multicam-a41fe4a6.js +1 -0
- package/cjs/multicamv2-76d8530b.js +1 -0
- package/cjs/multicamv2-f48d95fe.js +1 -0
- package/cjs/mwebPotrait-3c11d7cf.js +1 -0
- package/cjs/mwebPotraitTray-a3a2715b.js +1 -0
- package/cjs/nextEpisodeButton-b6e6586f.js +1 -0
- package/cjs/nextEpisodeButton-cc80609a.js +1 -0
- package/cjs/nondvr_skin-ef2cb3b2.js +1 -0
- package/cjs/playlist-a550a735.js +1 -0
- package/cjs/playlist-df87ca90.js +1 -0
- package/cjs/renditions-c3ea26e8.js +1 -0
- package/cjs/resolution-51b38a3e.js +1 -0
- package/cjs/series-6178964e.js +1 -0
- package/cjs/series-9c237975.js +1 -0
- package/cjs/series-v2-70137d8c.js +1 -0
- package/cjs/series-v2-a265ff17.js +1 -0
- package/cjs/settings-icon-b350b587.js +1 -0
- package/cjs/settings-icon-e6a8feee.js +1 -0
- package/cjs/skin-14da56f6.js +1 -0
- package/cjs/skin-225252ff.js +1 -0
- package/cjs/skin-286f52db.js +1 -0
- package/cjs/skin-534810ae.js +1 -0
- package/cjs/skin-638aecc2.js +1 -0
- package/cjs/skin-84083352.js +1 -0
- package/cjs/skin-983a2ea7.js +1 -0
- package/cjs/skin-9eba464b.js +1 -0
- package/cjs/skin-b703ef26.js +1 -0
- package/cjs/skin-f225a42e.js +1 -0
- package/cjs/util-ce8a4138.js +1 -0
- package/cjs/videoSelector-a4c00f50.js +1 -0
- package/cjs/videoSelector-fcdf11eb.js +1 -0
- package/esm/autoNextVideo-89ede579.js +1 -0
- package/esm/bundle.css +577 -0
- package/esm/caption-settings-2e47813b.js +1 -0
- package/esm/caption-settings-3f6b6163.js +1 -0
- package/esm/dvr_skin-9cc1b144.js +1 -0
- package/esm/error-2395864b.js +1 -0
- package/esm/features-05101ce6.js +1 -0
- package/esm/generic-4a3c0d6b.js +1 -0
- package/esm/icons-f5378bf3.js +1 -0
- package/esm/index.js +1 -0
- package/esm/keyboardShortcuts-7fa108ec.js +1 -0
- package/esm/loader-580278fe.js +1 -0
- package/esm/multicam-bc0aea8a.js +1 -0
- package/esm/multicam-de741974.js +1 -0
- package/esm/multicamv2-d006cffa.js +1 -0
- package/esm/multicamv2-fb91fa98.js +1 -0
- package/esm/mwebPotrait-3c1805d8.js +1 -0
- package/esm/mwebPotraitTray-0ff12233.js +1 -0
- package/esm/nextEpisodeButton-a1556cdf.js +1 -0
- package/esm/nextEpisodeButton-ec95417f.js +1 -0
- package/esm/nondvr_skin-64be70e5.js +1 -0
- package/esm/playlist-5d3f4436.js +1 -0
- package/esm/playlist-7ecf432a.js +1 -0
- package/esm/renditions-0fdb57ed.js +1 -0
- package/esm/resolution-57e7767a.js +1 -0
- package/esm/series-041152aa.js +1 -0
- package/esm/series-998e2084.js +1 -0
- package/esm/series-v2-0727ee8c.js +1 -0
- package/esm/series-v2-9bcd5d54.js +1 -0
- package/esm/settings-icon-0125bffd.js +1 -0
- package/esm/settings-icon-9bac9ef3.js +1 -0
- package/esm/skin-0aea7a56.js +1 -0
- package/esm/skin-2c638dc1.js +1 -0
- package/esm/skin-5a02ebe6.js +1 -0
- package/esm/skin-665ec17e.js +1 -0
- package/esm/skin-80957fd8.js +1 -0
- package/esm/skin-851ea2fb.js +1 -0
- package/esm/skin-bb73c15b.js +1 -0
- package/esm/skin-cd537931.js +1 -0
- package/esm/skin-d5510f70.js +1 -0
- package/esm/skin-fba79111.js +1 -0
- package/esm/util-9c9ee6b3.js +1 -0
- package/esm/videoSelector-8da87dd3.js +1 -0
- package/esm/videoSelector-8e258d45.js +1 -0
- package/package.json +15 -32
- package/.babelrc +0 -8
- package/.browserslistrc +0 -2
- package/README.md +0 -29
- package/babel.config.json +0 -8
- package/dist/38afc79c94e0bcf0.png +0 -0
- package/dist/3bc8b7ff04e98d37.png +0 -0
- package/dist/522ea7c76ac4fd33.png +0 -0
- package/dist/a74cd46ed4277568.png +0 -0
- package/dist/b739faec1fde1346.png +0 -0
- package/dist/ed3d0a4d9de91460.png +0 -0
- package/dist/index.cjs.css +0 -2
- package/dist/index.cjs.css.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.d.ts +0 -45
- package/dist/index.esm.css +0 -2
- package/dist/index.esm.css.map +0 -1
- package/dist/index.esm.js +0 -2
- package/dist/main-player/player-ui.d.ts +0 -19
- package/dist/player-components/player-buttons/playerButtons.d.ts +0 -38
- package/dist/player-components/player-seekbar/playerSeekbar.d.ts +0 -25
- package/dist/player-ui/player-ui.d.ts +0 -18
- package/dist/playerInitializer.d.ts +0 -13
- package/index.html +0 -49
- package/rollup.config.mjs +0 -45
- package/src/ads-manager/ads-manager.js +0 -120
- package/src/assets/checkIcon.png +0 -0
- package/src/assets/pauseIcon.png +0 -0
- package/src/assets/pauseIconFocus.png +0 -0
- package/src/assets/playIcon.png +0 -0
- package/src/assets/playIconFocus.png +0 -0
- package/src/assets/settingsIcon.png +0 -0
- package/src/index.ts +0 -242
- package/src/player-components/player-buttons/playerButtons.js +0 -104
- package/src/player-components/player-seekbar/playerSeekbar.js +0 -223
- package/src/player-components/player-setting-option-wrapper/player-setting-option-one-wrapper.js +0 -82
- package/src/player-components/player-setting-option-wrapper/player-setting-option-two-wrapper.js +0 -84
- package/src/player-components/player-sidebar/player-sidebar.js +0 -188
- package/src/player-components/player-title/playerTitle.js +0 -55
- package/src/player-ui/player-ui.js +0 -514
- package/src/playerInitializer.js +0 -335
- package/src/styles/index.css +0 -200
- package/src/utilities/utilities.js +0 -79
- package/tsconfig.json +0 -14
|
@@ -1,514 +0,0 @@
|
|
|
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;
|