Pause Sound

T2008

Member
I'm having trouble pausing and resuming sound. The code is in the step event and is posted below. For some reason, I can stop and and play the music. However, when I pause and resume, it doesn't work. I know the triggering events are working because it works when I stop and play it. Any ideas as to why this doesn't pause the music? Any help would be greatly appreciated!

Code:
if (obj_lab1rm6_trigger_outage.triggered) && (!obj_lab1rm6_trigger_outage.scene_over) {
        audio_pause_sound(global.snd_bkg_music);  //this won't pause sound
        //audio_stop_sound(global.snd_bkg_music);    //it works to stop sound when this is coded
    } 
    if (obj_lab1rm6_trigger_outage.scene_over) {
        
        //if (!audio_is_playing(global.snd_bkg_music)) {  //it works to play music from beginning when this is in
            //audio_play_sound(global.snd_bkg_music,10,true);
       // }
        audio_resume_sound(global.snd_bkg_music);  //this doesn't work
    }
 

kburkhart84

Firehammer Games
I'm on 2.3.2.560. I can confirm the pause and resume sound functions are working fine on my machine. I'm just doing a very basic test though. I have a single object in the room with the following code.

Code:
//create
sound = audio_play_sound(__fhAudioSwapMusic1, 1, true);
alarm[0] = 60;

//alarm0
audio_pause_sound(sound);
alarm[1] = 60;

//alarm1
alarm[0] = 60;
audio_resume_sound(sound);
It just starts the music looping in the create event. It sets an alarm for one second in the future which pauses that music and sets another alarm. The second alarm resumes the music and sets the first alarm. It goes back and forth. And yes, the music is resuming right where it left off as well.
*****

The funny part of this though, I'm literally working with my audio system thing at the moment. Since I'm handling cross-fading and stuff with it, I never pause music, rather I always just stop it and I store the position automatically and then resume it at that position also automatically. The sound part does pausing, but the music part one does "manual" pausing in a different way. In any case, I did the above test with just the raw audio functions, not doing anything with my own stuff. Also, note that I couldn't avoid the clicking that occurs from instantly stopping and starting a track at random positions. This thought process led me to add a fadeout and fadein functionality to starting and stopping music and sounds.
 

T2008

Member
Thanks for responding. I tried adding alarms and still didn't work. I don't understand why it's not working.
 

kburkhart84

Firehammer Games
Thanks for responding. I tried adding alarms and still didn't work. I don't understand why it's not working.
Can you try an empty project and just a single object without messing with any other code? This would at the least prove if its something with your code or with the sound functions themselves.
 

T2008

Member
I edited out a lot of my code and it still didn't work. I should try your suggestion and just try with empty project, or at least empty object to see. I actually tried just fading the music to really low and then increasing it back to normal volume at the triggering events, which achieved the effect I wanted. Still, it seems like it should be straightforward to pause/resume. I'm sure I'm missing something obvious.
 

kburkhart84

Firehammer Games
I edited out a lot of my code and it still didn't work. I should try your suggestion and just try with empty project, or at least empty object to see. I actually tried just fading the music to really low and then increasing it back to normal volume at the triggering events, which achieved the effect I wanted. Still, it seems like it should be straightforward to pause/resume. I'm sure I'm missing something obvious.
Since I'm using the same functions you are trying to use in my version that I did for a test and it worked fine, I'd still recommend you try using a blank project. That will prove if it is those functions in general on your system, that project, something with your code, whatever.
 

T2008

Member
Yeah, I think I will try that, as it bothers me that it doesn't work even if I found a reasonable solution.
 
Top