HTML5 - 视频冻结重页处理

时间:2017-10-14 19:45:11

标签: javascript html5 html5-canvas html5-video

我正在尝试在执行繁重处理的页面上显示视频,这意味着许多HTML控件会随时间更新和更改网格,图表等,并且他们的处理会不断发生。问题是,当我重新加载HTML元素时,视频会冻结(使用Chrome 61)。 它有什么办法吗?比如从另一个线程渲染特定的HTML元素(视频)(以某种方式使用网络工作者?) 我认为其他人可能已经在单页应用上的视频或其他实时更新控件(渲染画布等)上遇到了这个问题,是否有解决方案?

下面这样的代码示例,显然这个例子不是真实的代码,而是由样本组成,但它证明了这个想法。

会感激一些帮助。 谢谢!

<!DOCTYPE html>
<html>
<head>
  <title>||Working with elements||</title>
</head>
<body>

<video width="320" height="240" autoplay controls>
  <source src="test.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

<script type="text/javascript">
function addElement () { 
for (i=0; i < 1000000; i++)
{
  // create a new div element 
  // and give it some content 
  var newDiv = document.createElement("div"); 
  var newContent = document.createTextNode("Hi there and greetings!"); 
  newDiv.appendChild(newContent); //add the text node to the newly created div. 

  // add the newly created element and its content into the DOM 
  var currentDiv = document.getElementById("div1"); 
  document.body.insertBefore(newDiv, currentDiv); 
  }
}
</script>
<div id="div1">The text above has been created dynamically.</div>
<input type=button onclick="addElement()">
</body>
</html>

0 个答案:

没有答案