Skip to main content
Participant
Jun 2, 2023 5:57 AM UTC
Answered

Want To Stop Every Music In Background When Minimized In SWF or APK

I Have a Little Trouble When i Realise The Music Background Wont Stop  When I go Minimized this app, anyone know to mute sound when minimized ?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Jun 2, 2023 11:48 AM UTC

    Hi.

     

    You'll need to listen for the ACTIVATE and DEACTIVATE events from the NativeApplication class. Like this:

     

    import flash.desktop.NativeApplication;
    import flash.events.Event;
    import flash.media.SoundMixer;
    
    function deactivateHandler(e:Event):void
    {
    	// stop/mute/pause sounds
    	// e.g.: SoundMixer.stopAll();
    }
    
    function activateHandler(e:Event):void
    {
    	// play/resume sounds
    	// e.g.: yourSound.play();
    }
    
    NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deactivateHandler);
    NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, activateHandler);

     

     

    I hope this helps.

     

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Jun 2, 2023 11:48 AM UTC

    Hi.

     

    You'll need to listen for the ACTIVATE and DEACTIVATE events from the NativeApplication class. Like this:

     

    import flash.desktop.NativeApplication;
    import flash.events.Event;
    import flash.media.SoundMixer;
    
    function deactivateHandler(e:Event):void
    {
    	// stop/mute/pause sounds
    	// e.g.: SoundMixer.stopAll();
    }
    
    function activateHandler(e:Event):void
    {
    	// play/resume sounds
    	// e.g.: yourSound.play();
    }
    
    NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deactivateHandler);
    NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, activateHandler);

     

     

    I hope this helps.

     

    Regards,

    JC

    Translate