Mixerstrip.setPaused notworking OnApplicationPause

I’m trying to use MixerStrip.setPaused() to pause the FMOD audio when the Android Application goes into background.

My FMOD related code works, but in combination with Unity’s OnApplicationPause(bool) - it seems like it doesn’t get called.

My theory is that FMOD takes too long to pause the MixerStrip, so that the Application is already paused before it happens ??

It fires ok, when the application gets resumed…

Any Infos on how to pause the FMOD sound, when the android App goes into background, would be appreciated.

Here’s my code:

public class ApplicationStateManager : MonoBehaviour {

	static FMOD.Studio.MixerStrip m_mixer;

	void Start() {
		Application.runInBackground = false;
		GetMainMixer();
	}

	public void GetMainMixer() {
		
		var m_system = FMOD_StudioSystem.instance;
		// Get main mixer
		FMOD.GUID guid = new FMOD.GUID();
		m_system.System.lookupID("bus:/", out guid);
		m_system.System.getMixerStrip(guid, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out m_mixer);
	}


	void OnApplicationPause (bool pauseState) {
		if (pauseState) {
			m_mixer.setPaused(true);
		}
		if (!pauseState){
			m_mixer.setPaused(false);
		}

	}

}

Hello atomtwist,

Did you manage to stop the sound when the app is paused in Android devices?

I think you are right, the OnApplicationPause handler is called but the app is paused before it can finish the operation. The function ends its execution after the app resumes, that is why a subtle pause can be heard sometimes.

I’ve also tried using the method OnApplicationFocus, with the same result.

I tried to stop the music, instead of pausing this. The music never stopped when pausing the app but was always restarted when resuming it.

I think this should be a basic feature. Many of the users don’t know how to kill the app in order to stop the persistent sound.

Anyone knows how to do this?

Thanks!

Didn’t get it to work yet. :frowning:
Solution or workaround would be very appreciated !!

only happens on android btw. iOS handles these kind of things differently - and just fades out the sound if u minimize…

Hi guys,

Sorry for the delay in replying. The next release will include the complete lowlevel API, and a new function “mixer suspend” which will not only pause the output but also put FMOD in low power mode to save battery. This has been added to the FMOD_StudioSystem.onApplicationPause so there are no code changes required on your end. This new functionality should be available later this week.

That’s great news. :slight_smile:
Thanx a lot !!

Thank you Peter!