954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Creating a media player in Java

I had this crazy idea of creating a media player using java that would stream files from from my desktop computer, which I would set up some sort of server app for, and talk to a portable client app that I could download on any of the other computers on campus. This way I can always have my music playing without having to have my ipod. I just had a question of where should I start? I know a little about networking, I have created a simple instant messenger but that is about it. I don't know what class I need to implement to transfer songs, rather than text like in my instant messenger. What are some good ideas?

dragon99x
Newbie Poster
2 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

This is usually the first site I point people to when they want to make a java music player.
http://www.javazoom.net/index.shtml

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 
This is usually the first site I point people to when they want to make a java music player. http://www.javazoom.net/index.shtml

Actually I already have downloaded the javazoom classes and that works perfectly but I am contemplating how to go about streaming the music files from my desktop. I been reading the FileReader class api but I still can't tell which classes I SHOULD use to get it to work.

dragon99x
Newbie Poster
2 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

I know the javazoom packages will allow you to listen to a stream, but I haven't dealt with actually creating the stream itself (though I been meaning to do so). I know it'll connect to ice/shoutcast streams, so maybe that's something to look at.

This should play a stream:

BasicPlayer player = new BasicPlayer();

URL url = new URL("http://205.188.215.225:8018");

AudioFileFormat aff = AudioSystem.getAUdioFileFormat(url);

if (aff instanceof TAudioFileFormat)
{
	Map props ((TAudioFileFormat)aff).properties();
	String title = (String)props.get("mp3.shoutcast.metadata.icy-name");
	String sUrl = (String)props.get("mp3.shoutcast.metadata.icy-url");
	String genre = (String)props.get("mp3.shoutcast.metadata.icy-genre");
	String bitrate = (String)props.get("mp3.shoutcast.metadata.icy-br");

	player.open(url);
	player.play();
}


How you stream the song from your own computer I'm not sure. You might need to run an icecast server.

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You