Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 with webkitEnterFullScreen

余生长醉 提交于 2019-12-23 01:08:09

问题


$(document).ready(function(){
        var url = 'video.mp4'
        var video = $(document.createElement('video'))

        video.attr("width", 300);
        video.attr("height", 150);
        video.attr("src", url);
        video.attr("controls", true);
        video.attr("id", "video");

        video[0].addEventListener("play", function() {  }, false);

        video[0].play();
        video[0].webkitEnterFullScreen();

        $('body').append(video);

    })

Uncaught Error: INVALID_STATE_ERR: DOM Exception 11

What am I doing wrong?


回答1:


You need to wait until the video's loadedmetadata event has been fired before calling webkitEnterFullScreen(). Please take a look at this post on stackoverflow or read Apple's Safari docs.




回答2:


this error means that the video is not loaded, make sure that path to the video file is correct and the video is loaded, and afterward you can try this:

if (document.mozFullscreen) {
    video.mozRequestFullScreen();
}

if (document.webkitIsFullscreen) {
    video.webkitEnterFullScreen();
}


来源:https://stackoverflow.com/questions/11413300/uncaught-error-invalid-state-err-dom-exception-11-with-webkitenterfullscreen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!