Storing large file in chromecast memory

有些话、适合烂在心里 提交于 2019-12-04 22:51:58
ben

I'm a bit unsure about this answer because I find it a bit too obvious. But I'll give it a try:

You said you had no trouble with a setup where you download 28MB via ajax. Why don't you cut it down even further? You could for example go with 4MB. I'm suggesting this because it may alleviate problems arising from "bursts" of computation as you for example mentioned with reading the responseText field of the xhr object.

After you decided on an appropriate chunk size you could use http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-22#section-3 to download your video in parts and then concatenate it in javascript according to your needs. See also Download file in chunks in Chrome Javascript API?

If you have access to the server you could also split the file on the server side such that you can send requests from the client like so:

example.com/movies/my_movie.mp4?chunk=1

Try using an Application Cache manifest file to ensure that the file is only downloaded once:

<html manifest="some.manifest">

where some.manifest has the contents:

CACHE MANIFEST
# version 1.0
the_video_to_cache.webm

This will ensure that future HTTP requests for the resource will not cause download. The video will only re-download when the manifest file changes (so you can change the #-prefixed comment string to cause a re-download). Note that the new version will be shown on first page load after the download completes. After an update, the user will see an out-of-date video one time (while the new version downloads) and then see the new version on the next visit.

Note that this may not work if your video is larger that the permitted size of the app cache.

I'm don't have chromecast, and not sure. Is it possible to use experimental features, like Quota Management API? This API, could add some extra memory for you stored data, may be you should try to use it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!