I'm working on a simple React Component to play video. It works fine, now I'd like to know when the video stops so that I can hide him and start some other things. I'd like to use 'ended' event, below the code, I but I keep getting: Cannot read property 'addEventListener' of undefined which, as far as I understand, means that the html tag introVideo is null but I don't know what I'm doing wrong.
export default class ShowMovieWindow extends React.Component {
constructor(props) {
super(props);
this.handleVideoEnd = this.handleVideoEnd.bind(this);
};
handleVideoEnd() {
console.log("Finished");
}
componentDidMount() {
this.refs.introVideo.addEventListener("ended", this.handleVideoEnd);
}
render() {
return (
<Dialog isOpen={this.props.isOpen}>
<div className={Classes.DIALOG_BODY}>
<div>
<video ref="introVideo" autoPlay>
<source src={'./asset/video/intro.mp4'} type="video/mp4"/>
</video>
</div>
</div>
</Dialog>
);}}