Skip to content

Instantly share code, notes, and snippets.

@hhimanshu
Created November 11, 2020 13:42
Show Gist options
  • Save hhimanshu/ecdf2ee500bfbd08140dc449cd49c47a to your computer and use it in GitHub Desktop.
Save hhimanshu/ecdf2ee500bfbd08140dc449cd49c47a to your computer and use it in GitHub Desktop.
Plyr w/ TypeScript
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