# audioSource.isPlaying issues?

**URL:** https://discussions.unity.com/t/audiosource-isplaying-issues/396313
**Category:** Mobile
**Tags:** iOS
**Created:** [August 12, 2009, 1:00am UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313 "2009-08-12T01:00:34Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jtbentley\_1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/jtbentley_1/32/277620_2.png) [@jtbentley\_1](https://discussions.unity.com/u/jtbentley_1)
#### Post date: [August 12, 2009, 1:00am UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313/1 "2009-08-12T01:00:34Z")

</div>

Hey,

I’m trying to have a very simple toggle button for some audio… It looks something like this.

```auto
// 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.

Any ideas?

---

<div class="post-metadata">

### Author: ![Dreamora](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dreamora/32/91058_2.png) [@Dreamora](https://discussions.unity.com/u/Dreamora)
#### Post date: [August 12, 2009, 1:05am UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313/2 "2009-08-12T01:05:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jtbentley\_1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/jtbentley_1/32/277620_2.png) [@jtbentley\_1](https://discussions.unity.com/u/jtbentley_1)
#### Post date: [August 12, 2009, 1:09am UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313/3 "2009-08-12T01:09:58Z")

</div>

I had an awful fear you (or someone just like you) would say that 🙂

I suppose when I hit play, I set off a coroutine that sets that boolean to false after audio.length has ended aswell.

Plus, the user is basically encouraged to move on from that point, etc, so I have to keep it all in sync etc.

Sigh.

Workaround - VCR controls… They’re just always there, even if it’s the height of redundancy 🙂

---

<div class="post-metadata">

### Author: ![anon\_92210825](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anon\_92210825](https://discussions.unity.com/u/anon_92210825)
#### Post date: [September 8, 2009, 10:20am UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313/4 "2009-09-08T10:20:13Z")

</div>

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?

Thanks.

---

<div class="post-metadata">

### Author: ![Wozik](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@Wozik](https://discussions.unity.com/u/Wozik)
#### Post date: [September 8, 2009, 10:35am UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313/5 "2009-09-08T10:35:27Z")

</div>

Play() after Stop() may not work if they are being called within one frame.

---

<div class="post-metadata">

### Author: ![anon\_92210825](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anon\_92210825](https://discussions.unity.com/u/anon_92210825)
#### Post date: [September 8, 2009, 10:40am UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313/6 "2009-09-08T10:40:58Z")

</div>

Thanks. I don’t think that’s the problem here though, because audio.Play is being called some time after the clip was paused.

---

<div class="post-metadata">

### Author: ![anon\_92210825](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anon\_92210825](https://discussions.unity.com/u/anon_92210825)
#### Post date: [September 8, 2009, 3:59pm UTC](https://discussions.unity.com/t/audiosource-isplaying-issues/396313/7 "2009-09-08T15:59:23Z")

</div>

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.
