Skip to content

Commit

Permalink
fix: pip-to-audio action does not close pip window (#6476)
Browse files Browse the repository at this point in the history
  • Loading branch information
janisslsm authored Sep 10, 2024
1 parent d8f826e commit bf99635
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.libretube.ui.fragments

import android.annotation.SuppressLint
import android.app.Activity
import android.app.Dialog
import android.content.BroadcastReceiver
import android.content.Context
Expand Down Expand Up @@ -175,6 +176,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
*/
private var playerLayoutOrientation = Int.MIN_VALUE

// Activity that's active during PiP, can be used for controlling its lifecycle.
private var pipActivity: Activity? = null

private val mainActivity get() = activity as MainActivity
private val windowInsetsControllerCompat
get() = WindowCompat
Expand Down Expand Up @@ -219,7 +223,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
playOnBackground()
// wait some time in order for the service to get started properly
handler.postDelayed(500) {
activity?.finish()
pipActivity?.moveTaskToBack(false)
pipActivity = null
}
}

Expand Down Expand Up @@ -1511,6 +1516,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
updateCurrentSubtitle(null)

openOrCloseFullscreenDialog(true)
pipActivity = activity
} else {
binding.player.useController = true

Expand Down

0 comments on commit bf99635

Please sign in to comment.