有没有办法检测用户何时按下全屏按钮?在他们的API网站上找不到任何关于它的信息......
我尝试了很多时间来检测vimeo播放器上的全屏按钮,但没有成功。但我发现其他解决方案对我有用:
$(window).resize(checkResize);
function checkResize(){
if (
document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement
){
// action for fullscreen enable
}else{
// action for fullscreen disable
}
}
这就是我完成检测嵌入式(iframe)Vimeo视频是否全屏(需要jQuery)的方法:
$(function(){
var checkVimeoFullscreen = setInterval(function(){
var winWidth = $(window).width(); // Get the full window width
var vimeoWidth = $('iframe[src*="vimeo"]').width(); // Get the width of the Vimeo iframe
if (winWidth == vimeoWidth){ // if the Vimeo iframe and the window width match, you're in fullscreen
console.log("Vimeo is in fullscreen mode.");
} else {
console.log("Vimeo is not in fullscreen mode.");
}
},500); // You can change the interval if you want, but this worked for me
});
你可以这样做:
$('button.fullscreen[data-title-fullscreen][data-title-unfullscreen]').click(function(){
//DO something here
});