Results 1 to 5 of 5

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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 02:50 PM.

Posting Permissions

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