Vimeo,检测全屏点击

问题描述 投票:4回答:3

有没有办法检测用户何时按下全屏按钮?在他们的API网站上找不到任何关于它的信息......

http://developer.vimeo.com/player/js-api

javascript click vimeo
3个回答
1
投票

我尝试了很多时间来检测vimeo播放器上的全屏按钮,但没有成功。但我发现其他解决方案对我有用:

$(window).resize(checkResize);

function checkResize(){
    if (
        document.fullscreenElement ||
        document.webkitFullscreenElement ||
        document.mozFullScreenElement ||
        document.msFullscreenElement
    ){
        // action for fullscreen enable
    }else{
        // action for fullscreen disable
    }
}

0
投票

这就是我完成检测嵌入式(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
});

-1
投票

你可以这样做:

$('button.fullscreen[data-title-fullscreen][data-title-unfullscreen]').click(function(){
//DO something here
});
© www.soinside.com 2019 - 2024. All rights reserved.