调用 webkitEnterFullscreen() 时出现 DOM 异常 11
异常是什么意思?我该如何修复它?我正在使用适用于 Ubuntu 的最新 Google Chrome。
What does the exception mean? How can I fix it? I am using the latest Google Chrome for Ubuntu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在视频元素收到其资产的元数据之前调用
webkitEnterFullscreen
时,可能会发生INVALID_STATE_ERR:DOM 异常 11
。最简单的解决方案是推迟对webkitEnterFullscreen
的调用,方法是将其放入分配给视频的loadedmetadata
事件的回调函数中。在移动环境中,您需要更进一步,将该调用附加到可触摸元素,以便由用户启动,因为播放和全屏操作必须由移动环境中的用户交互驱动。
代码应该看起来像这样:
INVALID_STATE_ERR: DOM Exception 11
can occur when a call towebkitEnterFullscreen
is made before the video element has received its asset's metadata. The simplest solution is to defer the invocation ofwebkitEnterFullscreen
by putting it in a callback function assigned to the video'sloadedmetadata
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: