Jump to content

[1.7.10][Connection] How to connect to an online radio and listen to it


_gjkf_

Recommended Posts

Hey everybody! As some of you recall, I'm making a mod that should allow the player to listen to the radio while playing. Now, I got to a point where I need a way to connect to the given URL.

 

I admit I have no idea on how to use Java to connect to the net. I looked into this: https://github.com/OpenMods/OpenBlocks/tree/master/src/main/java/openblocks/client/radio (OpenBlocks' way to do this) but it didn't really help me.

 

My mod can be found here: https://github.com/gjkf/HeadPhones-Radio

 

I have a gui with a "connect" button in it that should connect to the given URL and a key bind that will start and stop the transmission. My problem is how to actually connect to that URL and how to play the actual music.

 

I'm not asking for ready code, I'm asking for help, some code will be appreciated but I want to learn.

 

Thanks in advance.

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Link to comment
Share on other sites

Hey everybody! As some of you recall, I'm making a mod that should allow the player to listen to the radio while playing. Now, I got to a point where I need a way to connect to the given URL.

 

I admit I have no idea on how to use Java to connect to the net. I looked into this: https://github.com/OpenMods/OpenBlocks/tree/master/src/main/java/openblocks/client/radio (OpenBlocks' way to do this) but it didn't really help me.

 

My mod can be found here: https://github.com/gjkf/HeadPhones-Radio

 

I have a gui with a "connect" button in it that should connect to the given URL and a key bind that will start and stop the transmission. My problem is how to actually connect to that URL and how to play the actual music.

 

I'm not asking for ready code, I'm asking for help, some code will be appreciated but I want to learn.

 

Thanks in advance.

 

Do you know if this is possible, because if it is it would be a really cool mod

Link to comment
Share on other sites

I'm sure this is possible. If you have ever played with OpenBlocks, there's the radio that has some tuned crystal with stations configurable via config. As I said I tried using it but with no success.

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Link to comment
Share on other sites

Really nobody can help me?

 

Nobody knows how to do it. You would just have to understand the OpenBlocks code. If you cant, copy and paste the OpenBlocks code into your project and see what the output is. Oh, and if you dont know already, the OpenBlocks radio can only play certain radio stations

Link to comment
Share on other sites

Well I really don't have time to write a long reply as I only came to check something here but let me warn you this isn't something you should do if you need to ask the question on a board unrelated to it.

And yes, this is advanced base java, not minecraft forge code.

And sure, it is doable, afterall it is just a matter of connecting to the url, getting the stream and putting it through to the desired output(and a lot of other bits and pieces). Something which is easily explained however far less fun to do without a decent bit of experience in that particular field of programming.

 

I'll point you in the right direction but you'll need to do the rest mostly yourself.

First of all you have a perfect, well not perfect but decent enough to know how to do it, with that openblocks code.

'It didn't help me' is well... good luck getting any further with programming this radio.

Secondly, look into connecting to an url, and look into andriod based radios as those applications do that often.

 

As for ITzZ, you can set the stations in the config files of openblocks.

Secondly, the openblocks code uses a open source android class to do it so you can easily use it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.