MCPcopy
hub / github.com/midrender/revideo / MotionCanvasPlayer

Class MotionCanvasPlayer

packages/player/src/main.ts:18–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18class MotionCanvasPlayer extends HTMLElement {
19 public static get observedAttributes() {
20 return ['src', 'quality', 'width', 'height', 'auto', 'variables'];
21 }
22
23 private get auto() {
24 const attr = this.getAttribute('auto');
25 return !!attr;
26 }
27
28 private get hover() {
29 return this.getAttribute('auto') === 'hover';
30 }
31
32 private get quality() {
33 const attr = this.getAttribute('quality');
34 return attr ? parseFloat(attr) : this.defaultSettings.resolutionScale;
35 }
36
37 private get width() {
38 const attr = this.getAttribute('width');
39 return attr ? parseFloat(attr) : this.defaultSettings.size.width;
40 }
41
42 private get height() {
43 const attr = this.getAttribute('height');
44 return attr ? parseFloat(attr) : this.defaultSettings.size.height;
45 }
46
47 private get variables() {
48 try {
49 const attr = this.getAttribute('variables');
50 return attr ? JSON.parse(attr) : {};
51 } catch {
52 this.project.logger.warn(`Project variables could not be parsed.`);
53 return {};
54 }
55 }
56
57 private readonly root: ShadowRoot;
58 private readonly canvas: HTMLCanvasElement;
59 private readonly overlay: HTMLCanvasElement;
60 private readonly button: HTMLDivElement;
61
62 private state = State.Initial;
63 private project: Project | null = null;
64 private player: Player | null = null;
65 private defaultSettings:
66 | ReturnType<typeof getFullPreviewSettings>
67 | undefined;
68 private abortController: AbortController | null = null;
69 private mouseMoveId: number | null = null;
70 private finished = false;
71 private playing = false;
72 private connected = false;
73 private stage = new Stage();
74 private timeline: HTMLInputElement;
75

Callers

nothing calls this directly

Calls 8

setPlayingMethod · 0.95
updateClassMethod · 0.95
formatTimeMethod · 0.95
requestSeekMethod · 0.80
framesToSecondsMethod · 0.80
secondsToFramesMethod · 0.80
renderMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected