Created
November 11, 2020 13:42
-
-
Save hhimanshu/ecdf2ee500bfbd08140dc449cd49c47a to your computer and use it in GitHub Desktop.
Plyr w/ TypeScript
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
export const VideoPlayer = ({youtubeId}: VideoPlayerProps) => { | |
useEffect(() => { | |
const options = { | |
noCookie: false, | |
rel: 0, | |
showinfo: 1, | |
iv_load_policy: 3, | |
modestbranding: 1 | |
} | |
if (typeof document !== `undefined`) { | |
const Plyr = require('plyr'); | |
require("plyr/dist/plyr.css"); | |
const player = new Plyr(".js-plyr", options); | |
player.source = { | |
type: "video", | |
sources: [ | |
{ | |
src: youtubeId, | |
provider: "youtube" | |
} | |
] | |
}; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment