Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/firefox-media-orb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

Fix video and audio failing to play on Firefox with "no video with supported format and MIME type found".
6 changes: 6 additions & 0 deletions src/app/components/message/content/AudioContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ export function AudioContent({
controls={false}
autoPlay
ref={audioRef}
// See VideoContent: CORS opts this Range-streamed media out of Firefox's ORB.
crossOrigin={
srcState.status === AsyncStatus.Success && !srcState.data.startsWith('blob:')
? 'anonymous'
: undefined
}
onVolumeChange={(e) => {
localStorage.setItem(MEDIA_VOLUME_KEY, String((e.target as HTMLAudioElement).volume));
}}
Expand Down
10 changes: 10 additions & 0 deletions src/app/components/message/content/VideoContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type RenderVideoProps = {
onError: () => void;
autoPlay: boolean;
controls: boolean;
crossOrigin?: 'anonymous';
};
type VideoContentProps = {
body: string;
Expand Down Expand Up @@ -116,6 +117,11 @@ export const VideoContent = as<'div', VideoContentProps>(
}
}, [srcState.status]);

const streamsAuthenticatedMedia =
srcState.status === AsyncStatus.Success &&
!url.startsWith('http') &&
!srcState.data.startsWith('blob:');

const handleLoad = () => {
setLoad(true);
setError(false);
Expand Down Expand Up @@ -195,6 +201,10 @@ export const VideoContent = as<'div', VideoContentProps>(
onError: handleError,
autoPlay: false,
controls: true,
// Firefox blocks media Range responses it cannot sniff as audio/video (mozilla bug
// 1880289); requesting with CORS opts out. External URLs are left alone since we
// cannot assume they send Access-Control-Allow-Origin.
crossOrigin: streamsAuthenticatedMedia ? 'anonymous' : undefined,
})}
</Box>
)}
Expand Down
Loading