Skip to content

Instantly share code, notes, and snippets.

@arqex
Created January 3, 2016 13:03
Show Gist options
  • Save arqex/c935ad769ac4a3d84e8b to your computer and use it in GitHub Desktop.
Save arqex/c935ad769ac4a3d84e8b to your computer and use it in GitHub Desktop.
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