0

So I'm serving up an mp3 file using HttpServletResponse writing to a servlet output stream.

When I go to that location in the browser, the mp3 correctly loads up and starts playing, but unfortunately, isn't able to seek anywhere(I can't scroll through the song at all)

How do I fix this, or make it so the browser downloads the full song before it starts playing.

Thanks in advance.

dessalines
  • 6,352
  • 5
  • 42
  • 59

2 Answers2

0

You need to wrap it in an audio controls tag, assuming HTML5. See http://www.w3schools.com/html/html5_audio.asp for an example. Just replace the hardcoded mp3 with a call to your servlet.

John Kuhns
  • 506
  • 4
  • 20
0

You servlet must be able to respond to HTTP range requests, i.e. serve not the whole mp3 from start, but also subparts.

Take a look at this thread for further information. It links to page which shows how to implement support for http range and other important headers.

EDIT: corrected URL

wero
  • 32,544
  • 3
  • 59
  • 84
  • That seems to only be information about client-side. Does that mean that my servlet is working correctly, and going to that URL shouldn't allow seeking? – dessalines Jun 19 '15 at 17:50
  • sorry, wrong URL, edited and entered a different. But just google "http range" for lots of information. – wero Jun 19 '15 at 19:40