简体   繁体   English

如何在后台HTML5 / JS中下载视频

[英]How to download video in background HTML5 / JS

Is there a way to make a video download in the background (Possible on a different thread?) than I get my images and do webrequests? 有没有一种方法可以在后台进行视频下载(可能在不同的线程上?),而不是获取图像并进行Web请求?

Situation: 情况:

I show a video, video plays fine. 我显示一个视频,视频播放正常。 But, once I start getting 2 images at the same time from that server, the page won't response and will wait for my video to have finished loading, then it loads the images within a few seconds. 但是,一旦我开始同时从该服务器获取2张图像,该页面将不会响应,并且将等待我的视频加载完成,然后在几秒钟内加载图像。 (about 100kb per image). (每张图片约100kb)。

If I try to open any other page on the same browser and the crashed page's server it won't load untill the crashed page is done loading, however any other site(For example google) will just load fine. 如果我尝试在同一浏览器和崩溃页面的服务器上打开任何其他页面,则直到崩溃页面完成加载后才加载,但是其他任何网站(例如google)也可以正常加载。

So is there a way to make the browser not want to download full video, or maybe just give priority to images? 那么,有没有一种方法可以使浏览器不想下载完整的视频,或者只是优先考虑图像?

This sounds like the server throttling your requests, as everything apart from scripts always load asynchronously in a browser. 这听起来像服务器在限制您的请求,因为除脚本之外的所有内容始终都异步加载到浏览器中。

It might be that you are only allowed so much bandwidth per second from the server - or so many connections - and that could be the reason why the server won't respond until your first request has finished. 可能是服务器每秒仅允许您这么多的带宽-或那么多的连接-这可能是服务器直到您的第一个请求完成后才响应的原因。

Check your server configuration and perhaps have a play with it to exclude this possibility. 检查您的服务器配置,也许可以尝试一下以排除这种可能性。

Maybe you can try a worker, it provides a way to execute background scripts (you will have to split your video and images in separate files), as you can see in the Use Cases it refers to "Prefetching and/or caching data for later use" as a possible scenario. 也许您可以尝试一个工作程序,它提供了一种执行后台脚本的方法(您必须将视频和图像拆分为单独的文件),如在用例中所看到的,它指的是“预取和/或缓存数据以供以后使用”使用”作为可能的方案。 Hope it helps. 希望能帮助到你。

More info here: 更多信息在这里:

http://www.html5rocks.com/en/tutorials/workers/basics/#toc-examples http://www.html5rocks.com/en/tutorials/workers/basics/#toc-examples

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM