a continuous data is added to the audioService. I see it sent like this but no sound is playing. f12 dev tools.
@GetMapping(value = "/audio/live/{id}") public StreamingResponseBody liveAudio(HttpServletRequest request, @PathVariable("id") String id) { return new StreamingResponseBody() { @Override public void writeTo(OutputStream out) throws IOException { try { try { byte[] audioBytes = audioService.getAudio(id); out.write(MyAudioUtil.convertWav(audioBytes).toByteArray()); out.flush(); } catch (InterruptedException | CloseNowException | ClientAbortException exc) { //ignore these exceptions return; } out.close(); } catch (Exception e) { LOGGER.error("blabblablab", e); return; } } //} }; } 21 Answer
Add Jlayer to your dependency. on gradle
implementation group: 'javazoom', name: 'jlayer', version: '1.0.1' on maven
<dependency> <groupId>javazoom</groupId> <artifactId>jlayer</artifactId> <version>1.0.1</version> </dependency> After adding jlayer, read your input and play with jlayer
BufferedInputStream inputStream = new BufferedInputStream(new ByteArrayInputStream(audioBytes.toByteArray())); Player player = new Player(inputStream); //player from jplayer player.play(); 2