[Tutorial] Music streaming system - 8 genres
#1

Hello everyone, well this is my first released script you can use.
I did this just now, and thought I could share it with you, since It can be helpful to some people.
So, you'll need to put these codes into your script for them to work.
This includes 8 types of music, which you can change the link of, of course.( PS: All songs go back to their respected owners, this is just a stream, just like streaming from the website itself.
If this causes any trouble, I kindly ask administrators to remove the URLs "if this causes any trouble." )


------------------------------------------------------------------------------------------------


So first of all, let's create the command which pops up a dialog for us to choose from.

The code is:
PHP Code:
CMD:radio(playeridparams[])
{
ShowPlayerDialog(playerid1499DIALOG_STYLE_LIST"Choose any type of music!"">Dubstep\n>Blues\n>Metal\n>Jazz\n>POP\n>R&B\n>Rock\n>Country\n>>Stop Stream""Choose""Cancel");
return 
1;

Let's explain it a bit.
First of all, we're popping up a dialog for the player which types the command: /radio.
He will find 8 genres of music from which he will chose and click on.
It will show up for him in the shape of a list.

But this ain't enough, we must put OnDialogReponse for this to work, else nothing will appear when he chooses one.

Now let's move on to OnDialogResponse, we got this code:
PHP Code:
if(dialogid ==1499)
{
    if(
response)
    {
            if(
listitem==0)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=40568");
            
GameTextForPlayer(playerid"~r~Dubstep ~g~on"30001);
            }
            if(
listitem==1)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=1270282");
            
GameTextForPlayer(playerid"~r~Blues ~g~on"30001);
            }
            if(
listitem==2)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=212870");
            
GameTextForPlayer(playerid"~r~Metal ~g~on"30001);
            }
            if(
listitem==3)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=86433");
            
GameTextForPlayer(playerid"~r~Jazz ~g~on"30001);
            }
            if(
listitem==4)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=203280");
            
GameTextForPlayer(playerid"~r~pop ~g~on"30001);
            }
            if(
listitem==5)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=139386");
            
GameTextForPlayer(playerid"~r~R&B ~g~on"30001);
            }
            if(
listitem==6)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=19275");
            
GameTextForPlayer(playerid"~r~Rock ~g~on"30001);
            }
            if(
listitem==7)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=109008");
            
GameTextForPlayer(playerid"~r~Country ~g~on"30001);
            }
            if(
listitem==8)
            {
            
StopAudioStreamForPlayer(playerid);
            
GameTextForPlayer(playerid"~g~Music ~r~off"30001);
            }
    }

Now let's explain it a bit.
First we got the :

PHP Code:
if(dialogid ==1499)
{
    if(
response)
    { 
This is used to define that we're working on the dialogid 1499 which we used before when making the /radio command.
Now, we put if(response) to show that "If player chooses an item from the list".
Next we got the:
PHP Code:
if(listitem==0)
            {
            
PlayAudioStreamForPlayer(playerid"http://yp.shoutcast.com/sbin/tunein-station.pls?id=40568");
            
GameTextForPlayer(playerid"~r~Dubstep ~g~on"30001);
            } 
This means that if he chooses the first item in the list, an audio stream will play for player, with the above link.
A small text on the bottom right of the screen will appear saying: Dubstep On for 3 seconds.


The same goes for the other ones.
At last, we got the last item of the list:
PHP Code:
if(listitem==8)
            {
            
StopAudioStreamForPlayer(playerid);
            
GameTextForPlayer(playerid"~g~Music ~r~off"30001);
            } 
As we put in the dialog, the last one was :Stop Stream.
Now behind that, we got this code.
So if player chooses that from the list, it will "StopAudioStreamForPlayer", which means stop playing the music, aswell as show him a text saying: Music off.
Put all this code under OnDialogResponse and it should work properly.

---------------------------------------------------------------------------------------------------

Anyway, hope this helped guys, this is my first tutorial.. If I helped you, leave some positive feedback and if you need more tutorials which I know how to do, I will surely make them for you guys.

Thanks again!
Reply
#2

wow !
this is awesome , i have used this on my server ! and it is all working fine !!!
all my players loved it

You are awesome ! i really love all your work !
Reply
#3

Please give me a link to add music i'm try this web mp3.zing.vn but it not work. Sorry for my bad english.
Reply
#4

Okay sure, use shoutcast.com and chose any genre of music, and copy the URL from it.
And please rep+ me if I helped you
Reply
#5

But shoucast.com does have my favorite song like day light or payphone or some thing just the boring song. i need the link can search song
Reply
#6

Alright what you need to do is the following:
1-Go to ****** and search for your song, and put Free download near it.
2-Get the link of the song and you can use it in PlayAudioStreamForPlayer.

Or the second way is:
1-Upload your song on some website.
2-Get the link of the song and use it just like before.


Hope this helped!
Reply
#7

Quote:
Originally Posted by JimmyCh
View Post
Alright what you need to do is the following:
1-Go to ****** and search for your song, and put Free download near it.
2-Get the link of the song and you can use it in PlayAudioStreamForPlayer.

Or the second way is:
1-Upload your song on some website.
2-Get the link of the song and use it just like before.


Hope this helped you, rep+ me if I did
Thanks i rep+ you
Reply
#8

No problem, any time.
Reply
#9

it will be better if you the website to get a radio stations ok
well nice
Reply
#10

What do you mean exactly? Well feel free to change the URL to anything you want, but I found that shoutcast would be great for streaming so I used it.
And thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)