Youtube video component for deku.
npm install deku-youtube-video
import YoutubeVideo from 'deku-youtube-video';
const onClick = (e, component, setState) => {
console.log('video clicked');
// Set state.opened to true to play the video
setState({ opened: true });
}
export default {
render: function ({ state }) {
const {opened} = state;
return (<YoutubeVideo youtube-id='YoB8t0B4jx4' onClick={onClick} opened={opened} />);
}
}
youtubeId=[youtube-video-id]
Set youtube video ID to use.onClick=[function]
Function to run when video is clicked onopened=[boolean]
If false, shows a video preview using the youtube thumbnail and if true opens and plays the video.thumbnail=[string]
- Optional Set custom thumbnail image, this will override the standard youtube thumbnail.thumbnailSize=[string]
- Optional Set which youtube thumbnail to use, defaults tohqdefault
If you load the youtube iframe api (https://www.youtube.com/iframe_api
), support for the following events exists (as attributes):
onEnded
- called on window.YT.PlayState.ENDEDonPlaying
- called on window.YT.PlayState.PLAYINGonPaused
- called on window.YT.PlayState.PAUSEDonBuffering
- called on window.YT.PlayerState.BUFFERINGonCued
- called on window.YT.PlayerState.CUED
Import the css using postcss.
@import 'deku-youtube-video';