3
$(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?

Ivan
  • 301
  • 4
  • 9

2 Answers2

3

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.

Community
  • 1
  • 1
TimHayes
  • 3,684
  • 21
  • 26
0

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();
}
Ram
  • 143,282
  • 16
  • 168
  • 197