Fix: videos start playing after party starts

This commit is contained in:
Dejvino 2025-12-31 06:51:05 +00:00
parent eba86f81d6
commit 032f2981a0
2 changed files with 30 additions and 8 deletions

View File

@ -1,6 +1,18 @@
import * as THREE from 'three';
import { state } from '../state.js';
import { turnTvScreenOff, turnTvScreenOn } from '../scene/projection-screen.js';
import sceneFeatureManager from '../scene/SceneFeatureManager.js';
// Register a feature to handle party start
sceneFeatureManager.register({
init: () => {},
update: () => {},
onPartyStart: () => {
if (state.videoUrls && state.videoUrls.length > 0) {
startVideoPlayback();
}
}
});
// --- Play video by index ---
export function playVideoByIndex(index) {
@ -70,6 +82,14 @@ export function playNextVideo() {
playVideoByIndex(nextIndex);
}
export function startVideoPlayback() {
if (state.videoUrls && state.videoUrls.length > 0) {
console.info(`Starting playback of ${state.videoUrls.length} tapes.`);
if (state.loadTapeButton) state.loadTapeButton.classList.add("hidden");
playVideoByIndex(0);
}
}
export function playPreviousVideo() {
let prevIndex = state.currentVideoIndex - 1;
if (prevIndex < 0) {
@ -160,11 +180,13 @@ export function loadVideoFile(event) {
return;
}
// 3. Start playback of the first video
console.info(`Loaded ${state.videoUrls.length} tapes. Starting playback...`);
state.loadTapeButton.classList.add("hidden");
const startDelay = 5;
console.info(`Video will start in ${startDelay} seconds.`);
setTimeout(() => { playVideoByIndex(0); }, startDelay * 1000);
// 3. Start playback logic
console.info(`Loaded ${state.videoUrls.length} tapes.`);
if (state.partyStarted) {
startVideoPlayback();
} else {
console.info("Tapes loaded. Waiting for party start...");
if (state.loadTapeButton) state.loadTapeButton.innerText = "Tapes Ready";
}
}

View File

@ -12,7 +12,7 @@ void main() {
}
`;
const ledCountX = 256;
const ledCountX = 128;
const ledCountY = ledCountX * (9 / 16);
const screenFragmentShader = `