【发布时间】:2017-01-24 11:22:35
【问题描述】:
我想将标记添加到我的 videojs 播放器时间。我已经看到了如何实施它,并且几个月前就已经实施了它,并且当时奏效了。现在在我的另一个项目中,我想使用相同的。但它给我这样的控制台错误(如下),我无法在播放器时间轴上看到我的标记。
class Player extends Component {
constructor() {
super();
this.state = {
player: {}
};
}
componentDidMount() {
var self = this;
var player = videojs(this.refs.video, this.props.options).ready(function () {
self.player = this;
self.player.on('play', self.handlePlay);
});
// $.get('URL-TO-FETCH-DATA-FROM', function(result) {
// if (this.isMounted()) {
// this.setState({
// dataVar1: result
// });
// }
// }.bind(this));
if (this.props.onPlayerInit) this.props.onPlayerInit(player);
player.markers({
markerStyle: {},
markers: this.props.marker_store,
onMarkerReached: function () {
// player.pause();
},
});
this.setState({player: player});
}
handlePlay() {
console.log("handle play ")
}
render() {
var props = blacklist(this.props, 'children', 'className', 'src', 'type', 'onPlay');
props.className = cx(this.props.className, 'videojs', 'video-js vjs-default-skin', 'vjs-big-play-centered');
assign(props, {
ref: 'video',
controls: true,
});
return (
<video {... props}>
<source src={videoSrc} type="video/mp4"/>
</video>
)
}
}
const mapStateToProps = (state) => {
return {
marker_store:state.markerReducer
};
};
export default connect(mapStateToProps)(Player);
这些是markers.js插件代码的行,它们会抛出videojs未定义错误
};
}
videojs.plugin('markers', registerVideoJsMarkersPlugin);
})(jQuery, window.videojs);
我应该如何解决它才能看到播放器上的标记?
【问题讨论】:
标签: javascript reactjs video.js markers