Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to play sound files from remote client in browser

 
Md Ibrahim
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Iam having this requirement, i have a sound file (.wav or .mp3) in my local machine which is referred in server-side java code
to play the sound using awt TOOLKIT, it works fine when running in my own local browser, but when accessed from another
m/c through web browser (internet) it wont work since sound file is in my server code and not in client's code.

Is there any better way to implement this, also the sound file should not be included directly in client code.
Please do reply whatever possibilities you know of?.

I doubt how all the music websites play sounds on entering the website (which is a remote client nothing but our browser)

I'm using JSF in front with java in server-side.

please please do reply back as it is some kind of urgent.

By
Ibrahim.
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a web application, the simplest method would be to serve the sound file as you would any other multi-media content and let the browser (and ultimately the user) decide how to deal with it. In the ServletsFaq there's an article on how to create an Image Servlet: http://faq.javaranch.com/java/ImageServlet. Although this was geared toward image files, the same principle is involved in sound files (just a different content-type header).

Of course, there are more advanced ways of doing this, including using flash or other players.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Md Ibrahim wrote:Hi all,

Iam having this requirement, i have a sound file (.wav or .mp3) in my local machine which is referred in server-side java code
to play the sound using awt TOOLKIT, it works fine when running in my own local browser, but when accessed from another
m/c through web browser (internet) it wont work since sound file is in my server code and not in client's code.

Is there any better way to implement this, also the sound file should not be included directly in client code.
Please do reply whatever possibilities you know of?.

I doubt how all the music websites play sounds on entering the website (which is a remote client nothing but our browser)

I'm using JSF in front with java in server-side.

please please do reply back as it is some kind of urgent.


turn up the volume on the server REALLY LOUD.

no, don't. When music sites do this, they do it through a player of some sort (flash, quicktime, even a java applet). Check out this page full of audio applets:
http://javaboutique.internet.com/audio/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic