playMaker

Author Topic: Audio Listener Pause  (Read 10228 times)

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • Flying Robot Studios
Audio Listener Pause
« on: October 18, 2013, 01:52:36 AM »
tiny action. But will come handy if you want to pause all audio in the scene and resume. Even one shot clips.


Tkfore21

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Audio Listener Pause
« Reply #1 on: November 30, 2013, 03:23:03 PM »
THANK YOU!!!!!!!

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Audio Listener Pause
« Reply #2 on: January 18, 2014, 06:30:40 PM »
This is a great action, thanks.

However... I have a bug.

If you trigger this action, it pauses all audio fine, however if you click away from your window (standalone PC build) and it goes into the default Unity sleep thing, when you click back on your game, the one-shot audio clips that were suspended will resume.

It handled my music track ok, but not the one-shot sfx sound that I triggered just being pausing my game.

Any chance you could look at/fix this?

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • Flying Robot Studios
Re: Audio Listener Pause
« Reply #3 on: January 20, 2014, 01:43:20 AM »
I've added an option of running this action every frame so that when you return to the window it will remain paused.

https://github.com/flyingrobot/playmakercustomactions/blob/master/AudiolistenerPause.cs

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Audio Listener Pause
« Reply #4 on: January 20, 2014, 12:06:11 PM »
Thanks for addressing that so quickly!

I am getting an error with this update though:

Assets/PlayMaker/Actions/AudiolistenerPause.cs(4,1): error CS8025: Parsing error

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • Flying Robot Studios
Re: Audio Listener Pause
« Reply #5 on: January 21, 2014, 02:34:34 AM »
You must have right click saved the above github link. You will have to click on it, go to Github and then download.

Anyway I've attached it here

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Audio Listener Pause
« Reply #6 on: January 21, 2014, 09:12:49 AM »
Thanks. I'm now running without errors.

It doesn't seem to work correctly though....

Now, it's resuming the audio for music as well as the one-shot clips when I tab away then back to my standalone build.

Using the old action, at least the only problem was the one-shot clips.

Have you tested it in a scene and confirmed that it works?

Cheers,

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • Flying Robot Studios
Re: Audio Listener Pause
« Reply #7 on: January 22, 2014, 09:14:01 AM »
There's not much I can do here. This actions is a direct port of the unity runtime class.

http://docs.unity3d.com/Documentation/ScriptReference/AudioListener-pause.html

Did you checked 'everyframe' ? My script will work, but when you return to the game window, you may notice the audio playing for a fraction of second before this actions kicks in.

I'd suggest you use 'set game volume' action alongside this and set the volume to zero.

There are lengthier processes to do this by pausing each audio source from an action. But this is faster way, and you don't have to search and list out all audio sources.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Audio Listener Pause
« Reply #8 on: January 22, 2014, 09:30:45 AM »
Hi,

Yes, I had 'every frame' checked.

I'm not really sure what difference this should have in theory, but in practice this update is worse than the original action on my scene. At least the music remained paused with the original action.

And it's not just a few frames, it continues with the music until the end of the track. And with the one-shot clips, plays to their end.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Audio Listener Pause
« Reply #9 on: January 22, 2014, 09:32:48 AM »
Oh, I probably should have mentioned;

I'm using this on a GUI button that I've set to activate pause mode - setting the ScaleTime to 0, and clicking the button again to put the ScaleTime back to 1.

But as I said, the original action worked perfectly other than the tabbing away then back to standalone build.

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • Flying Robot Studios
Re: Audio Listener Pause
« Reply #10 on: January 22, 2014, 09:51:18 AM »
Did you scale the time before triggering this action or after it.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Audio Listener Pause
« Reply #11 on: January 22, 2014, 11:14:48 AM »
I use this action and then scale time.

Everything works perfectly if I stay focused on my game - it's only if I click away, or minimize, and then go back to my game whilst it's paused - that's where the problem occurs.


3d_Artist1987

  • Beta Group
  • Full Member
  • *
  • Posts: 157
Re: Audio Listener Pause
« Reply #12 on: August 30, 2014, 02:12:32 AM »
Thanks for making this action.

play_edu

  • Full Member
  • ***
  • Posts: 116
Re: Audio Listener Pause
« Reply #13 on: August 30, 2014, 02:20:01 AM »
Hi,

Thanks man for making this script.

Regards
Play_edu

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Audio Listener Pause
« Reply #14 on: January 04, 2015, 04:07:12 PM »
I try to use the AudioListenerPause,   but there is error. How can i fix that?


here the error.
 The type or namespace name `Tooltip' could not be found. Are you missing a using directive or an assembly reference?

TooltipAttribute' is an ambiguous reference between `UnityEngine.TooltipAttribute' and `HutongGames.PlayMaker.TooltipAttribute'
« Last Edit: January 04, 2015, 04:09:48 PM by nabilfx »