KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to support resume on Jersey REST, I'm trying to do it this way: @Path("/helloworld") public class RestServer { @GET @Path("say") @Produces("audio/mp3") public Response getMessage(@HeaderParam("Range") String r ) throws IOException{ String str="/Users/dima/Music/crazy_town_-_butterfly.mp3"; System.out.println(r); RandomAccessFile f=new RandomAccessFile(str, "r"); int off=0; int to=(int)f.length(); byte[] data ; if(r!=null){ String from=r.split("=")[1].split("-")[0]; String t=r.split("=")[1].split("-")[1]; off=Integer.parseInt(from); to=Integer.parseInt(t); } data= new byte[to-off]; f.readFully(data, off, to-off); ResponseBuilder res=Response.ok(data) .header("Accept-Ranges","bytes") .header("Content-Range:", "bytes "+off+"-"+to+"/"+data.length) .header("Pragma", "no-cache");; if(r==null){ res=res.header("Content-Length", data.length); } f.close(); Response ans=res.build(); return ans; } } I want to be able stream mp3 so the browser can seek the music, but in safari it still not working. any ideas?
Tags (comma-separated)
Save Edits
Cancel