1
0

more refactors
All checks were successful
Test / test (push) Successful in 9m32s

This commit is contained in:
Aiden
2026-06-10 12:37:48 +10:00
parent d9a5ec9018
commit 24a166046e
9 changed files with 238 additions and 62 deletions

View File

@@ -5,12 +5,13 @@ import {
VALID_PROJECTIONS
} from './config.js';
import { create2DControlPanel, createPlayButton, injectPlayerStyles } from './dom/dom.js';
import { createMediaAdapter, type SupportedMediaAdapter } from './media/media-adapter.js';
export type BootstrapContext = {
mediaAdapter: SupportedMediaAdapter;
playButton: HTMLButtonElement;
playerContainer: HTMLElement;
projectionMode: ProjectionMode;
videoElement: HTMLVideoElement;
};
export function bootstrapPlayer(playerBase: string, onReady: (context: BootstrapContext) => void): void {
@@ -38,25 +39,24 @@ export function bootstrapPlayer(playerBase: string, onReady: (context: Bootstrap
return;
}
const videoElement = playerContainer.querySelector('video');
if (!videoElement) {
console.error(`VR_WEB_PLAYER_DOM: ${PLAYER_SELECTOR} must contain a video element.`);
const mediaAdapter = createMediaAdapter(playerContainer);
if (!mediaAdapter) {
console.error(`VR_WEB_PLAYER_DOM: ${PLAYER_SELECTOR} must contain a supported media element (video).`);
return;
}
videoElement.classList.add('vrwp-video');
const playButton = createPlayButton();
playerContainer.appendChild(playButton);
playerContainer.appendChild(create2DControlPanel());
playButton.disabled = true;
videoElement.load();
mediaAdapter.load();
completeXrSupportCheck(playButton, () => {
onReady({
mediaAdapter,
playButton,
playerContainer,
projectionMode: configuredProjection as ProjectionMode,
videoElement
projectionMode: configuredProjection as ProjectionMode
});
});
});