1

您好,我正在尝试自动播放全屏视频我正在使用全屏 api ...这是代码

        功能启动全屏(元素){
          如果(元素。请求全屏){
            element.requestFullscreen();
          }否则如果(元素.mozRequestFullScreen){
            element.mozRequestFullScreen();
          } 否则如果(element.webkitRequestFullscreen){
            element.webkitRequestFullscreen();
          } 否则如果(元素.msRequestFullscreen){
            element.msRequestFullscreen();
          }
        }



        kWidget.addReadyCallback(function(playerId){
           var kdp = document.getElementById( playerId );
           var theid = jQuery('.kaltura-player-wrapper').attr('id')
           设置间隔(函数(){
           var durationVideo = Math.round(kdp.evaluate('{duration}'));
           var currentTime = Math.round(kdp.evaluate('{video.player.currentTime}'));

        如果(当前时间 == 2){
            launchIntoFullscreen(document.getElementById(theid));
        控制台.log(theid);
        }
    
        // 打全屏
        功能退出全屏(){
         如果(document.exitFullscreen){
           document.exitFullscreen();
        } 否则如果(document.mozCancelFullScreen){
           document.mozCancelFullScreen();
        } 否则如果(document.webkitExitFullscreen){
           document.webkitExitFullscreen();
        }
        }

        // 取消支持全屏的浏览器!

        var durationFull = (durationVideo - 1);
           if (currentTime == durationFull){
               退出全屏();
           }

        如果(当前时间 == 持续时间视频){
             jQuery("#relatedredirect").modal({minWidth: 200});

                变量计数 = 3;
                var countdown = setInterval(function(){
                jQuery("p.countdown").html("Il prossimo video tra "+count + " secondi");
                如果(计数 == 0){
                  清除间隔(倒计时);
                  window.open('', "_self");
                }
                数数 - ;
                }, 1000);
        }

错误 切换到全屏模式的请求被拒绝,因为 Element.mozRequestFullScreen () 未被用户快速生成的事件处理程序调用。

4

1 回答 1

0

注意:需要从事件处理程序中调用全屏请求,否则它们将被拒绝。来自: https ://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode

于 2015-06-01T08:21:47.350 回答