Created
February 2, 2021 01:21
-
-
Save pietrop/81b1c8e11361d822fbe76f5fd2eb5e7c to your computer and use it in GitHub Desktop.
Check the media type using the file extension of a url, works client side
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 path from 'path'; | |
const getMediaType = (mediaUrl) => { | |
const clipExt = path.extname(mediaUrl); | |
let tmpMediaType = 'video'; | |
if (clipExt === '.wav' || clipExt === '.mp3' || clipExt === '.m4a' || clipExt === '.flac' || clipExt === '.aiff') { | |
tmpMediaType = 'audio'; | |
} | |
return tmpMediaType; | |
}; | |
export default getMediaType; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment