I’m trying to have a very simple toggle button for some audio… It looks something like this.
// Play pause toggle
if (audio.isPlaying)
{
audio.Pause();
}
else
{
audio.Play();
}
This works fine on the Mac, but unfortunately it doesn’t work reliably on the iPhone/iPods. It seems that if you pause a sound (I’m playing back .mp4’s), it seems to return that it is still playing, and thus, won’t resume.
I would simply add a boolean variable that holds the state.
The topic has come up already and I’m unsure if unity can do anything about it as this fully relies on the iphone hardware decompression etc, not cpu work
I’m having the same problem with my iPhone app. I’m using uncompressed audio for a sound effect as recommended in the documentation, but I just can’t get it to stop and start using audio.Play() and audio.Pause() (or audio.Stop()). if I use:
Debug.Log(audio.isPlaying);
to check if the clip is playing it seems that audio.Pause() will stop it, but audio.Play() will not start it again.
I’ve searched the forum but can’t find a solution to this problem. Has anyone been able to work around it?
I’ve worked around it by using audio.volume = 0.0 in my pause function. This shouldn’t cause problems with processor use because everything else is suspended at this point. Using audio.Stop() seems to work fine when the game ends and I can then restart it as expected. Just not during the game. Odd.