omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Muting or stopping sound of a background app and turning it on afterwards

    Pythonista
    down mute sound volume background
    2
    4
    1197
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • baschni
      baschni last edited by

      Hallo,

      I would like to imitate the effect when you hear music with one app A and then a voice message is played in another app B. App B then turns down the sound of App A running in background and playing the voice message and afterwards turning up the volume again.

      App A in my case is deezer and App B would be the Pythonista script, that would put out a signal sound to the user.

      Pausing music in a and turning it on afterwards would also work for me.

      Kind regards
      Bastian

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        What happens when you play a sound now? Does it stop the other app entirely?

        I think there may be a avaudiosession option for that, but it's been a while.

        1 Reply Last reply Reply Quote 0
        • baschni
          baschni last edited by

          When I play a sound currently through sound.play_effect the music in the background just continues. But it is so loud, that I do not really notice the sound from Pythonista.

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            xthis works, might be ways to simplify

            from objc_util import  *
            s=ObjCClass("AVAudioSession").sharedInstance()
            s.setActive_error_(False,None)
            s.setCategory_withOptions_error_(ns('AVAudioSessionCategoryPlayback'),0x2,None)
            # s.setActive_error_(True,None)
            import sound
            sp=sound.Player('game:Bleep')
            sp.play()
            s.setActive_error_(False,None)
            s.setCategory_withOptions_error_(ns('AVAudioSessionCategoryPlayback'),0x1,None)
            

            option 2 means to "duck others". there is another option to interrupt others, but i cant seem to get that working.
            If we dont set active false at the end, the music stays softer.
            Im not entirely sure if the setActive is needed up front.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors