Created
May 10, 2022 12:56
-
-
Save johnw86/ba3b990f4f437068df8cb1bf91d49e7d to your computer and use it in GitHub Desktop.
Instagram Story CDN Handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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