问题
$(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