Results 1 to 1 of 1
  1. #1
    nicocannon is offline Member
    Join Date
    Dec 2014
    Rep Power

    Question Allow seeking through streaming mp3 file

    I am making a web app that allows you to stream music content. I am able to stream the song and seek forward but as soon I seek before the current position it just stops playing. Weirdly testing this in the eclipse EE internal browser it allows seeking forward and backwards and the same with microsoft edge. This is only happening with chrome!

    Here is my servlet code:
    Java Code:
    	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		String songName = request.getParameter("SongName");
    		songName = songName.replace("'", "");
    		FileInputStream in = null;
    		ServletOutputStream out = null;
    		//int position = (int) request.getAttribute("Pos");
    		try {
    			File mp3 = new File(getServletContext().getRealPath(songName + ".mp3"));
    			in = new FileInputStream(mp3);
    			out = response.getOutputStream();
    			//set Headers
    			response.setContentLength((int) mp3.length());
    			response.setHeader("Accept-Ranges", "bytes");
    			byte[] data = new byte[(int) mp3.length()];
    		} catch (Exception e) {
    		} finally {
    			if (in != null) {
    			if (out != null) {
    This is the html file calling this servlet:
    Java Code:
    <!DOCTYPE html>
    		var position = document.getElementById('myAudio').currentTime;
    		<audio controls id="myAudio">
    			<source src="GetSong?SongName=Core" type="audio/mpeg">

    I have also noticed this error when testing the code:

    ClientAbortException: Software caused connection abort: socket write error


    ClientAbortException: Connection reset by peer: socket write error
    Last edited by nicocannon; 08-30-2015 at 10:42 AM.

Similar Threads

  1. Seeking talented Java Developer
    By eXoSea in forum Jobs Discussion
    Replies: 0
    Last Post: 10-10-2013, 06:21 AM
  2. Seeking Lucene Consultant
    By evedk in forum Jobs Offered
    Replies: 0
    Last Post: 07-28-2012, 08:21 PM
  3. File Streaming in Java
    By Haroogan in forum Advanced Java
    Replies: 0
    Last Post: 01-18-2011, 09:57 PM
  4. seeking advice on using paintImmediately()
    By gib65 in forum AWT / Swing
    Replies: 1
    Last Post: 06-28-2010, 06:33 PM
  5. streaming mp3
    By arnab321 in forum CLDC and MIDP
    Replies: 1
    Last Post: 10-11-2008, 04:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts