Sending ,receiving and playing mp3 through socket
Hi. I'm trying make this program. My server takes an mp3 file, breaks it into byteArray, then send it through socket, recive it with client and finaly play it. Now, I read on this forum that java doesn't support mp3 directly, so instead of mp3, let's say that it does it to an audio file.
I have no idea were to start, and since non of my mentors can't help me becausethey don't really know about it more than I do, and this is my project and I will get a grade for it, I realy need your help...
Message was edited by:
baneizalfe
# 1
Unfortanetly the JRE does not support MP3 directly. You can use the MP3 decoder from Tritonus www.tritonus.org or from Java Media Framework http://java.sun.com/products/java-media/jmf/
Here are same example lines using package javax.sound.sampled
for a client player:
I suggest that you try it first with an WAV audio file instead of a socket stream:
// First get the audio stream:
AudioInputStream ais=Audiosystem.getAudioInputStream(new File("audio.wav"));
// Get a clip
Clip clip=AudioSystem.getClip();
// open an audio line
clip.open(ais);
// start playing
clip.start();
// drain the audio line
clip.drain();
clip.close();
For transfer via socket connection you use the InputStream of the socket instead of the file.
Important JavaSound link: http://jsresources.org/
Good luck !
Klaus