当用户单击 html5 视频中的全屏按钮(右下角)时,我想执行某些操作。
所以像这样:
$('#video').on('webkitRequestFullscreen', function() {
console.log("hello");
});
但这不起作用。
这将在 Android WebView 中运行,因此您不必担心多个浏览器。
最佳答案
编辑有一些事件可以处理此问题,请参阅以下内容:Fullscreen API: Which events are fired?
原始答案
在这种情况下,您必须使用某种间隔。以下是我完成此任务的方法:
// Returns true if we can enter fullscreen
//(i.e. fullscreen function is available and not already fullscreened)
var canFullscreen = function(){
return (
!document.fullscreenElement &&
!document.mozFullScreenElement &&
!document.webkitFullscreenElement &&
!document.msFullscreenElement );
}
setInterval(function(){
if( canFullscreen() ) {
// Handle exiting fullscreen
} else {
// Handle entering fullscreen
}
}, 50);
关于javascript - 如何在 javascript/jquery 中检查 html5 视频的全屏请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35302249/