我在这里有一个简单的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();
});
我正在尝试捕获视频上的所有点击事件以供将来处理,但我不希望视频在点击时暂停。有什么想法吗?
答案 0 :(得分:9)
我找到了HTML5的答案......但我没有在闪回后备中获得点击事件。更新了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();
});
答案 1 :(得分:1)
如果有人对此表示不满,那就是另一种选择。如果你想在用户点击流(或视图,无论你怎么称呼它)时绕过停止播放功能,而不是控制栏,你可以注释视频中的某些内容..
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
}
}
};
控制栏仍然有用......