Results 1 to 5 of 5

Thread: Audio Focus advanced setting, (do not stop playback)

  1. #1

    Audio Focus advanced setting, (do not stop playback)

    Having advanced setting where audio focus is not lost when media played from other app and/or system

    Vanilla music, I believe, handles it : onAudioFocusChange, L2121 for some reason hash gets converted to star so can not add it to url
    public void onAudioFocusChange(int type)
    {
    Log.d("VanillaMusic", "audio focus change: " + type);

    // Rewrite permanent focus loss into can_duck
    if (mIgnoreAudioFocusLoss) {
    switch (type) {
    case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
    case AudioManager.AUDIOFOCUS_LOSS:
    type = AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK;
    }
    }

    switch (type) {
    case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
    case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
    synchronized (mStateLock) {
    if((mState & FLAG_PLAYING) != 0) {
    mTransientAudioLoss = true;

    if(type == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
    setFlag(FLAG_DUCKING);
    } else {
    mForceNotificationVisible = true;
    unsetFlag(FLAG_PLAYING);
    }
    }
    break;
    }
    case AudioManager.AUDIOFOCUS_LOSS:
    mTransientAudioLoss = false;
    mForceNotificationVisible = true;
    unsetFlag(FLAG_PLAYING);
    break;
    case AudioManager.AUDIOFOCUS_GAIN:
    if (mTransientAudioLoss) {
    mTransientAudioLoss = false;
    // Restore all flags possibly changed by AUDIOFOCUS_LOSS_TRANSIENT_*
    unsetFlag(FLAG_DUCKING);
    setFlag(FLAG_PLAYING);
    }
    break;
    }
    }
    Toggle in advanced setting would be needed to enable or disable Audio Focus, with optional pause on call, resume after call:
    I.E.
    Last edited by rancidfrog; April 8th, 2017 at 03:50 PM.

  2. #2

    Re: Audio Focus advanced setting, (do not stop playback)


  3. #3

    Re: Audio Focus advanced setting, (do not stop playback)

    Quote Originally Posted by Peter View Post
    Android update
    In MainService.java requestAudioFocus would need to be adjusted with boolean flag setting probably a enable/disable switch in advanced settings regarding Permanent Audio focus:
    Code:
    void requestAudioFocus() {
    // Setting needed for Permanent Focus in advanced settings
    // int AUDIOFOCUS_GAIN    
    // Constant Value: 1 (0x00000001) 
    if( permanentFocus)
            if (this.mAudioManager != null && !this.mHaveAudioFocus && this.mAudioManager.requestAudioFocus(this, AUDIOFOCUS_GAIN, 1) == 1) {
                this.mHaveAudioFocus = true;
                registerRemoteControlClient();
            }
    else
            if (this.mAudioManager != null && !this.mHaveAudioFocus && this.mAudioManager.requestAudioFocus(this, 3, 1) == 1) {
                this.mHaveAudioFocus = true;
                registerRemoteControlClient();
            }

  4. #4

    Re: Audio Focus advanced setting, (do not stop playback)

    Can Always on playback no interruptions be considered?

  5. #5

    Re: Audio Focus advanced setting, (do not stop playback)

    Quote Originally Posted by rancidfrog View Post
    Can Always on playback no interruptions be considered?
    If you mean "do not interrupt playback when a notification comes in" that would be great. PowerAmp does that perfectly, now with Foobar I have to put my phone on silent all the time with playback over bluetooth.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •