有没有办法检测用户点击全屏按钮的操作?在他们的API网站上找不到相关信息...
http://developer.vimeo.com/player/js-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
}
}
window.addEventListener('resize', function () {
if (
document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement
){
screen.orientation.lock('landscape');
}
});
$(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
});