我在这里有一个简单的jsfiddle:http://jsfiddle.net/cvcwc/2/
基本代码看起来像:
window.player = videojs("movie_container", { techOrder: ["html5", "slash"] }, function() {
videojs_player = this;
videojs_player.src({ src: "http://video-js.zencoder.com/oceans-clip.mp4", type: 'video/mp4'})
videojs_player.on("click", function(event){
event.preventDefault();
alert('click');
});
videojs_player.play();
});
我正在尝试捕获视频上的所有单击事件以进行将来的处理,但是我不希望视频在单击时暂停。有什么想法吗?
我找到了HTML5的答案...但是我在Flash后备中没有单击事件。更新的JSFDL:http://jsfiddle.net/cvcwc/3/
window.player = videojs("movie_container", { techOrder: ["html5", "flash"] }, function() {
videojs_player = this;
videojs_player.src({ src: "http://video-js.zencoder.com/oceans-clip.mp4", type: 'video/mp4'})
videojs_player.off('click');
videojs_player.on("click", function(event){
event.preventDefault();
console.log("click", event.clientX, event.clientY, videojs_player.currentTime());
});
videojs_player.play();
});
如果某人掉下来,则只是一种替代方案。当用户单击流(或查看,无论您称之为什么)而不是控制栏时,您想绕过停止播放功能时,可以在videojs中评论somelines ..
Player.prototype.handleTechClick_ = function handleTechClick_(event) {
// We're using mousedown to detect clicks thanks to Flash, but mousedown
// will also be triggered with right-clicks, so we need to prevent that
if (event.button !== 0) return;
// When controls are disabled a click should not toggle playback because
// the click is considered a control
if (this.controls()) {
if (this.paused()) {
//this.play(); // COMMENTED OUT
} else {
//this.pause(); // COMMENTED OUT
}
}
};
控制条仍将工作...