开发者

Use JQuery/JS to eagerly load a bunch of MIDI file URls and cache them to be played on demand

Is it possible to have a webpage where on buttonClick, JQuery goes fetches a certain few URLs to MIDI files, and instead of them playing automatically, they are played on demand ?

<a href="bach.mid">Bach</a>
<a href="beethoven.mid">Beethoven</a>

I want to be able to eagerly fetch开发者_如何学编程 them into an array of objects and play them on demand.

 midis[0].play// or something like that


Assuming those MIDI files are static content, you can set the cache-control of those files to private in the hosting environment to make them able to cache in the browser local file cache once downloaded.

Make an array with the name of the MIDI files and just loop through them with AJAX code to download / pre-load them (no special code is needed, just download) before you need to play them. Since the MIDI would be in the browser cache after you pre-load them, you should be able to play them when you need to. The browser will be smart enough to pick up those files from the file cache (if the cache is cleared by the user, it will download it again from the server).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