react-youtube-player
React component that encapsulates YouTube IFrame Player API and exposes player controls using the component properties.
Implementation
componentDidMount
callback is used to replace the rendered element with an iframe
that loads a YouTube Player.
componentWillReceiveProps
is used to detect when component properties change, compare them with the state of the YouTube Player and call YouTube IFrame Player API when necessary.
Usage
; /** * @typedef * @value 'unstarted' Stops and cancels loading of the current video. * @value 'playing' Plays the currently cued/loaded video. * @value 'paused' Pauses the currently playing video. */ /** * @property * @property * @property * @property * @property */<YoutubePlayer videoId='' playbackState='unstarted' configuration= showinfo: 0 controls: 0 />
Demo
To run the demo:
npm install
npm run build
npm run demo