🎥 Make videos programmatically with React
`@remotion/studio`: Detect wrong content type in media playback error overlay
Jonny Burgere14f511e469e
diff --git a/packages/studio/src/error-overlay/remotion-overlay/MediaPlaybackErrorExplainer.tsx b/packages/studio/src/error-overlay/remotion-overlay/MediaPlaybackErrorExplainer.tsxindex 81c960a431..a733369809 100644--- a/packages/studio/src/error-overlay/remotion-overlay/MediaPlaybackErrorExplainer.tsx+++ b/packages/studio/src/error-overlay/remotion-overlay/MediaPlaybackErrorExplainer.tsx@@ -5,6 +5,7 @@ type ProbeResult =| {type: 'loading'}| {type: 'not-found'}| {type: 'other-error'; statusCode: number}+ | {type: 'wrong-content-type'; contentType: string}| {type: 'ok'}| {type: 'fetch-error'};@@ -43,7 +44,15 @@ export const MediaPlaybackErrorExplainer: React.FC<{} else if (!res.ok) {setResult({type: 'other-error', statusCode: res.status});} else {- setResult({type: 'ok'});+ const contentType = res.headers.get('content-type') ?? '';+ if (+ contentType.includes('text/html') ||+ contentType.includes('application/json')+ ) {+ setResult({type: 'wrong-content-type', contentType});+ } else {+ setResult({type: 'ok'});+ }}}).catch(() => {@@ -99,5 +108,35 @@ export const MediaPlaybackErrorExplainer: React.FC<{);}+ if (result.type === 'wrong-content-type') {+ return (+ <div style={container}>+ Fetching <code style={codeStyle}>{src}</code> returned a{' '}+ <code style={codeStyle}>{result.contentType}</code> response instead of+ a video. This usually means the URL does not point to an actual media+ file.+ <br />+ If the file is in your <code style={codeStyle}>public/</code> folder,+ make sure to use{' '}+ <a+ style={linkStyle}+ href="https://remotion.dev/docs/staticfile"+ target="_blank"+ >+ <code style={codeStyle}>staticFile()</code>+ </a>{' '}+ to reference it.+ <br />+ <a+ style={linkStyle}+ href="https://remotion.dev/docs/media-playback-error"+ target="_blank"+ >+ Learn more+ </a>+ </div>+ );+ }+return null;};