Skip to main content
Participant
June 2, 2023
Answered

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

  • June 2, 2023
  • 1 reply
  • 149 views

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 has been closed for replies.
    Correct answer JoãoCésar17023019

    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
    June 2, 2023

    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