# FMOD 2.02 PLAYBACK\_STATE returns always STOPPED when sound is playing

**URL:** <https://qa.fmod.com/t/fmod-2-02-playback-state-returns-always-stopped-when-sound-is-playing/19355>\
**Category:** Unity\
**Tags:** unity\
**Created:** [October 3, 2022, 5:40pm UTC](https://qa.fmod.com/t/fmod-2-02-playback-state-returns-always-stopped-when-sound-is-playing/19355 "2022-10-03T17:40:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![visumecadroide](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/visumecadroide/32/4074_2.png) [@visumecadroide](https://qa.fmod.com/u/visumecadroide)\
**Post date:** [October 3, 2022, 5:40pm UTC](https://qa.fmod.com/t/fmod-2-02-playback-state-returns-always-stopped-when-sound-is-playing/19355/1 "2022-10-03T17:40:25Z")

</div>

Hello, I cannot get my unity script working as intended with PLAYBACK\_STATE and I absolutely don’t know why.  
I just spent my day trying to understand but I am still stuck.

Using Fmod 2.02 + Unity 2020.3.39f1.  
I use my script to check if a sound is playing in order to not play it again once it is already playing but the PLAYBACK\_STATE is always STOPPED. So it keeps restarting the sound each frame.

Here is the script I use :  
To explain a bit, I call PlayOneShotAttachedToGO() at only one place in the update of another script.

```auto
using FMOD.Studio;
using FMODUnity;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AudioPlayer : MonoBehaviour
{
    public EventReference soundEventReference;
    EventInstance soundStateInstance;

    void Start()
    {
        soundStateInstance = RuntimeManager.CreateInstance(soundEventReference);
    }

    public PLAYBACK_STATE playbackState;

    public void PlayOneShotAttachedToGO()
    {
        if (soundStateInstance.isValid())
        {
            soundStateInstance.getPlaybackState(out playbackState);
            if (playbackState == PLAYBACK_STATE.STOPPED)//keeps being STOPPED even if the sound is playing in game
                RuntimeManager.PlayOneShotAttached(soundEventReference, gameObject);
        }
    }

    public void PlayOneShotToTransformPosition()
    {
        if (soundStateInstance.isValid())
        {
            soundStateInstance.getPlaybackState(out playbackState);
            if (playbackState == PLAYBACK_STATE.STOPPED)
                RuntimeManager.PlayOneShot(soundEventReference, transform.position);
        }
    }

    public void StopSound()
    {
        if (soundStateInstance.isValid())
        {
            soundStateInstance.getPlaybackState(out playbackState);
            if (playbackState == PLAYBACK_STATE.PLAYING)
                soundStateInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
        }
    }
}

```

I cannot understand what is happening and why when I hear the sound played in-game in unity it keeps being STOPPED.

I hope someone will have a solution. Also, it’s no use to propose to get back on 2.01 because I was forced to upgrade to 2.02 because 3D spatialized sound was not working.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [October 9, 2022, 10:50pm UTC](https://qa.fmod.com/t/fmod-2-02-playback-state-returns-always-stopped-when-sound-is-playing/19355/2 "2022-10-09T22:50:27Z")

</div>

Hi,

So the problem is the `soundStateInstance` is not the same event instance that `PlayOneShotAttached` is creating/using. Since `SoundStateInstance` is never played it will always return Stopped.

A solution would be to implement your own `PlayOneShotAttached` based on how we have structured it in the `RuntimeManager.cs` script. To find its implementation highlight `PlayOneShotAttached` in your script and press F12.

Hope this helps!
