无法访问VideoJS的player.currentTime()

问题描述:

我试图访问其他我初始化它的方法中的videojs的当前时间。但我无法访问它。它说:“无法读取的未定义的属性currentTime的”无法访问VideoJS的player.currentTime()

这就是我要做的

我在下面的函数初始化玩家

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() 


    } 

这是我试图访问球员的currentTime的

jumpToSpecificMarker= (time) =>{ 
     // this.state.player.currentTime(10) 
     player.currentTime() 
    } 

我从我的渲染方法调用jumpToSpecificMarker这样

render() { 
     if (this.props.sentance_selected_reducer.flag) { 
      console.log("Inside if flag") 

      this.jumpToSpecificMarker(player, this.props.sentance_selected_reducer.sentanceTime); 
     } 

player变量超出了函数的范围jumpToSpecificMarker。

你是如何调用jumpToSpecificMarker的?你也可以通过玩家作为参数jumpToSpecificMarker(玩家,时间)?

+0

请参阅我的编辑。我添加了如何调用jumpToSpeceficMarker – ApurvG

+0

而我在全班范围内定义了球员变量。所以我不认为它超出了范围。 – ApurvG