Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Streaming Music from a servlet  RSS feed

 
Robert Drescher
Greenhorn
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:

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
 
Palak Mathur
Ranch Hand
Posts: 343
IntelliJ IDE Java Spring
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!