var PLAYER_ID = 'player';
var Player = React.createClass({
componentDidMount: function() {
document.getElementById(PLAYER_ID).addEventListener( 'ended', this.props.onEnded )
},
componentWillUnmount: function() {
document.getElementById(PLAYER_ID).removeEventListener( 'ended', this.props.onEnded )
},
render: function () {
return (
<video
id={PLAYER_ID}
src={this.props.src}
</video>
)
}
});
var PlayerContainer = React.createClass({
onEnded: function () {
alert("onEnded")
},
render: function() {
return <Player
src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
onEnded={this.onEnded}/>
}
});
React.render(
<PlayerContainer />,
document.body
);