Skip to content

Instantly share code, notes, and snippets.

@johnw86
Created May 10, 2022 12:56
Show Gist options
  • Save johnw86/ba3b990f4f437068df8cb1bf91d49e7d to your computer and use it in GitHub Desktop.
Save johnw86/ba3b990f4f437068df8cb1bf91d49e7d to your computer and use it in GitHub Desktop.
Instagram Story CDN Handling
import logo from './logo.svg';
import './App.css';
import React from 'react';
function App() {
const [showVideo, setShowVideo] = React.useState(true);
const [showImage, setShowImage] = React.useState(true);
const cdnLink = "https://lookaside.fbsbx.com/ig_messaging_cdn/?asset_id=18041239177335195&signature=AbyRRJJOrhzZVtk5I4R-Y68YJOtVRq0ee5bet-gMDsTwgsS2iWKM6qZakxyOUDnFbt8t1ehbsQo6-ZsrYGzl6g1pX3dc7SCX6BfxPz93Q22xINr2NLaMzhK6qMZ8-pi1Ev9V_8yyer3CQwEX0IbjFsA3qvcVKTL_W9LTf1YA7uILkb-k";
const handleVideoError = () => {
setShowVideo(false);
}
const handleImageError = () => {
setShowImage(false);
}
return (
<div className="App">
{showImage && <img alt="" src={cdnLink} onError={handleImageError} />}
{showVideo && <video playsInline controls onError={handleVideoError}>
<source src={cdnLink} type="video/mp4" />
Your browser does not support the video tag.
</video>}
{(!showImage && !showVideo) && <p>Story gone, was shit anyways</p>}
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment