Skip to content

Commit 2116c64

Browse files
committed
fix: offline audio player transition, offline PiP/fullscreen
1 parent b00fa5e commit 2116c64

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
android:name=".ui.activities.NoInternetActivity"
4646
android:label="@string/noInternet"
4747
android:launchMode="singleTop"
48+
android:configChanges="keyboard|keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation|uiMode"
4849
android:supportsPictureInPicture="true"
4950
android:screenOrientation="locked" />
5051

app/src/main/java/com/github/libretube/helpers/BackgroundHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import com.github.libretube.parcelable.PlayerData
1515
import com.github.libretube.services.AbstractPlayerService
1616
import com.github.libretube.services.OfflinePlayerService
1717
import com.github.libretube.services.OnlinePlayerService
18-
import com.github.libretube.ui.activities.MainActivity
18+
import com.github.libretube.ui.activities.AbstractPlayerHostActivity
1919
import com.github.libretube.ui.activities.NoInternetActivity
2020
import com.github.libretube.ui.fragments.DownloadSortingOrder
2121
import com.github.libretube.ui.fragments.DownloadTab
@@ -42,7 +42,7 @@ object BackgroundHelper {
4242
) {
4343
// close the previous video player if open
4444
val fragmentManager =
45-
ContextHelper.unwrapActivity<MainActivity>(context).supportFragmentManager
45+
ContextHelper.unwrapActivity<AbstractPlayerHostActivity>(context).supportFragmentManager
4646
fragmentManager.fragments.firstOrNull { it is PlayerFragment }?.let {
4747
fragmentManager.commit { remove(it) }
4848
}

app/src/main/java/com/github/libretube/helpers/NavigationHelper.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,26 @@ object NavigationHelper {
114114
// in contrast to the video player, the audio player doesn't start a media service on
115115
// its own!
116116
if (isOffline) {
117-
BackgroundHelper.playOnBackground(
117+
BackgroundHelper.playOnBackgroundOffline(
118118
context,
119119
videoId.toID(),
120-
timestamp,
121120
playlistId,
122-
channelId,
123-
keepQueue
121+
downloadTab!!,
122+
shuffle,
123+
downloadSortingOrder
124124
)
125125
} else {
126-
BackgroundHelper.playOnBackgroundOffline(
126+
BackgroundHelper.playOnBackground(
127127
context,
128128
videoId.toID(),
129+
timestamp,
129130
playlistId,
130-
downloadTab!!,
131-
shuffle,
132-
downloadSortingOrder
131+
channelId,
132+
keepQueue
133133
)
134134
}
135135

136-
openAudioPlayerFragment(context, minimizeByDefault = true)
136+
openAudioPlayerFragment(context, offlinePlayer = isOffline, minimizeByDefault = true)
137137
} else {
138138
openVideoPlayerFragment(
139139
context,

app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.constraintlayout.motion.widget.MotionLayout
1414
import androidx.constraintlayout.motion.widget.TransitionAdapter
1515
import androidx.core.math.MathUtils.clamp
1616
import androidx.core.os.bundleOf
17+
import androidx.core.os.postDelayed
1718
import androidx.core.view.isGone
1819
import androidx.core.view.isVisible
1920
import androidx.fragment.app.Fragment
@@ -22,6 +23,7 @@ import androidx.fragment.app.commit
2223
import androidx.lifecycle.lifecycleScope
2324
import androidx.media3.common.MediaMetadata
2425
import androidx.media3.common.Player
26+
import androidx.media3.common.util.Log
2527
import androidx.media3.common.util.UnstableApi
2628
import androidx.media3.session.MediaController
2729
import com.github.libretube.R
@@ -112,7 +114,7 @@ class AudioPlayerFragment : Fragment(R.layout.fragment_audio_player), AudioPlaye
112114

113115
// manually apply additional padding for edge-to-edge compatibility
114116
activity.getSystemInsets()?.let { systemBars ->
115-
with (binding.audioPlayerMain) {
117+
with(binding.audioPlayerMain) {
116118
setPadding(
117119
paddingLeft,
118120
paddingTop + systemBars.top,
@@ -279,6 +281,7 @@ class AudioPlayerFragment : Fragment(R.layout.fragment_audio_player), AudioPlaye
279281
NavigationHelper.openVideoPlayerFragment(
280282
context = requireContext(),
281283
videoId = videoId,
284+
isOffline = isOffline,
282285
alreadyStarted = true,
283286
)
284287
}

0 commit comments

Comments
 (0)