java - Browser treating real file differently than servlet-generated file -
I use HTML 5, the user has an application to go to listen to some audio samples on the server. If I specify the path to an actual audio file on the server, things work as expected: However, if I point out that a resource actually generates an audio file that is servlet, audio does not seem to play: I have confirmed that this servlet writes the required audio file; I downloaded and played it straight back and I have typed the reaction material on audio / mpeg and audio / x-mpeg but there is no dice. Do I have some other headings to work on this? Thanks for any help. @requestmapping (value = "/ dbAudio", method = RequestMethod.GET) Public Zero getAudioFromDB (HttpServletRequest request, HttpServletResponse response) exception {response.setContentType ("audio throws / MPEG"); // Next uncommenting allows me to download resources directly and confirm this // // This is a well-formed audio file // response.setHeader ("content-nature", "attachment; filename = banana.mp3 ") is; Outputstream o = response .getoutputstream (); Resource r = ctx.getResources ("/ audio / english / banana_1.mp3") [0]; InputStream s = r.getInputStream (); Int chuck = 0; While (true) {chuck = s.read (); Break if (piece == -1); O.write (part); } O.flush (); }
& lt; Audio src = "/ audio / English / banana_1.mp3" control & gt; Your browser & lt; Code & gt; Audio & lt; / Code & gt; Does not support element & Lt; / Audio & gt;
& Lt; Audio src = "/ app / db audio" control & gt; Your browser & lt; Code & gt; Audio & lt; / Code & gt; Does not support element & Lt; / Audio & gt;
Try this.
Comments
Post a Comment