Initial move

This commit is contained in:
2024-09-03 14:50:33 +02:00
parent adb6be0006
commit 9fa656ed5e
138 changed files with 13117 additions and 0 deletions

61
frontend/src/ui/video.ts Normal file
View File

@@ -0,0 +1,61 @@
import { UINode } from "./node";
export class Video extends UINode {
private videoElement: HTMLVideoElement;
public constructor(title: string, src: string | MediaStream = "") {
super(title);
this.videoElement = document.createElement("video");
if (typeof src === "string") {
this.videoElement.src = src; // Set src if it's a string URL
} else if (src instanceof MediaStream) {
this.videoElement.srcObject = src; // Set srcObject if it's a MediaStream
}
this.videoElement.setAttribute("aria-label", title);
this.element.appendChild(this.videoElement);
this.setRole("video");
}
public getElement(): HTMLElement {
return this.videoElement;
}
public setSource(src: string | MediaStream) {
if (typeof src === "string") {
this.videoElement.src = src;
} else if (src instanceof MediaStream) {
this.videoElement.srcObject = src;
}
return this;
}
public play() {
this.videoElement.play();
return this;
}
public pause() {
this.videoElement.pause();
return this;
}
public setControls(show: boolean) {
this.videoElement.controls = show;
return this;
}
public setLoop(loop: boolean) {
this.videoElement.loop = loop;
return this;
}
public setMuted(muted: boolean) {
this.videoElement.muted = muted;
return this;
}
public setAutoplay(autoplay: boolean) {
this.videoElement.autoplay = autoplay;
return this;
}
}