[Tutorial] Audio Stream (Part 1)(For Beginners)
#1

Hello,

Today I'm going to teach you about some audio stream functions you can use.

Audio Stream was here way before but you needed a special AudioClient to actually receive the audio client client side but since 0.3d Kalcor and his team has implemented AudioClient inside the SA-MP client itself.

So here we go.

What functions is there for the Audio Stream? There is plenty of functions for different kind of usage

Let's work on "PlayAudioStreamForPlayer" for example. Basically what this function do is that it Plays a Stream it could be a radio.pls or even a song.mp3. But this will play it for the player only that calls the functions.



Let's do a simple command with it

pawn Код:
CMD:play(playerid, params[])
{
       PlayAudioStreamForPlayer(playerid, "play.pls"); // Basically this will play the URL Given to the player
}
And if you wish to stop the Stream you will use the function StopAudioStreamForPlayer(playerid);

You can even use the PlayAudioStreamForPlayer with floats so further you go where you started the stream less you will hear the music or sound


Let's do a quick example
pawn Код:
CMD:play2(playerid, params[])
{    
       new Float:X, Float:Y, Float:Z, Float:Distance = 5.0; // Basically the Distance is the range of the sound/music
       GetPlayerPos(playerid, X, Y, Z); // This will get the player Position to set the AudioStream
       PlayAudioStreamForPlayer(playerid, "test.pls");
       return 1;
}
I hope you learned a little about AudioStream and hope to see you read my Part 2 that will be with OnPlayerStateChange and other features.
Reply
#2

do we need includes / plugins / or filterscripts?
Reply
#3

Quote:
Originally Posted by the_zohan
Посмотреть сообщение
do we need includes / plugins / or filterscripts?
Quote:
Originally Posted by ViruZz
Посмотреть сообщение
Audio Stream was here way before but you needed a special AudioClient to actually receive the audio client client side but since 0.3d Kalcor and his team has implemented AudioClient inside the SA-MP client itself.
Can't you read?

https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer
Reply
#4

ok but where should i place my test.pls file?
Reply
#5

Quote:
Originally Posted by the_zohan
Посмотреть сообщение
ok but where should i place my test.pls file?
Wait. You don't get it, that's why I gave you the link to the PlayAudioStreamForPlayer wiki.

pawn Код:
PlayAudioStreamForPlayer(playerid, url[]);
as you see the second parameter is url[]. I guess you know what is a url.

Here is an example taken from SA-MP wiki.

pawn Код:
PlayAudioStreamForPlayer(playerid, "http://somafm.com/tags.pls");
You don't need to place anything anywhere if you mean about music files. The only thing you have to do is find a url of a radio song you want and paste it to this function. The rest, you know.

EDIT:

Also ViruZz make a command witch stops the AudioStream to show newbies how actually it works. Other than that nice and simple tutorial for newbies. Keep it up!
Reply
#6

so u mean i should make a filterscript and add this command

CMDlay(playerid, params[])
{
PlayAudioStreamForPlayer(playerid, "play.pls"); // Basically this will play the URL Given to the player
}

and then go in game and play?
Reply
#7

Quote:
Originally Posted by the_zohan
Посмотреть сообщение
so u mean i should make a filterscript and add this command

CMDlay(playerid, params[])
{
PlayAudioStreamForPlayer(playerid, "play.pls");
}

and then go in game and play?
Read of what I said before. play.pls is just an example.

pawn Код:
CMD:play(playerid, params[])
{      
    PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls");
    return 1;
}

Please use [pawn] [ /pawn] tags next time whenever your gonna share any code.
Reply
#8

Quote:
Originally Posted by the_zohan
Посмотреть сообщение
so u mean i should make a filterscript and add this command

CMDlay(playerid, params[])
{
PlayAudioStreamForPlayer(playerid, "play.pls"); // Basically this will play the URL Given to the player
}

and then go in game and play?
No. Replace "play.pls" to your direct audio link. Here, I'll show you how to get direct link for PlayAudioStreamForPlayer.
1) Go ro kiwi6.com
2) Click Browse and find your .mp3 file then click Save(or Open)
3) Click Start upload and wait for a few minutes.
4) Click at the "Saved" link and copy Direct hotlink.
5) Now replace "play.pls" with your direct link. Example
pawn Код:
PlayAudioStreamForPlayer(playerid,"http://k005.kiwi6.com/hotlink/egvkrzxjlx/eminen_like_toy_soldiers.mp3");
Reply
#9

"Part 1"?
What else you will include in part 2?
You said everything about audio stream in this topic
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)