@viewlift/player-backup 1.0.3 → 1.0.4-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.
- package/.babelrc +8 -0
- package/README.md +29 -0
- package/babel.config.json +8 -0
- 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/bundle.css +2 -0
- package/dist/bundle.css.map +1 -0
- package/dist/bundle.js +38 -0
- package/dist/bundle.js.map +1 -0
- package/dist/ed3d0a4d9de91460.png +0 -0
- package/index.html +49 -0
- package/jsconfig.json +9 -0
- package/package.json +33 -15
- package/rollup.config.mjs +39 -0
- package/src/ads-manager/ads-manager.js +120 -0
- 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.js +13 -0
- package/src/player-components/player-buttons/playerButtons.js +106 -0
- package/src/player-components/player-seekbar/playerSeekbar.js +223 -0
- package/src/player-components/player-setting-option-wrapper/player-setting-option-one-wrapper.js +82 -0
- package/src/player-components/player-setting-option-wrapper/player-setting-option-two-wrapper.js +84 -0
- package/src/player-components/player-sidebar/player-sidebar.js +188 -0
- package/src/player-components/player-title/playerTitle.js +56 -0
- package/src/player-ui/player-ui.js +564 -0
- package/src/playerControls/playerControls.css +10 -0
- package/src/playerControls/playerControls.js +501 -0
- package/src/styles/index.css +204 -0
- package/src/utilities/utilities.js +79 -0
- package/cjs/autoNextVideo-823821e8.js +0 -1
- package/cjs/bundle.css +0 -657
- package/cjs/caption-settings-67212c17.js +0 -1
- package/cjs/caption-settings-d42c056e.js +0 -1
- package/cjs/debugSelection-cbfdabb7.js +0 -1
- package/cjs/dvr_skin-f7f770ae.js +0 -1
- package/cjs/error-26d5a3c3.js +0 -1
- package/cjs/features-164c3cc6.js +0 -1
- package/cjs/generic-8b99b151.js +0 -1
- package/cjs/icons-7afb9c13.js +0 -1
- package/cjs/index-3dfe6459.js +0 -1
- package/cjs/index.js +0 -1
- package/cjs/keyboardShortcuts-cfd998c2.js +0 -1
- package/cjs/loader-393b838a.js +0 -1
- package/cjs/multicam-21c9a90b.js +0 -1
- package/cjs/multicam-a41fe4a6.js +0 -1
- package/cjs/multicamv2-76d8530b.js +0 -1
- package/cjs/multicamv2-c148fa24.js +0 -1
- package/cjs/mwebPotrait-3c11d7cf.js +0 -1
- package/cjs/mwebPotraitTray-b9d5d45a.js +0 -1
- package/cjs/nextEpisodeButton-300afadc.js +0 -1
- package/cjs/nextEpisodeButton-b6e6586f.js +0 -1
- package/cjs/nondvr_skin-ef2cb3b2.js +0 -1
- package/cjs/playlist-925f808b.js +0 -1
- package/cjs/playlist-df87ca90.js +0 -1
- package/cjs/renditions-bc841552.js +0 -1
- package/cjs/resolution-6a9adf54.js +0 -1
- package/cjs/series-82ec79d3.js +0 -1
- package/cjs/series-9c237975.js +0 -1
- package/cjs/series-v2-24855152.js +0 -1
- package/cjs/series-v2-70137d8c.js +0 -1
- package/cjs/settings-icon-a63f46fc.js +0 -1
- package/cjs/settings-icon-e6a8feee.js +0 -1
- package/cjs/skin-095cc078.js +0 -1
- package/cjs/skin-225252ff.js +0 -1
- package/cjs/skin-39ab30e2.js +0 -1
- package/cjs/skin-84083352.js +0 -1
- package/cjs/skin-93a3e5ae.js +0 -1
- package/cjs/skin-983a2ea7.js +0 -1
- package/cjs/skin-afbec6d7.js +0 -1
- package/cjs/skin-ec49b877.js +0 -1
- package/cjs/skin-f225a42e.js +0 -1
- package/cjs/skin-fb394911.js +0 -1
- package/cjs/util-fa21734a.js +0 -1
- package/cjs/videoSelector-01a9ef43.js +0 -1
- package/cjs/videoSelector-fcdf11eb.js +0 -1
- package/esm/autoNextVideo-1672740e.js +0 -1
- package/esm/bundle.css +0 -657
- package/esm/caption-settings-2e47813b.js +0 -1
- package/esm/caption-settings-3eacf3a0.js +0 -1
- package/esm/debugSelection-2601b8b3.js +0 -1
- package/esm/dvr_skin-9cc1b144.js +0 -1
- package/esm/error-2395864b.js +0 -1
- package/esm/features-f86404ce.js +0 -1
- package/esm/generic-7c43020f.js +0 -1
- package/esm/icons-c18c70b7.js +0 -1
- package/esm/index-9f022e82.js +0 -1
- package/esm/index.js +0 -1
- package/esm/keyboardShortcuts-c06f3c7b.js +0 -1
- package/esm/loader-580278fe.js +0 -1
- package/esm/multicam-94da3759.js +0 -1
- package/esm/multicam-de741974.js +0 -1
- package/esm/multicamv2-0105c40f.js +0 -1
- package/esm/multicamv2-d006cffa.js +0 -1
- package/esm/mwebPotrait-3c1805d8.js +0 -1
- package/esm/mwebPotraitTray-5ab39989.js +0 -1
- package/esm/nextEpisodeButton-2ea69b56.js +0 -1
- package/esm/nextEpisodeButton-a1556cdf.js +0 -1
- package/esm/nondvr_skin-64be70e5.js +0 -1
- package/esm/playlist-032fbbf3.js +0 -1
- package/esm/playlist-7ecf432a.js +0 -1
- package/esm/renditions-97276745.js +0 -1
- package/esm/resolution-38cd4f5c.js +0 -1
- package/esm/series-041152aa.js +0 -1
- package/esm/series-977edced.js +0 -1
- package/esm/series-v2-0727ee8c.js +0 -1
- package/esm/series-v2-516c91c2.js +0 -1
- package/esm/settings-icon-0125bffd.js +0 -1
- package/esm/settings-icon-2b713fbf.js +0 -1
- package/esm/skin-2c638dc1.js +0 -1
- package/esm/skin-42c2f81d.js +0 -1
- package/esm/skin-5e2fa9d4.js +0 -1
- package/esm/skin-6093bfb3.js +0 -1
- package/esm/skin-60a41d44.js +0 -1
- package/esm/skin-665ec17e.js +0 -1
- package/esm/skin-93e320fc.js +0 -1
- package/esm/skin-b939c35e.js +0 -1
- package/esm/skin-cd537931.js +0 -1
- package/esm/skin-d5510f70.js +0 -1
- package/esm/util-d9f5a7be.js +0 -1
- package/esm/videoSelector-8889c58e.js +0 -1
- 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;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/*************** playerSeekbar.css ***************/
|
|
2
|
+
body {
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
background-color: #000;
|
|
7
|
+
}
|
|
8
|
+
.vl-player-container .seekbar-container {
|
|
9
|
+
position: absolute;
|
|
10
|
+
left: 50%;
|
|
11
|
+
transform: translateX(-50%);
|
|
12
|
+
bottom: 50px;
|
|
13
|
+
height: 12px;
|
|
14
|
+
background: #444;
|
|
15
|
+
width: 90%;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
border-radius: 6px;
|
|
18
|
+
margin: 0;
|
|
19
|
+
user-select: none;
|
|
20
|
+
z-index: 20;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.vl-player-container .seekbar-buffer {
|
|
24
|
+
position: absolute;
|
|
25
|
+
height: 100%;
|
|
26
|
+
background: #888;
|
|
27
|
+
width: 0;
|
|
28
|
+
border-radius: 6px;
|
|
29
|
+
z-index: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.vl-player-container .seekbar-progress {
|
|
33
|
+
position: absolute;
|
|
34
|
+
height: 100%;
|
|
35
|
+
background: rgba(254, 253, 255, 0.7);
|
|
36
|
+
width: 0;
|
|
37
|
+
border-radius: 6px;
|
|
38
|
+
z-index: 2;
|
|
39
|
+
transition: width 0.1s linear;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.vl-player-container .seekbar-thumb {
|
|
43
|
+
position: absolute;
|
|
44
|
+
top: 50%;
|
|
45
|
+
transform: translate(-50%, -50%);
|
|
46
|
+
width: 16px;
|
|
47
|
+
height: 16px;
|
|
48
|
+
background: #fff;
|
|
49
|
+
border-radius: 50%;
|
|
50
|
+
/* border: 2px solid #4169E1; */
|
|
51
|
+
z-index: 3;
|
|
52
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
transition: background 0.2s;
|
|
55
|
+
}
|
|
56
|
+
.vl-player-container .seekbar-thumb:hover {
|
|
57
|
+
background: #ffeaea;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.vl-player-container .seekbar-tooltip {
|
|
61
|
+
position: absolute;
|
|
62
|
+
bottom: 24px;
|
|
63
|
+
left: 0;
|
|
64
|
+
transform: translateX(-50%);
|
|
65
|
+
background: #222;
|
|
66
|
+
color: #fff;
|
|
67
|
+
padding: 2px 8px;
|
|
68
|
+
border-radius: 4px;
|
|
69
|
+
font-size: 12px;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
z-index: 10;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.vl-player-container .seekbar-time-label, .vl-player-container .seekbar-duration-label {
|
|
76
|
+
position: relative;
|
|
77
|
+
top: 18px;
|
|
78
|
+
font-size: 13px;
|
|
79
|
+
color: #eee;
|
|
80
|
+
margin-right: 4px;
|
|
81
|
+
z-index: 5;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/*************** playerButtons.css ***************/
|
|
88
|
+
|
|
89
|
+
.vl-player-container .play-pause-btn {
|
|
90
|
+
position: absolute !important;
|
|
91
|
+
left: 50%;
|
|
92
|
+
top: 50%;
|
|
93
|
+
transform: translate(-50%, -50%);
|
|
94
|
+
z-index: 20;
|
|
95
|
+
width: 70px;
|
|
96
|
+
height: 70px;
|
|
97
|
+
border-radius: 50%;
|
|
98
|
+
background: rgba(255,255,255, .5);
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.vl-player-container .play-pause-btn img {
|
|
103
|
+
position: absolute !important;
|
|
104
|
+
left: 50%;
|
|
105
|
+
top: 50%;
|
|
106
|
+
transform: translate(-50%, -50%);
|
|
107
|
+
height: 50px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
.vl-player-container .left-side-container {
|
|
112
|
+
position: absolute !important;
|
|
113
|
+
display: flex;
|
|
114
|
+
left: 5%;
|
|
115
|
+
bottom: 77px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.vl-player-container .right-side-container {
|
|
119
|
+
position: absolute !important;
|
|
120
|
+
display: flex;
|
|
121
|
+
right: 5%;
|
|
122
|
+
bottom: 77px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.vl-player-container .settings-btn {
|
|
126
|
+
border-radius: 5px;
|
|
127
|
+
padding: 5px;
|
|
128
|
+
bottom: 100px;
|
|
129
|
+
width: 50px;
|
|
130
|
+
height: 40px;
|
|
131
|
+
margin: 0 5px;
|
|
132
|
+
background: rgba(255,255,255, 0.5);
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
z-index: 20;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.vl-player-container .settings-btn img{
|
|
138
|
+
height: 100%;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.vl-player-container .restart-btn {
|
|
142
|
+
right: 2%;
|
|
143
|
+
border-radius: 8px;
|
|
144
|
+
padding: 5px;
|
|
145
|
+
bottom: 100px;
|
|
146
|
+
border: 2px solid #fff;
|
|
147
|
+
color: #fff;
|
|
148
|
+
font-size: 20px;
|
|
149
|
+
font-weight: 700;
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-direction: column;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
margin: 0 5px;
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
z-index: 20;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
/*************** player-setting-option-wrapper ***************/
|
|
160
|
+
.vl-player-container .default-option-wrapper {
|
|
161
|
+
display: flex;
|
|
162
|
+
justify-content: space-between;
|
|
163
|
+
align-items: center;
|
|
164
|
+
width: 95%;
|
|
165
|
+
height: 50px;
|
|
166
|
+
background: #525760;
|
|
167
|
+
color: #fff;
|
|
168
|
+
padding: 5px 10px;
|
|
169
|
+
font-weight: 700;
|
|
170
|
+
font-size: 18px;
|
|
171
|
+
border-radius: 2px;
|
|
172
|
+
box-shadow: 0 10px 15px rgba(0, 0, 0, .1);
|
|
173
|
+
margin: 20px 0px;
|
|
174
|
+
text-transform: capitalize;
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
}
|
|
177
|
+
.vl-player-container .default-option-wrapper span {
|
|
178
|
+
height: 40px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.vl-player-container .default-option-wrapper span > img{
|
|
182
|
+
height: 100%;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
.vl-player-container .default-sidebar {
|
|
187
|
+
position: absolute;
|
|
188
|
+
top: 0;
|
|
189
|
+
color: #fff;
|
|
190
|
+
display: flex;
|
|
191
|
+
flex-direction: column;
|
|
192
|
+
background-color: rgba(30, 30, 30, .75);
|
|
193
|
+
height: 100%;
|
|
194
|
+
min-height: 720px;
|
|
195
|
+
width: 400px;
|
|
196
|
+
padding: 50px 20px 0 20px;
|
|
197
|
+
right: 0px;
|
|
198
|
+
z-index: 30;
|
|
199
|
+
/* right: -450px; */
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.vl-player-container .focused{
|
|
203
|
+
outline: 2px solid #ffffff;
|
|
204
|
+
}
|