Skip to content

Commit

Permalink
Maybe fixes stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Dec 10, 2024
1 parent 909dd5b commit 22edd4d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/StatefulVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class StatefulVideo {
this.flags = new Flags(this.document);
this.offset = this.flags.offset;
this.texture = texture;
this.video = this.texture.baseTexture.resource.source;
this.video = this.texture?.baseTexture?.resource?.source;
this.timeout = null;
this.still = false;
this.playing = false;
Expand All @@ -31,6 +31,9 @@ export class StatefulVideo {
this.newCurrentTime = null;
this.randomTimers = {};
this.ready = !!currentDelegator;
if (!this.video) {
this.waitUntilReady();
}
}

static setAllReady() {
Expand Down Expand Up @@ -200,6 +203,10 @@ export class StatefulVideo {
}

static createPlaceable(placeableDoc) {
const hasFlags = foundry.utils.getProperty(placeableDoc, CONSTANTS.STATES_FLAG)?.length;
if (hasFlags) {
return StatefulVideo.make(placeableDoc, placeableDoc.object.texture)
}
if (!lib.isResponsibleGM()) return;
const path = lib.getVideoJsonPath(placeableDoc);
fetch(path)
Expand Down Expand Up @@ -481,10 +488,20 @@ export class StatefulVideo {
return game.video.play(this.video);
}

async waitUntilReady() {
while (!this.video) {
this.document.renderable = false;
if (this.document?.mesh) this.document.mesh.renderable = false;
this.updateVideo();
await lib.wait(10);
}
this.play();
}

updateVideo() {
if (!this.document.object) return;
this.texture = this.document.object.texture;
this.video = this.document.object.texture.baseTexture.resource.source;
this.video = this.document.object?.texture?.baseTexture?.resource?.source;
}

updateHudScale() {
Expand Down

0 comments on commit 22edd4d

Please sign in to comment.