Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  stream music with java  (Read 8247 times)
0 Members and 1 Guest are viewing this topic.
Offline pudelhund

Junior Newbie

« Posted 2012-03-22 07:44:07 »

I am currently coding some chat program and now want to play music via a client command like:


So the link would be send from the client that sent the song, to the server. The server should then without downloading the song, stream it to every client (they shouldn't download it as well). Problem is, I don't know how to stream mp3's over a TCP based connection.

My question is, if someone could provide me with libraries/tutorials/ideas/code examples of what I need.

As an alternative directly streaming music from one client's computer would be okay as well. If I (as a client) play a song on my machine (using some music player like VLC or similar) and then type a certain command (maybe /stream), the sounds from my soundcard would be streamed to the server and then to every client logged in.

It would be awesome if you could provide me with some advice for both, Google didn't really help so far, mainly because I don't quite understand what I should search for.

Thanks in advance!
Offline jimeowan

Junior Devvie

Medals: 1
Projects: 1

« Reply #1 - Posted 2012-03-22 10:04:27 »

The thing is there's no way you can broadcast music without downloading it. You can broadcast music while downloading it though, and that's what streaming is  Tongue

Now after some quick Googling I found a few leads for how to do it. For instance: points to two existing projects for hosting audio broadcasting servers.
Another common solution would be to use an independent broadcasting server (like IceCast) and make your server send data to it/control it.

One thing that you should consider though is: are you sure you want to use the server to broadcast sound? An alternative would be to simply broadcast the command, and let clients process it themselves.
On one hand using a server for the streaming is probably more flexible, as you can then easily add other sound-related commands without having to modify the clients, but on the other hand it might induce an important traffic.

Author of "The Little Scientist" (judging panel winner for Java4K 2012 </brag>)
Offline ra4king

JGO Kernel

Medals: 508
Projects: 3
Exp: 5 years

I'm the King!

« Reply #2 - Posted 2012-03-23 03:01:36 »

Well using an InputStream isn't that hard, just open a connection on the URL object and then feed the data to something that can translate MP3 to raw audio. If you want to use Java Sound, you'll have to Google around for a Java Sound MP3 SPI.

Pages: [1]
  ignore  |  Print  

EgonOlsen (39 views)
2018-06-10 19:43:48

EgonOlsen (21 views)
2018-06-10 19:43:44

EgonOlsen (41 views)
2018-06-10 19:43:20

DesertCoockie (187 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (862 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!