Created
January 18, 2017 08:37
-
-
Save berkaytheunicorn/a04bf76e65e603ed1a27047330b81fee to your computer and use it in GitHub Desktop.
React Video Component
This file contains hidden or 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
React = require "react" | |
{video,source} = React.DOM | |
View = React.createClass | |
displayName: "Video" | |
shouldComponentUpdate:(nextProps,nextState)-> | |
# unless @refs.video.readyState is 4 | |
# return true | |
# unless @props.options.style.width is nextProps.options.style.width | |
# return true | |
# unless @props.options.style.height is nextProps.options.style.height | |
# return true | |
# return false | |
return true | |
# componentDidMount:()-> | |
# @refs.video.load() | |
# console.log "yey" | |
componentDidUpdate:()-> | |
unless @refs.video.readyState is 4 | |
@refs.video.load() | |
options:()-> | |
props = @props.options | |
props.ref = "video" | |
return props | |
render: ()-> | |
video @options() , | |
@props.sources.map (video,index)-> | |
source | |
key:index | |
src: video.src | |
type: video.type or "" | |
module.exports = React.createFactory View |
Important part is
unless @refs.video.readyState is 4
@refs.video.load()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
in JSX