From ddcdfbad6875ecc0b86d626ac2873ac27c66b61a Mon Sep 17 00:00:00 2001 From: 0x24d Date: Wed, 3 Apr 2024 22:04:34 +0100 Subject: [PATCH] fix: Respect USE_HLS_OVER_DASH preference when playing in audio mode --- .../libretube/services/OnlinePlayerService.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt index c0c74506e..d9535665d 100644 --- a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt +++ b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt @@ -27,6 +27,7 @@ import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.Segment import com.github.libretube.api.obj.Streams import com.github.libretube.constants.IntentData +import com.github.libretube.constants.PreferenceKeys import com.github.libretube.db.DatabaseHelper import com.github.libretube.enums.NotificationId import com.github.libretube.extensions.parcelableExtra @@ -35,6 +36,7 @@ import com.github.libretube.extensions.toID import com.github.libretube.extensions.updateParameters import com.github.libretube.helpers.PlayerHelper import com.github.libretube.helpers.PlayerHelper.checkForSegments +import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.helpers.ProxyHelper import com.github.libretube.obj.PlayerNotificationData import com.github.libretube.parcelable.PlayerData @@ -325,14 +327,19 @@ class OnlinePlayerService : LifecycleService() { private suspend fun setMediaItem() { val streams = streams ?: return - val (uri, mimeType) = if (streams.audioStreams.isNotEmpty() && !PlayerHelper.disablePipedProxy) { - PlayerHelper.createDashSource( - streams, - this - ) to MimeTypes.APPLICATION_MPD - } else { - ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8 - } + val (uri, mimeType) = + if (!PreferenceHelper.getBoolean( + PreferenceKeys.USE_HLS_OVER_DASH, + false, + ) && streams.audioStreams.isNotEmpty() && !PlayerHelper.disablePipedProxy + ) { + PlayerHelper.createDashSource( + streams, + this, + ) to MimeTypes.APPLICATION_MPD + } else { + ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8 + } val mediaItem = MediaItem.Builder() .setUri(uri)