• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

Streaming Music from a servlet

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

hope someone can help a greenhorn and comes up with a good suggestion...
What I want to do is to make a music stream which can be controlled by the frontend.

The Servlet is reading the audio file (at the moment it is one on continuous loop) and streaming the data to the client. The Servlet is used as source in a HTML5 audio element.

This works so far just like a radio stream would work.

What I have doubts about is the way of controlling the streaming. I have a play and pause button which set the playback mode in a session bean and the Servlet should check the status of that session bean to pause and continue the stream. Of course, this isn't synchronized, so the Servlet already pumped out hundreds of MB by the time would be able to click on pause which would keep on playing on the client side.

Apart from that, I am continuously checking the session bean for changes by calling new InitialContext().lookup("java:module/PlayControl") when the servlet is handling the request and then checking for the properties. But I have a feeling that the actions performed on the frontend and the bean queried by the Servlet are two different ones.

Frontend code:




1. Do you see what is wrong with the communication between Frontend - Bean - Servlet?
2. How would you go about exercising control over the stream? I thought slowing the buffering down to a rate that would be appropriate for the songs bitrate might help...

Thanks for your input!

Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot check your code right now. But I think you might be interested in using Java Media APIs
You got style baby! More than this tiny ad:
Enterprise-grade Excel API for Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!