本文介绍了在单页应用程序页面上的许多视频标签(角),使页面冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我创建了一个单页的应用程序(角),我尝试切换一个页面上有多个视频的网页(例如4),几个开关后,我有无尽挂起的请求的一个问题。

If I create a single page application (angular) where I try to switch pages with several videos on one page (for example 4), after several switches I have a problem with endless pending requests.

根据该问题Dynamic IMG(或视频)标签不加载所有资源,HTTP请求"待决的QUOT; 以及张贴关于在Chrome中的旁边还有意见:

According to this question Dynamic img (or video) tags don't load resources at all, HTTP requests are "pending" and post about this problem in Chrome https://code.google.com/p/chromium/issues/detail?id=234779 there are next advices:


  1. 不要使用preLOAD =元数据(或preLOAD =自动),并使用preLOAD =无。
    但在这种情况下,我们没有preVIEW图像视频时尽量发挥吧,我没有缓冲的数据,所以我等待几秒钟,并有延时播放之前。

  1. Don't use preload="metadata" (or preload="auto") and use preload="none".
    But in this case we don't have preview image for video and when try to play it, I don't have buffered data, so I'm waiting for several seconds and have delay before playing.

我试图使用Chrome浏览器(链接2)中描述的所有招数,但它工作在Chrome和Firefox在Windows平台上,并在Opera开不工作。结果
它一般不工作,在Mac OS平台上的所有浏览器。我还有无尽的挂起的请求。

I tried to use all tricks that described for Chrome (link 2), but it works in Chrome and Firefox on Windows platform and does't work in Opera.
It generally doesn't work in all browsers on MacOS platform. I still have endless pending requests.

关于未决请求:它不仅是视频或音频文件的请求,也可以是数据库连接或.html页面或等。我认为这个问题是在浏览器引擎。也许有人知道什么花样?

About pending requests: it is not only about requests of video or audio files, it can be database connection or .html page or so on. I think the problem is in browser engine. Maybe anybody knows any tricks?

推荐答案

://$c$c.google.com/p/chromium/issues/detail ID = 234779 相对=nofollow> HTML5视频请求留未决(永远)这Chrome HTML5视频停止工作,如果太多的标签是开放的 - 内存问题我发现单页的应用程序(基于角框架,我的情况)的解决方案:需要重写视频标签的SRC ATTR并重新加载它,然后? - 从页面中删除。示例:

Mostly according to this HTML5 video request stay pending (forever) and this Chrome HTML5 Videos stop working if too many tabs are open - Memory issue? I found a solution for single page application (in my case based on angular framework): need to override src attr of video tag and reload it, and then - remove from page. Sample:

$('video').each(function() {
    $(this)[0].pause();
    $($(this)[0]).attr('src', "");
    $(this)[0].load();
    $(this)[0].remove();
});

或全code角形器:

$scope.$on('$destroy', function() {
    $('video').each(function() {
        $(this)[0].pause();
        $($(this)[0]).attr('src', "");
        $(this)[0].load();
        $(this)[0].remove();
    });
});

如果没有帮助,尝试所有的招数在这里Chrome HTML5视频停止工作,如果太多的标签是开放的 - 内存问题

If it doesn't help, try all tricks here Chrome HTML5 Videos stop working if too many tabs are open - Memory issue?

这篇关于在单页应用程序页面上的许多视频标签(角),使页面冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:51