Skip to content

Instantly share code, notes, and snippets.

@scwood
Created September 29, 2022 06:40
Show Gist options
  • Save scwood/ca97f21aafa522e8d92ef3616a115002 to your computer and use it in GitHub Desktop.
Save scwood/ca97f21aafa522e8d92ef3616a115002 to your computer and use it in GitHub Desktop.
FloatingRadioBanner.tsx
function FloatingRadioBanner() {
const radioMediaType = useState(MediaType.None);
const isLoading = useState(true) // Idk if None really matters
useEffect(() => {
// Setup mixhalo
//
// Set radioMediaType inside ths listeners
//
// Set isLoading to false once you've determined the radioMediaType
//
// Return cleanup function:
// return () => listeners.remove()
}, [])
useEffect(() => {
if (mediaControls.isRadioBannerVisible) {
mediaConrols.setMediaType(radioMediaType)
}
}, [mediaControls.isRadioBannerVisible, radioMediaType])
if (!mediaControls.isRadioBannerVisible) {
return null;
} else if (isLoading) {
return // version of radio banner with activity indicators
} else if (radioMediaType === MediaType.LowLatency) {
return <LowLatencyRadioBanner/>
} else {
return <HighLatencyRadioBanner/>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment