Skip to content

Commit

Permalink
whoops
Browse files Browse the repository at this point in the history
  • Loading branch information
konekowo committed Sep 29, 2024
1 parent 14afeb6 commit d2b56ea
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Audio/Audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,21 @@ export class Audio {
if (this._onEndCallback) {
this._onEndCallback();
}
let backgroundVideo = this.beatmap.Events.Events.find((e) => {
if (e.eventType == EventTypes.VIDEO){
return e;
}
}) as EventVideo;
if (backgroundVideo) {
if (backgroundVideo.texture) {
if (backgroundVideo.texture.source.resource.startPromise) {
backgroundVideo.texture.source.resource.startPromise.then(() => {
let video = backgroundVideo.texture!.source.resource as HTMLVideoElement;
video.pause();
});
}
}
}
}
}

Expand All @@ -191,6 +206,34 @@ export class Audio {
throw new Error("SetTime is not supported on AudioSourceBuffer!");
}
this.mediaAudioElement.currentTime = timeMS/1000;
let backgroundVideo = this.beatmap.Events.Events.find((e) => {
if (e.eventType == EventTypes.VIDEO){
return e;
}
}) as EventVideo;
if (backgroundVideo) {
if (backgroundVideo.texture) {
if (backgroundVideo.texture.source.resource.startPromise) {
backgroundVideo.texture.source.resource.startPromise.then(() => {
let video = backgroundVideo.texture!.source.resource as HTMLVideoElement;
let time = timeMS/1000;
time += backgroundVideo.startTime;
if (time < 0) {
video.currentTime = 0;
video.pause();
backgroundVideo.texture!.source.resource.startPromise = new Promise<void>((resolve) => {
setTimeout(() => {
video.play();
}, Math.abs(time));
});
} else {
video.currentTime = time;
}

});
}
}
}
}

public GetDuration() {
Expand Down

0 comments on commit d2b56ea

Please sign in to comment.