From 0572bbde72514a9584b19fe031a03d4c9b23d74c Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Tue, 6 Oct 2026 23:18:38 +0200 Subject: fix(hub): play video on iPhone through ManagedMediaSource An iPhone has no MediaSource; every film was refused as an unsupported codec. A browser with neither now says so. Co-Authored-By: Claude Opus 5.5 --- .../meshbay-hub/src/meshbay_hub/static/video-player.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/video-player.js') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/video-player.js b/packages/meshbay-hub/src/meshbay_hub/static/video-player.js index 21abe8e..5ea14ef 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/video-player.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/video-player.js @@ -1104,7 +1104,16 @@ function VideoPlayer({ entry, transportRef, gekRef, onClose, onDownload, onCopyL setAudioTrack(msg.audio_track); } - if (!window.MediaSource || !MediaSource.isTypeSupported(mime)) { + // An iPhone has no MediaSource, only ManagedMediaSource (iOS 17.1+): + // testing for the first alone refused every film there, and blamed + // the codec for it. + const MS = window.MediaSource || window.ManagedMediaSource; + if (!MS) { + setError(t('video.err_no_mse')); + setPhase('error'); + return; + } + if (!MS.isTypeSupported(mime)) { setError(t('video.err_mse', { codec: msg.codec })); setPhase('error'); return; @@ -1186,7 +1195,7 @@ function VideoPlayer({ entry, transportRef, gekRef, onClose, onDownload, onCopyL castRestartPendingRef.current = true; } - const ms = new MediaSource(); + const ms = new MS(); msRef.current = ms; if (blobUrlRef.current) URL.revokeObjectURL(blobUrlRef.current); const url = URL.createObjectURL(ms); @@ -1235,6 +1244,9 @@ function VideoPlayer({ entry, transportRef, gekRef, onClose, onDownload, onCopyL }); if (videoRef.current) { + // A ManagedMediaSource never opens on an element AirPlay could take + // over, unless it is given a second source to hand AirPlay instead. + if (MS !== window.MediaSource) videoRef.current.disableRemotePlayback = true; videoRef.current.src = url; videoRef.current.addEventListener('seeking', onSeeking); videoRef.current.addEventListener('timeupdate', pump); -- cgit v1.2.3