• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Streaming Music from a servlet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

faces-config.xml:


Bean-Code:


Servlet-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!

Robert
 
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot check your code right now. But I think you might be interested in using Java Media APIs
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic