Created
January 3, 2016 13:03
-
-
Save arqex/c935ad769ac4a3d84e8b to your computer and use it in GitHub Desktop.
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
var Video = React.createClass({ | |
render: function() { | |
return ( | |
<video ref="video" src={ this.props.src } /> | |
); | |
}, | |
/** | |
* It plays the video is it is paused or pause it | |
* if the video is being played. | |
*/ | |
playOrPause: function(){ | |
// HTML 5 API is also object oriented | |
// we can use their methods also using | |
// references | |
var videoElement = this.ref.video; | |
if( videoElement.paused ){ | |
videoElement.play(); | |
} | |
else { | |
videoElement.pause(); | |
} | |
}, | |
/** | |
* Moves the video to the beginning. | |
*/ | |
goToBeginning: function(){ | |
this.refs.video.currentTime = 0; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment