Tuesday 15 September 2015

javascript - How can I make 2 audio elements in succession, but make just 1 request for the audio? -


I have a large audio file that I want to load once on a web page, but I have 2 audio in javascript Tag object:

  var audio tag 1 = new audio (); Var audio tag 2 = new audio (); Audio 1. Src = 'huge file MP3; Audio 1. Src = 'huge file MP3;  

How do I make a request to a browser? I know the files are cached, but I suspect that the browser has to cache any of the 2 requests, because the feedback headers for the first request have not come at the time of issuing the second request. This means that the programmatic and cache control headers are not read by the browser.

Is there a way to tell the browser, "Once request this data, and exclude 2 audio tags?" 2 instead of issuing the request?

I think I can create an audio bob and then create an object url? Maybe it's too much over land for easy work?

  var audio tag 1 = new audio (); Var audio tag 2 = new audio (); AudioTag1.src = 'huge file MP3 ;; AudioTag1.addEventListener ("Load", function () {console.log ('Audio 1 Ready'); AudioTag 2.src = 'hugeFile.mp3'; audioTag2.load ();}); AudioTag2.addEventListener ("Load", function () {console.log ('Audio 2 Ready');}); AudioTag1.load ();  

Not tested, but it is sure that on the second request, the browser will check the cache and the file will be fully loaded


No comments:

Post a Comment