Quantcast

Jump to content

» «
Photo

Custom Radio Stations?

8 replies to this topic
sovietbacon
  • sovietbacon

    Player Hater

  • Members
  • Joined: 11 Aug 2013

#1

Posted 11 August 2013 - 08:01 PM

All right, here's what I want to do. I want to add spotify into GTA IV's car radio system. So instead of having to use independence fm, you can just go to another channel, say spotify fm. After it prompting you for login details you could go into some bootleg menu or something and choose what playlist/songs/internet radio you want it to play.

Spotify has a C library and I see that GTA IV has a C++ script hook thing. I'm brand new to all of this, but I know a TINY bit of C++. Is there a way I could go about adding this? I saw an internet radio mod, but you had to manually add streams from other services with urls and whatnot. I would assume that that would work similarly, but I can't just go peeking at the source code of that, and the mod didn't add/replace car radios. I noticed it used the .net script hook though, and from googling I noticed that the .net is based off the C++ one. So, here's a list of what I would need to know:
  • making a new car radio station
  • Playing a .mp3 or other audio file through that station.

Once I know how to do that, I think I can figure things out on my own. So far, searching hasn't lead me very far.

Libspotify link: https://developer.sp...ies/libspotify/

LuigiPeace
  • LuigiPeace

    Player Hater

  • Members
  • Joined: 02 Aug 2013

#2

Posted 16 August 2013 - 04:21 PM

Perhaps you can "simply" (using script with C++/.NET ScriptHook) display your menu and choose your playlist/songs/internet radio (with Spotify API) and then stream it in a mp3 file which must be located in the directory of custom music, and so when you go on Independence FM and (if you active Spotify) it would play the streamed mp3 file... But I'm really not sure if it could works or not...

