wood burning stoves 2.0*
The moose likes Java in General and the fly likes How to play sound files from remote client in browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to play sound files from remote client in browser" Watch "How to play sound files from remote client in browser" New topic
Author

How to play sound files from remote client in browser

Md Ibrahim
Greenhorn

Joined: Mar 24, 2010
Posts: 14
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

Joined: Apr 01, 2009
Posts: 643
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

Joined: Apr 30, 2003
Posts: 820

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/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to play sound files from remote client in browser
 
Similar Threads
Uploading File??
How to unzip a file on a remote unix server using java
Running a RMI Application
RMI Stubs
Sound in Servlet