gpt4 book ai didi

javascript - 无法访问 VideoJS 的 player.currentTime()

转载 作者:行者123 更新时间:2023-12-04 02:28:56 24 4
gpt4 key购买 nike

我正在尝试使用我初始化它的方法以外的方法访问 videojs 的当前时间。但我无法访问它。它说“无法读取未定义的属性 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()


}

这是我试图访问播放器当前时间的地方

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);
}

最佳答案

玩家变量超出了您的函数 jumpToSpecificMarker 的范围。

您如何调用 jumpToSpecificMarker?您还可以将玩家作为参数传递给 jumpToSpecificMarker(player, time) 吗?

关于javascript - 无法访问 VideoJS 的 player.currentTime(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46618363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com