But stream Spotify in mp3 file which should be located in a .rpf file for your custom radio station seems even more difficult (that's what I think)...

sovietbacon
  • sovietbacon

    Player Hater

  • Members
  • Joined: 11 Aug 2013

#3

Posted 17 August 2013 - 04:29 AM

Thanks for the reply. i agree, after looking into what you said (as I said I'm new to GTA modding, had no clue about .rpf files), I would have to be constantly writing/erasing crap to those rpf files and idk if I can do that with my set of skills.

Thanks for the response, btw.

LuigiPeace
  • LuigiPeace

    Player Hater

  • Members
  • Joined: 02 Aug 2013

#4

Posted 17 August 2013 - 10:06 AM

But even if you have the skills for, I don't know if it could works... If you set the game to allow modding, I'm not sure if writing into this .rpf file would be allowed by the game and don't cause a bug or crash the game !

I think using Independence FM is perhaps possible and here how I see it :

In your asi script made in C++ :
> you create a menu which get displayed to the player when he selects the Independence FM
- this menu allows you to set your playlist/songs/internet radio
- to enable/disable Spotify (this mod in a way)
> when the radio is selected and Spotify is on and settings are good you can
- get stream of Spotify (with Spotify API)
- output this stream into an mp3 file which would be located in the directory "User Music". (Then Independence FM should play this mp3 by it self ^^)

Bonus, to be sure the radio station won't switch to another sound (like radio presenter speech sound) :
> If a native function allow to force only mp3 in "User Music" directory to be played then you could implement this too...

If you accept this way to do, I suggest you to start by understanding how Spotify API works (if you don't no yet) because if you can't do what you want to do with your not going anywhere for this mod.
Then when you do so, you have to be able to ouput this stream into a mp3 file. When you know how works those two things and you're able to "play" with them without problems, then you can made your mod ^^ Because the menu is easier to made than the Spotify part wink.gif

Before anything, I'm going to stream an internet radio into a mp3 file in User Music (with VLC), at least to check if the radio station in the game will play the streamed mp3 file without problem, because if don't, everything above is good to be put in the trash...

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#5

Posted 17 August 2013 - 02:04 PM

QUOTE (LuigiPeace @ Saturday, Aug 17 2013, 10:06)
But even if you have the skills for, I don't know if it could works... If you set the game to allow modding, I'm not sure if writing into this .rpf file would be allowed by the game and don't cause a bug or crash the game !

I think using Independence FM is perhaps possible and here how I see it :

In your asi script made in C++ :
> you create a menu which get displayed to the player when he selects the Independence FM
- this menu allows you to set your playlist/songs/internet radio
- to enable/disable Spotify (this mod in a way)
> when the radio is selected and Spotify is on and settings are good you can
- get stream of Spotify (with Spotify API)
- output this stream into an mp3 file which would be located in the directory "User Music". (Then Independence FM should play this mp3 by it self ^^)

Bonus, to be sure the radio station won't switch to another sound (like radio presenter speech sound) :
> If a native function allow to force only mp3 in "User Music" directory to be played then you could implement this too...

If you accept this way to do, I suggest you to start by understanding how Spotify API works (if you don't no yet) because if you can't do what you want to do with your not going anywhere for this mod.
Then when you do so, you have to be able to ouput this stream into a mp3 file. When you know how works those two things and you're able to "play" with them without problems, then you can made your mod ^^ Because the menu is easier to made than the Spotify part wink.gif

Before anything, I'm going to stream an internet radio into a mp3 file in User Music (with VLC), at least to check if the radio station in the game will play the streamed mp3 file without problem, because if don't, everything above is good to be put in the trash...

I think you are missing a big point here. GTA (as far as I know) won't automatically load the mp3 files from the User Music directory, you must either enter the pause menu and reload them or restar the game. But what exactly is wrong with streaming? I have no idea what the spotify API does and how, but I would be amazed if there wasn't an audio stream. The only hassle is the selection of a specific radio in game, once that is done you just need to start reading spotify audio stream.

Anyway, maybe I'm completly wrong about the spotify API and that is not a possiblity, which I would be amazed with.

LuigiPeace
  • LuigiPeace

    Player Hater

  • Members
  • Joined: 02 Aug 2013

#6

Posted 17 August 2013 - 04:50 PM

Maybe with the automatic scan : it could load the mp3 without getting back on the pause menu...
Streaming means you write in the file as data are downloaded. So is the game able to load this way the mp3 ? I'm not sure about the difference between an existing mp3 file and a mp3 file that is streamed... but I think this way won't work.

Or you programmatically use Windows API to play the audio stream you selected. This way you don't have to deal with radio station & streaming file.

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#7

Posted 18 August 2013 - 12:00 AM Edited by pedro2555, 18 August 2013 - 12:06 AM.

QUOTE (LuigiPeace @ Saturday, Aug 17 2013, 16:50)
Maybe with the automatic scan : it could load the mp3 without getting back on the pause menu...
Streaming means you write in the file as data are downloaded. So is the game able to load this way the mp3 ? I'm not sure about the difference between an existing mp3 file and a mp3 file that is streamed... but I think this way won't work.

Or you programmatically use Windows API to play the audio stream you selected. This way you don't have to deal with radio station & streaming file.

I think you are complicating the process by having GTA load the music, that is not needed. What you need is the music playing, if it is from GTA or any other software it does not matter, as long as it works correctly for the end user. The best practice would be your mod playing the music, not GTA. GTA has better stuff to do and your mod only needs to play an audio stream.

Streaming works the same way as playing an MP3 file. But instead of reading a stream of bytes from the HDD to RAM, you read a stream of bytes from the network card to RAM.

I've found this super cool project at codeplex.com that may help you getting started, libspotifydotnet.codeplex.com.

Try to make a simple player first, I think you are missing a lot of concepts on this.

LuigiPeace
  • LuigiPeace

    Player Hater

  • Members
  • Joined: 02 Aug 2013

#8

Posted 18 August 2013 - 12:37 PM

QUOTE (pedro2555 @ Sunday, Aug 18 2013, 00:00)
I think you are complicating the process by having GTA load the music, that is not needed. What you need is the music playing, if it is from GTA or any other software it does not matter, as long as it works correctly for the end user. The best practice would be your mod playing the music, not GTA. GTA has better stuff to do and your mod only needs to play an audio stream.

Streaming works the same way as playing an MP3 file. But instead of reading a stream of bytes from the HDD to RAM, you read a stream of bytes from the network card to RAM.

I've found this super cool project at codeplex.com that may help you getting started, libspotifydotnet.codeplex.com.

Try to make a simple player first, I think you are missing a lot of concepts on this.


Yes, that's why I finally wrote :
QUOTE (LuigiPeace @ Saturday, Aug 17 2013, 16:50)
Or you programmatically use Windows API to play the audio stream you selected.

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#9

Posted 18 August 2013 - 05:37 PM

QUOTE (LuigiPeace @ Sunday, Aug 18 2013, 12:37)
QUOTE (pedro2555 @ Sunday, Aug 18 2013, 00:00)
I think you are complicating the process by having GTA load the music, that is not needed. What you need is the music playing, if it is from GTA or any other software it does not matter, as long as it works correctly for the end user. The best practice would be your mod playing the music, not GTA. GTA has better stuff to do and your mod only needs to play an audio stream.

Streaming works the same way as playing an MP3 file. But instead of reading a stream of bytes from the HDD to RAM, you read a stream of bytes from the network card to RAM.

I've found this super cool project at codeplex.com that may help you getting started, libspotifydotnet.codeplex.com.

Try to make a simple player first, I think you are missing a lot of concepts on this.


Yes, that's why I finally wrote :
QUOTE (LuigiPeace @ Saturday, Aug 17 2013, 16:50)
Or you programmatically use Windows API to play the audio stream you selected.

Hands on it. Bad luck Spotfiy isn't available in Africa. Stupid non-sense copyrights, they would have earned so many money here. I live in a flighty rich oil country... $0.60 a liter of petrol biggrin.gif




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users