I am trying to access the current time of videojs in the method other that where I initialised it. But I am not able to access it. It says "cannot read property currentTime of undefined"
This is what I am trying to do
I initialize player in below function
initVideoJS = ()=> {
var that = this;
debug('Init VideoJS')
const options = {
fluid: true,
preload: false,
autoplay: false,
controls: true,
aspectRatio: "16:9"
}
player = this.video = videojs(this.video_el, options) //player is the global variable
that.setState({player:this.video})
this.video.on("timeupdate", () => {
currentTime = this.video.currentTime();
duration = this.video.duration()
}
This is where I am trying to access currentTime of player
jumpToSpecificMarker= (time) =>{
// this.state.player.currentTime(10)
player.currentTime()
}
I am invoking jumpToSpecificMarker from my render method like this
render() {
if (this.props.sentance_selected_reducer.flag) {
console.log("Inside if flag")
this.jumpToSpecificMarker(player, this.props.sentance_selected_reducer.sentanceTime);
}