【问题标题】:Vimeo API - Can I disable some keyboard shortcuts of the embedded Vimeo video instead of disabling all shortcuts?Vimeo API - 我可以禁用嵌入式 Vimeo 视频的一些键盘快捷键而不是禁用所有快捷键吗?
【发布时间】:2021-11-10 13:00:48
【问题描述】:

我可以禁用嵌入 Vimeo 视频的某些键盘快捷键而不是禁用所有快捷键吗?

我经常通过 iframe 将 Vimeo 视频嵌入我的网站以进行视频会议。 我需要隐藏控制栏并禁用除快捷方式“F”以外的所有快捷方式

有没有办法做到这一点?

谢谢

【问题讨论】:

    标签: javascript iframe vimeo vimeo-api vimeo-player


    【解决方案1】:

    请通过本地保存在您的设备上或使用任何第三方代码编译器尝试代码,因为 Stack Overflow 不允许“全屏”,并确保 iframe 处于活动状态或焦点。

    var options = {
            id: 59777392,  //Video Id
            width: 640,
            keyboard: false,
        };
    
        var player = new Vimeo.Player('VimeoVideo', options);
    
        
    
        player.on('play', function() {
            window.focus()
        });
    
        player.on('pause', function() {
            window.focus()
        });
    
    
    window.addEventListener("blur", () => {
     {
        if (document.activeElement.tagName === "IFRAME") {
          check(); //Checks if Iframe is already in Full Screen
        }
      };
    });
    
    
    function check(){
    if(window.innerHeight !== screen.height) { //If the Iframe is not full screen then make it full screen when user presses 'F', this will work only after the Vimeo Video Iframe has completed loading.
        document.addEventListener("keydown", event => {
      if (event.isComposing || event.keyCode !== 70) {
        return;
      }
      player.requestFullscreen();
    })}
    else{
    document.addEventListener("keydown", event => {//If the Iframe is in full screen then make it normal, this function might not be executed if user do not interacts.
      if (event.isComposing || event.keyCode !== 70) {
        return;
      }
      player.exitFullscreen();
    })
    }
    }
    <!-- The Keyboard is disbaled and only 'F' key is enabled -->
    <div id="VimeoVideo"></div>
    <script src="https://player.vimeo.com/api/player.js"></script>

    【讨论】:

      猜你喜欢
      • 2021-09-15
      • 1970-01-01
      • 2012-11-06
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-19
      • 2012-10-30
      相关资源
      最近更新 更多