@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
package/index.html
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>HLS Player Test</title>
|
|
5
|
-
<link rel="stylesheet" href="./src/styles/index.css">
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<div id="player-container"></div>
|
|
9
|
-
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
|
10
|
-
<script type="module">
|
|
11
|
-
import { createHlsPlayer } from './src/playerInitializer.js';
|
|
12
|
-
const mountPoint = document.getElementById('player-container');
|
|
13
|
-
const config = {
|
|
14
|
-
// streamUrl: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
|
|
15
|
-
streamUrl: "https://cdn-vl-gcp-spinco-e-token-no-ssai-01.vos360.video/Content/HLS_HLS_CLEAR/Live/channel(886a397d-ff30-4021-eb16-bb73c658c033)/index.m3u8?hdnts=st=1753800508~exp=1753843708~acl=/Content/HLS_HLS_CLEAR/Live/channel(886a397d-ff30-4021-eb16-bb73c658c033)/*~hmac=461d4f615e40b0057f82b07d54f40bc029c4562ae65ef9d7caf85dd86f2e3270",
|
|
16
|
-
// streamUrl: 'https://cdn.bitmovin.com/content/assets/sintel/hls/playlist.m3u8',
|
|
17
|
-
videoTitleConfig: {
|
|
18
|
-
text: 'Big Buck Bunny',
|
|
19
|
-
fontSize: '40px',
|
|
20
|
-
fontWeight: 'bold',
|
|
21
|
-
textAlign: 'left',
|
|
22
|
-
textDecoration: 'none',
|
|
23
|
-
textTransform: 'none',
|
|
24
|
-
lineHeight: 'normal',
|
|
25
|
-
letterSpacing: 'normal',
|
|
26
|
-
color: '#ffffff',
|
|
27
|
-
backgroundColor: 'transparent'
|
|
28
|
-
},
|
|
29
|
-
startFromBeginningBtnConfig: {
|
|
30
|
-
text: 'Start From Beginning',
|
|
31
|
-
enabled: true,
|
|
32
|
-
width: '150px',
|
|
33
|
-
height: '35px',
|
|
34
|
-
fontSize: '16px',
|
|
35
|
-
fontWeight: 'normal',
|
|
36
|
-
textAlign: 'center',
|
|
37
|
-
textDecoration: 'none',
|
|
38
|
-
textTransform: 'none',
|
|
39
|
-
lineHeight: 'normal',
|
|
40
|
-
letterSpacing: 'normal',
|
|
41
|
-
color: '#ffffff',
|
|
42
|
-
backgroundColor: '#000000',
|
|
43
|
-
focused: false,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
createHlsPlayer(mountPoint, config);
|
|
47
|
-
</script>
|
|
48
|
-
</body>
|
|
49
|
-
</html>
|
package/rollup.config.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
-
import terser from '@rollup/plugin-terser';
|
|
4
|
-
import typescript from '@rollup/plugin-typescript';
|
|
5
|
-
import babel from '@rollup/plugin-babel';
|
|
6
|
-
import postcss from 'rollup-plugin-postcss';
|
|
7
|
-
import url from '@rollup/plugin-url';
|
|
8
|
-
|
|
9
|
-
const devMode = 'development';
|
|
10
|
-
export default {
|
|
11
|
-
input: 'src/playerInitializer.js',
|
|
12
|
-
output: [
|
|
13
|
-
{
|
|
14
|
-
file: 'dist/index.cjs.js',
|
|
15
|
-
format: 'cjs',
|
|
16
|
-
exports: 'auto',
|
|
17
|
-
sourcemap: devMode ? 'inline' : false
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
file: 'dist/index.esm.js',
|
|
21
|
-
format: 'esm',
|
|
22
|
-
sourcemap: devMode ? 'inline' : false
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
plugins: [
|
|
26
|
-
resolve(),
|
|
27
|
-
commonjs(),
|
|
28
|
-
typescript({ tsconfig: './tsconfig.json' }),
|
|
29
|
-
babel({
|
|
30
|
-
babelHelpers: 'bundled',
|
|
31
|
-
extensions: ['.js', '.ts'],
|
|
32
|
-
exclude: 'node_modules/**',
|
|
33
|
-
}),
|
|
34
|
-
postcss({
|
|
35
|
-
extract: true, // creates a separate CSS file
|
|
36
|
-
minimize: true,
|
|
37
|
-
sourceMap: true,
|
|
38
|
-
}),
|
|
39
|
-
url({
|
|
40
|
-
include: ['**/*.png', '**/*.jpg', '**/*.gif'],
|
|
41
|
-
limit: 0, // Always copy the files
|
|
42
|
-
}),
|
|
43
|
-
terser(),
|
|
44
|
-
],
|
|
45
|
-
};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Button } from "../player-components/player-buttons/playerButtons";
|
|
2
|
-
|
|
3
|
-
export class AdsManager {
|
|
4
|
-
constructor(props) {
|
|
5
|
-
this.adsMediaPlaybackList = props.adsMediaPlaybackList;
|
|
6
|
-
this.isSkipAble = props.isSkipAble;
|
|
7
|
-
this.playerResumeCallback = props.playerResumeCallback;
|
|
8
|
-
this.adsPlayerId = props.adsPlayerId;
|
|
9
|
-
|
|
10
|
-
this.initializeAdsPlayer();
|
|
11
|
-
this.addAdsEventListener();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
initializeAdsPlayer() {
|
|
15
|
-
this.adsContainer = document.createElement("div");
|
|
16
|
-
this.adsContainer.className = "adsContainer";
|
|
17
|
-
this.video = document.createElement('video');
|
|
18
|
-
this.adsContainer.appendChild(this.video);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
addAdsEventListener() {
|
|
22
|
-
this.video.addEventListener("ended", onEnded);
|
|
23
|
-
this.video.addEventListener("error", onError);
|
|
24
|
-
this.video.addEventListener("waiting", onBuffering);
|
|
25
|
-
this.video.addEventListener("play", onPlay);
|
|
26
|
-
this.video.addEventListener("playing", onPlaying);
|
|
27
|
-
this.video.addEventListener("timeupdate", playbackprogress);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
removeAdsEventListener() {
|
|
31
|
-
this.video.removeEventListener("ended", onEnded);
|
|
32
|
-
this.video.removeEventListener("error", onError);
|
|
33
|
-
this.video.removeEventListener("waiting", onBuffering);
|
|
34
|
-
this.video.removeEventListener("play", onPlay);
|
|
35
|
-
this.video.removeEventListener("playing", onPlaying);
|
|
36
|
-
this.video.removeEventListener("timeupdate", playbackprogress);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
onEnded() {
|
|
40
|
-
console.log("AdsManager: ended");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
onError() {
|
|
44
|
-
console.log("AdsManager: error");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
onBuffering() {
|
|
48
|
-
console.log("AdsManager: buffering");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
onPlay() {
|
|
52
|
-
console.log("AdsManager: play");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
onPlaying() {
|
|
56
|
-
console.log("AdsManager: playing");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
playbackprogress() {
|
|
60
|
-
console.log("AdsManager: playback progress");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
createPlayPauseBtn() {
|
|
65
|
-
this.playPauseBtn = new Button({
|
|
66
|
-
imgSrc: playIconFocus,
|
|
67
|
-
imgAltText: 'Play/Pause',
|
|
68
|
-
buttonText: 'Play',
|
|
69
|
-
width: 70,
|
|
70
|
-
height: 70,
|
|
71
|
-
klassname: 'play-pause-btn',
|
|
72
|
-
focused: false,
|
|
73
|
-
disabled: false,
|
|
74
|
-
handleClick: () => {
|
|
75
|
-
if (this.video.paused) {
|
|
76
|
-
this.video.play();
|
|
77
|
-
if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
|
|
78
|
-
this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', pauseIconFocus);
|
|
79
|
-
} else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
|
|
80
|
-
this.playPauseBtn.buttonElement.textContent = 'Pause';
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
this.video.pause();
|
|
84
|
-
if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
|
|
85
|
-
this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', playIconFocus);
|
|
86
|
-
} else if (this.playPauseBtn && this.playPauseBtn.buttonElement) {
|
|
87
|
-
this.playPauseBtn.buttonElement.textContent = 'Play';
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
this.playPauseBtn.mount(this.adsContainer);
|
|
93
|
-
|
|
94
|
-
requestAnimationFrame(() => {
|
|
95
|
-
if (this.playPauseBtn) this.playPauseBtn.focus();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
this.playPauseBtnEventListeners();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
playPauseBtnEventListeners() {
|
|
102
|
-
if (!this.playPauseBtn || !this.playPauseBtn.buttonElement) return;
|
|
103
|
-
|
|
104
|
-
this.playPauseBtn.buttonElement.addEventListener('focus', () => {
|
|
105
|
-
if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
|
|
106
|
-
const iconSrc = this.video.paused ? playIconFocus : pauseIconFocus;
|
|
107
|
-
this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
|
|
108
|
-
this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255)';
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
this.playPauseBtn.buttonElement.addEventListener('blur', () => {
|
|
113
|
-
if (this.playPauseBtn && this.playPauseBtn.buttonElement && this.playPauseBtn.buttonElement.querySelector('img')) {
|
|
114
|
-
const iconSrc = this.video.paused ? playIcon : pauseIcon;
|
|
115
|
-
this.playPauseBtn.buttonElement.querySelector('img').setAttribute('src', iconSrc);
|
|
116
|
-
this.playPauseBtn.buttonElement.style.backgroundColor = 'rgba(255, 255, 255, 0.5)';
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
package/src/assets/checkIcon.png
DELETED
|
Binary file
|
package/src/assets/pauseIcon.png
DELETED
|
Binary file
|
|
Binary file
|
package/src/assets/playIcon.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/index.ts
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
// LightningJS-compatible Video Player Component (ES5 compatible)
|
|
2
|
-
|
|
3
|
-
export interface VideoPlayerOptions {
|
|
4
|
-
// Optional playback callbacks
|
|
5
|
-
onPlaybackSuccess?: () => void;
|
|
6
|
-
onPlaybackEnded?: () => void;
|
|
7
|
-
onPlaybackError?: (error?: any) => void;
|
|
8
|
-
src: string;
|
|
9
|
-
autoplay?: boolean;
|
|
10
|
-
controls?: boolean;
|
|
11
|
-
width?: number;
|
|
12
|
-
height?: number;
|
|
13
|
-
// Event callbacks
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type EventHandler = (...args: any[]) => void;
|
|
17
|
-
|
|
18
|
-
type VideoPlayerEvent =
|
|
19
|
-
| 'play'
|
|
20
|
-
| 'pause'
|
|
21
|
-
| 'ended'
|
|
22
|
-
| 'timeupdate'
|
|
23
|
-
| 'error'
|
|
24
|
-
| 'loadedmetadata'
|
|
25
|
-
| 'seeking'
|
|
26
|
-
| 'seeked'
|
|
27
|
-
| 'volumechange';
|
|
28
|
-
|
|
29
|
-
export class LightningVideoPlayer {
|
|
30
|
-
/**
|
|
31
|
-
* Reinitialize the current videoElement with a new set of options and handle autoplay.
|
|
32
|
-
*/
|
|
33
|
-
reinitialize(options: VideoPlayerOptions) {
|
|
34
|
-
this.options = options;
|
|
35
|
-
this.videoElement.src = options.src;
|
|
36
|
-
this.videoElement.autoplay = !!options.autoplay;
|
|
37
|
-
this.videoElement.controls = !!options.controls;
|
|
38
|
-
if (options.width) {
|
|
39
|
-
this.videoElement.width = options.width;
|
|
40
|
-
} else {
|
|
41
|
-
this.videoElement.removeAttribute('width');
|
|
42
|
-
}
|
|
43
|
-
if (options.height) {
|
|
44
|
-
this.videoElement.height = options.height;
|
|
45
|
-
} else {
|
|
46
|
-
this.videoElement.removeAttribute('height');
|
|
47
|
-
}
|
|
48
|
-
// Reset playback state
|
|
49
|
-
this.videoElement.currentTime = 0;
|
|
50
|
-
this.videoElement.pause();
|
|
51
|
-
// If autoplay is set, start playback
|
|
52
|
-
if (options.autoplay) {
|
|
53
|
-
// Wait for metadata to be loaded before playing (for some browsers)
|
|
54
|
-
const playOnLoaded = () => {
|
|
55
|
-
this.videoElement.play();
|
|
56
|
-
this.videoElement.removeEventListener('loadedmetadata', playOnLoaded);
|
|
57
|
-
};
|
|
58
|
-
this.videoElement.addEventListener('loadedmetadata', playOnLoaded);
|
|
59
|
-
// If already loaded, play immediately
|
|
60
|
-
if (this.videoElement.readyState >= 1) {
|
|
61
|
-
this.videoElement.play();
|
|
62
|
-
this.videoElement.removeEventListener('loadedmetadata', playOnLoaded);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
private videoElement: HTMLVideoElement;
|
|
67
|
-
private options: VideoPlayerOptions;
|
|
68
|
-
private listeners: { [event: string]: EventHandler[] } = {};
|
|
69
|
-
private boundEmitters: { [event: string]: EventListener } = {};
|
|
70
|
-
private boundHandlerMap: { [K in VideoPlayerEvent]?: (e: Event) => void } = {};
|
|
71
|
-
|
|
72
|
-
constructor(options: VideoPlayerOptions) {
|
|
73
|
-
this.options = options;
|
|
74
|
-
this.videoElement = document.createElement('video');
|
|
75
|
-
this.videoElement.src = options.src;
|
|
76
|
-
this.videoElement.autoplay = !!options.autoplay;
|
|
77
|
-
this.videoElement.controls = !!options.controls;
|
|
78
|
-
if (options.width) this.videoElement.width = options.width;
|
|
79
|
-
if (options.height) this.videoElement.height = options.height;
|
|
80
|
-
this.videoElement.style.display = 'block';
|
|
81
|
-
this.videoElement.style.background = 'black';
|
|
82
|
-
|
|
83
|
-
// Attach class event handlers for all player events
|
|
84
|
-
const handlerMap: { [K in VideoPlayerEvent]: (e: Event) => void } = {
|
|
85
|
-
play: this.onPlay,
|
|
86
|
-
pause: this.onPause,
|
|
87
|
-
ended: this.onEnded,
|
|
88
|
-
timeupdate: this.onTimeupdate,
|
|
89
|
-
error: this.onError,
|
|
90
|
-
loadedmetadata: this.onLoadedmetadata,
|
|
91
|
-
seeking: this.onSeeking,
|
|
92
|
-
seeked: this.onSeeked,
|
|
93
|
-
volumechange: this.onVolumechange,
|
|
94
|
-
};
|
|
95
|
-
(Object.keys(handlerMap) as VideoPlayerEvent[]).forEach(event => {
|
|
96
|
-
const boundHandler = handlerMap[event].bind(this);
|
|
97
|
-
this.boundHandlerMap[event] = boundHandler;
|
|
98
|
-
this.videoElement.addEventListener(event, boundHandler);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
attachTo(container: HTMLElement) {
|
|
103
|
-
container.appendChild(this.videoElement);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
play() {
|
|
107
|
-
this.videoElement.play();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
pause() {
|
|
111
|
-
this.videoElement.pause();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
stop() {
|
|
115
|
-
this.videoElement.pause();
|
|
116
|
-
this.videoElement.currentTime = 0;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
destroy() {
|
|
120
|
-
if (this.videoElement.parentNode) {
|
|
121
|
-
this.videoElement.parentNode.removeChild(this.videoElement);
|
|
122
|
-
}
|
|
123
|
-
this.removeAllListeners();
|
|
124
|
-
// Remove class event handlers
|
|
125
|
-
(Object.keys(this.boundHandlerMap) as VideoPlayerEvent[]).forEach(event => {
|
|
126
|
-
if (this.boundHandlerMap[event]) {
|
|
127
|
-
this.videoElement.removeEventListener(event, this.boundHandlerMap[event]!);
|
|
128
|
-
delete this.boundHandlerMap[event];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get element(): HTMLVideoElement {
|
|
134
|
-
return this.videoElement;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Event callback function definitions
|
|
138
|
-
onPlay(e: Event) {
|
|
139
|
-
// Called when playback starts
|
|
140
|
-
if (typeof this.options.onPlaybackSuccess === 'function') {
|
|
141
|
-
this.options.onPlaybackSuccess();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
onPause(e: Event) {
|
|
146
|
-
// Called when playback is paused
|
|
147
|
-
// Override or pass as option
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
onEnded(e: Event) {
|
|
151
|
-
// Called when playback ends
|
|
152
|
-
if (typeof this.options.onPlaybackEnded === 'function') {
|
|
153
|
-
this.options.onPlaybackEnded();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
onTimeupdate(e: Event) {
|
|
158
|
-
// Called when playback position changes
|
|
159
|
-
// Override or pass as option
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
onError(e: Event) {
|
|
163
|
-
// Called on playback error
|
|
164
|
-
if (typeof this.options.onPlaybackError === 'function') {
|
|
165
|
-
this.options.onPlaybackError(e);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
onLoadedmetadata(e: Event) {
|
|
170
|
-
// Called when metadata is loaded
|
|
171
|
-
// Override or pass as option
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
onSeeking(e: Event) {
|
|
175
|
-
// Called when seeking starts
|
|
176
|
-
// Override or pass as option
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
onSeeked(e: Event) {
|
|
180
|
-
// Called when seeking ends
|
|
181
|
-
// Override or pass as option
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
onVolumechange(e: Event) {
|
|
185
|
-
// Called when volume changes
|
|
186
|
-
// Override or pass as option
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Event system
|
|
190
|
-
on(event: VideoPlayerEvent, handler: EventHandler) {
|
|
191
|
-
if (!this.listeners[event]) {
|
|
192
|
-
this.listeners[event] = [];
|
|
193
|
-
if (!this.boundEmitters[event]) {
|
|
194
|
-
this.boundEmitters[event] = this.emitEvent(event);
|
|
195
|
-
this.videoElement.addEventListener(event, this.boundEmitters[event]);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
this.listeners[event].push(handler);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
off(event: VideoPlayerEvent, handler: EventHandler) {
|
|
202
|
-
if (!this.listeners[event]) return;
|
|
203
|
-
this.listeners[event] = this.listeners[event].filter(h => h !== handler);
|
|
204
|
-
if (this.listeners[event].length === 0) {
|
|
205
|
-
if (this.boundEmitters[event]) {
|
|
206
|
-
this.videoElement.removeEventListener(event, this.boundEmitters[event]);
|
|
207
|
-
delete this.boundEmitters[event];
|
|
208
|
-
}
|
|
209
|
-
delete this.listeners[event];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
once(event: VideoPlayerEvent, handler: EventHandler) {
|
|
214
|
-
const onceHandler: EventHandler = (...args) => {
|
|
215
|
-
handler(...args);
|
|
216
|
-
this.off(event, onceHandler);
|
|
217
|
-
};
|
|
218
|
-
this.on(event, onceHandler);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
private emitEvent(event: VideoPlayerEvent) {
|
|
222
|
-
return (e: Event) => {
|
|
223
|
-
if (this.listeners[event]) {
|
|
224
|
-
this.listeners[event].forEach(handler => handler(e));
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
private removeAllListeners() {
|
|
230
|
-
(Object.keys(this.listeners) as VideoPlayerEvent[]).forEach(event => {
|
|
231
|
-
if (this.boundEmitters[event]) {
|
|
232
|
-
this.videoElement.removeEventListener(event, this.boundEmitters[event]);
|
|
233
|
-
delete this.boundEmitters[event];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
this.listeners = {};
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function getHandlerMethodName(event: string): string {
|
|
241
|
-
return 'on' + event.charAt(0).toUpperCase() + event.slice(1);
|
|
242
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
export class Button {
|
|
2
|
-
constructor(props) {
|
|
3
|
-
if (!props) {
|
|
4
|
-
throw new Error('Button Class: props are required');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
this.imgSrc = props.imgSrc || '';
|
|
8
|
-
this.imgAltText = props.imgAltText || '';
|
|
9
|
-
this.buttonText = props.buttonText || '';
|
|
10
|
-
this.klassname = props.klassname || 'default-button';
|
|
11
|
-
this.width = props.width || 100;
|
|
12
|
-
this.height = props.height || 50;
|
|
13
|
-
this.focused = props.focused || false;
|
|
14
|
-
this.disabled = props.disabled || false;
|
|
15
|
-
this.handleClick = props.handleClick || (() => {});
|
|
16
|
-
|
|
17
|
-
if (typeof this.handleClick !== 'function') {
|
|
18
|
-
throw new Error('Button Class: handleClick must be a function');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (this.disabled) {
|
|
22
|
-
this.klassname += ' disabled';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (this.focused) {
|
|
26
|
-
this.klassname += ' focused';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
this.handleClick = this.handleClick.bind(this);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
focus() {
|
|
33
|
-
if (this.buttonElement) {
|
|
34
|
-
this.buttonElement.focus();
|
|
35
|
-
this.buttonElement.classList.add('focused');
|
|
36
|
-
this.focused = true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
blur() {
|
|
41
|
-
if (this.buttonElement) {
|
|
42
|
-
this.buttonElement.blur();
|
|
43
|
-
this.buttonElement.classList.remove('focused');
|
|
44
|
-
this.focused = false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
mount(mountPoint) {
|
|
49
|
-
if (!mountPoint || !(mountPoint instanceof HTMLElement)) {
|
|
50
|
-
throw new Error('Button Class: mountPoint must be a valid DOM element');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const button = document.createElement('div');
|
|
54
|
-
button.className = this.klassname;
|
|
55
|
-
button.style.width = `${this.width}px`;
|
|
56
|
-
button.style.height = `${this.height}px`;
|
|
57
|
-
button.tabIndex = 0;
|
|
58
|
-
|
|
59
|
-
if (this.imgSrc) {
|
|
60
|
-
const img = document.createElement('img');
|
|
61
|
-
img.src = this.imgSrc;
|
|
62
|
-
img.alt = this.imgAltText;
|
|
63
|
-
img.onerror = () => {
|
|
64
|
-
console.warn('Button Class: Failed to load image at', this.imgSrc);
|
|
65
|
-
};
|
|
66
|
-
button.appendChild(img);
|
|
67
|
-
} else {
|
|
68
|
-
const span = document.createElement('span');
|
|
69
|
-
span.textContent = this.buttonText;
|
|
70
|
-
button.appendChild(span);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!this.disabled) {
|
|
74
|
-
button.addEventListener('click', this.handleClick);
|
|
75
|
-
}
|
|
76
|
-
button.addEventListener('keydown', (event) => {
|
|
77
|
-
if (event.key === 'Enter' || event.key === 'OK') {
|
|
78
|
-
this.handleClick();
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
button.addEventListener('focus', () => {
|
|
82
|
-
this.focused = true;
|
|
83
|
-
button.classList.add('focused');
|
|
84
|
-
});
|
|
85
|
-
button.addEventListener('blur', () => {
|
|
86
|
-
this.focused = false;
|
|
87
|
-
button.classList.remove('focused');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this.buttonElement = button;
|
|
91
|
-
mountPoint.appendChild(button);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
unmount() {
|
|
95
|
-
if (this.buttonElement) {
|
|
96
|
-
this.buttonElement.removeEventListener('click', this.handleClick);
|
|
97
|
-
this.buttonElement.removeEventListener('keydown', this.handleClick);
|
|
98
|
-
this.buttonElement.removeEventListener('focus', this.handleClick);
|
|
99
|
-
this.buttonElement.removeEventListener('blur', this.handleClick);
|
|
100
|
-
this.buttonElement.remove();
|
|
101
|
-
this.buttonElement = undefined;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|