问题描述
异常是什么意思?我该如何解决它?我正在使用适用于Ubuntu的最新Google Chrome。
What does the exception mean? How can I fix it? I am using the latest Google Chrome for Ubuntu.
推荐答案
INVALID_STATE_ERR:DOM例外11 webkitEnterFullscreen
时,可能会发生$ c>。最简单的解决方案是通过将其放入分配给视频的 loadedmetadata
事件的回调函数来推迟调用 webkitEnterFullscreen
。
INVALID_STATE_ERR: DOM Exception 11
can occur when a call to webkitEnterFullscreen
is made before the video element has received its asset's metadata. The simplest solution is to defer the invocation of webkitEnterFullscreen
by putting it in a callback function assigned to the video's loadedmetadata
event.
在移动环境中,您需要通过将该调用附加到可触摸元素来更进一步,以便用户启动它,因为必须驱动播放和全屏操作通过移动环境中的用户交互。
In a mobile environment, you need to take things a step further by attaching that call to a touchable element so that it is user initiated since play and fullscreen actions must be driven by user interaction in mobile environments.
代码看起来应该是这样的:
The code should look kind of like this:
var video, play, fullscreen;
video = document.createElement('video');
video.src = 'my_cool_video.mp4';
video.addEventListener('loadedmetadata', function () {
fullscreen.disabled = false;
}, false);
play = document.createElement('button');
play.innerHTML = 'PLAY';
play.addEventListener('click', function () {
video.play();
}, false);
fullscreen = document.createElement('button');
fullscreen.innerHTML = 'FULLSCREEN';
fullscreen.disabled = true;
fullscreen.addEventListener('click', function () {
video.webkitEnterFullscreen();
}, false);
document.body.appendChild(video);
document.body.appendChild(play);
documnet.body.appendChild(fullscreen);
这篇关于调用webkitEnterFullscreen()时的DOM异常11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!