forked from ssl-core/ssl-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
player-mfe.ts
60 lines (50 loc) · 1.51 KB
/
player-mfe.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import SocketHandler from "../lib/socket/socket-handler";
import Playback from "../entities/playback";
import { provide } from "./services/global-provider";
import { html } from "../utils/literals";
import styles from "./styles/main.css?inline";
import "./components/player-mfe-slider";
import "./components/player-mfe-controls";
import "./components/player-mfe-info";
import "./components/player-mfe-actions";
class PlayerMFE extends HTMLElement {
private root: ShadowRoot;
private socketHandler: SocketHandler;
private playback: Playback;
constructor() {
super();
this.root = this.attachShadow({ mode: "open" });
this.socketHandler = new SocketHandler("http://127.0.0.1:4040/ws");
this.playback = new Playback(this.socketHandler);
}
public async connectedCallback() {
this.provideDependencies();
this.render();
this.listenToEvents();
}
public disconnectedCallback() {
this.socketHandler.disconnect();
}
public render() {
this.root.innerHTML = html`
<div class="container">
<player-mfe-slider></player-mfe-slider>
<div class="container__controls">
<player-mfe-info></player-mfe-info>
<player-mfe-controls></player-mfe-controls>
<player-mfe-actions></player-mfe-actions>
</div>
</div>
<style>
${styles}
</style>
`;
}
private listenToEvents() {
this.socketHandler.connect();
}
private provideDependencies() {
provide("playback", this.playback);
}
}
export default PlayerMFE;