How to repeat audio
#1

hi all...

how to repeat PlayAudioStreamForPlayer automatically?
Reply
#2

As far as I know, unless you're using an audio plugin, which unfortunately requires your players to be using the plugin too, you'll have to loop the audio with a timer.
Reply
#3

return 1;

[I think]
Reply
#4

pawn Код:
forward MusicTimer(playerid);
public MusicTimer(playerid)
{
//code to play music
return 1;
}
then add settimer stuff (i forgot the syntax lel)
Reply
#5

It isn't possible to perfectly time it because clients with slower Internet connections load the initial stream more slowly.
Reply
#6

You can use a Timer.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
It isn't possible to perfectly time it because clients with slower Internet connections load the initial stream more slowly.
indeed...

that's why i asked it here, if i use timer, it will cut the duration song for the player with slow internet connection.
but in some server, it's repeated perfectly, without giving a client message ("streaming audio" thingy). i want to know what did they use.

Quote:
Originally Posted by ShinichiKudou
Посмотреть сообщение
pawn Код:
forward MusicTimer(playerid);
public MusicTimer(playerid)
{
//code to play music
return 1;
}
then add settimer stuff (i forgot the syntax lel)
i know how to make a function --_-- and using timer isn't a good choice. becouse some player have a slow internet connection.
Reply
#8

Maybe:

pawn Код:
enum SongEnum
{
    LongSong,
    Seconds,
    UrlSong[128],
};
new SongInfo[MAX_PLAYERS][SongEnum];

stock StopMusicEx(playerid)
{
    SongInfo[playerid][LongSong] = -1;
    StopAudioStreamForPlayer(playerid);
    return 0;
}

stock PlayMusicEx(playerid, str[], longsong)
{
    strmid(SongInfo[playerid][UrlSong], str, 0, 128, 128);
    PlayAudioStreamForPlayer(playerid, SongInfo[playerid][UrlSong]);
    SongInfo[playerid][Seconds] = longsong;
    SongInfo[playerid][LongSong] = gettime()+SongInfo[playerid][Seconds];
    return 1;
}

forward RepeatSong(); public RepeatSong()
{
    for(new x = 0; x < MAX_PLAYERS; x++)
    {
        if(IsPlayerConnected(x))
        {
            if(SongInfo[x][LongSong] > 0)
            {
                if(SongInfo[x][LongSong] < gettime())
                {
                    SongInfo[x][LongSong] = gettime()+SongInfo[x][Seconds];
                    PlayMusicEx(x, SongInfo[x][UrlSong], SongInfo[x][LongSong]);
                }
            }
        }
    }
    return 1;
}

public OnGameModeInit()
{
    SetTimer("RepeatSong", 1000, true);
    return 1;
}

/* Example

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/playsound", cmdtext, true, 10) == 0)
    {
        PlayMusicEx(playerid, "Url", Duration of the song);
        return 1;
    }
    return 0;
}

*/
Reply
#9

Use Audio Plugin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)