Unity WebGL audio not looping when started with playdelayed()

by grizzly_beer   Last Updated April 16, 2018 10:13 AM

I have an audioSource in which loop is set to true. I am starting it playing by calling playdelayed()

In the editor its plays fine. In a webgl build it does not loop. It just plays once.

Also in firefox it does not start playing at the correct time, it is a good fraction of a second off.

public override void MatchStarted()
{
    Intro.Play();
    Loop.PlayDelayed(Intro.clip.length);
}

PlayScheduled has exactly the same effect.

public override void MatchStarted()
{
    Intro.Play();
    Loop.PlayScheduled(AudioSettings.dspTime + Intro.clip.length);
}

Play(ulong) has the same effect

public override void MatchStarted()
{
    Intro.Play();
    Loop.Play((ulong)(44100 * Intro.clip.length));
}

I'm posting this here seeking workarounds. Any suggestions? As you can see from my code, my use case is a piece of music with an intro and a loop.

...

ps. I have seen some posts saying that if the bitrate is not 44.1 KHz this can cause looping issues on WebGl. The audio file in question is set to override the bitrate to 44.1 in its import settings.

Tags : unity webgl audio


Related Questions




Unity accesing external audio

Updated April 23, 2016 08:05 AM


Adding more effects to a Unity3d mixer

Updated October 27, 2017 16:13 PM