From b0f15acc783f8eb54ddfefe58a6704f78f6e85dd Mon Sep 17 00:00:00 2001 From: Michael Chung <6252325+ArEnSc@users.noreply.github.com> Date: Thu, 5 Sep 2024 00:40:30 -0400 Subject: [PATCH] Ok streaming video previews work. --- src/KonvaApp/Engine.ts | 1 - src/KonvaApp/Nodes/VideoNode.ts | 31 ++++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/KonvaApp/Engine.ts b/src/KonvaApp/Engine.ts index 3eb7ad95d3..4157b6b6ed 100644 --- a/src/KonvaApp/Engine.ts +++ b/src/KonvaApp/Engine.ts @@ -67,7 +67,6 @@ export class Engine { ); } }, this.videoLayer); - anim.start(); // Adding nodes here diff --git a/src/KonvaApp/Nodes/VideoNode.ts b/src/KonvaApp/Nodes/VideoNode.ts index 2edd614e0f..a6081cd70a 100644 --- a/src/KonvaApp/Nodes/VideoNode.ts +++ b/src/KonvaApp/Nodes/VideoNode.ts @@ -152,17 +152,10 @@ export class VideoNode extends NetworkedNodeContext { } else { loadingBar.hide(); } - console.log(`${this.didFinishLoading} ${this.shouldPlay}`); - if (this.didFinishLoading && this.shouldPlay === true) { - console.log("Playing"); - this.shouldPlay = false; - this.videoComponent.play(); - } else { - this.shouldPlay = true; - this.videoComponent.pause(); + }); - console.log("Pausing"); - } + this.node.on("mouseup", () => { + this.play(); }); } @@ -215,6 +208,7 @@ export class VideoNode extends NetworkedNodeContext { this.node.image(videoComponent); this.node.draw(); + this.videoComponent.loop = true; this.videoComponent.currentTime = 0; // ensure it shows up on screen console.log("Can Play"); @@ -225,10 +219,12 @@ export class VideoNode extends NetworkedNodeContext { // remove loading ui loadingBar.updateProgress(100); loadingBar.hide(); + + this.videoComponent.play(); }; videoComponent.onseeked = (event: Event) => { - console.log("Seeked"); + //console.log("Seeked"); // reimplement using the function }; @@ -237,12 +233,25 @@ export class VideoNode extends NetworkedNodeContext { } // odd reasoning you have to refresh to prevent multiple instances of things being created. causing laggyness // Loading animation when having a sequence of images. + play() { + console.log(`${this.didFinishLoading} ${this.shouldPlay}`); + if (this.didFinishLoading && this.shouldPlay === true) { + console.log("Playing"); + this.shouldPlay = false; + this.videoComponent.play(); + } else { + this.shouldPlay = true; + this.videoComponent.pause(); + console.log("Pausing"); + } + } async simulatedLoading() { // need to block playing while loading this.didFinishLoading = false; console.log(this.imageIndex); + if (this.imageIndex == 0) { loadingBar.show(); }