fix: Respect USE_HLS_OVER_DASH preference when playing in audio mode

This commit is contained in:
0x24d 2024-04-03 22:04:34 +01:00
parent ff7de41ad1
commit ddcdfbad68

View File

@ -27,6 +27,7 @@ import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.obj.Segment import com.github.libretube.api.obj.Segment
import com.github.libretube.api.obj.Streams import com.github.libretube.api.obj.Streams
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.db.DatabaseHelper import com.github.libretube.db.DatabaseHelper
import com.github.libretube.enums.NotificationId import com.github.libretube.enums.NotificationId
import com.github.libretube.extensions.parcelableExtra 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.extensions.updateParameters
import com.github.libretube.helpers.PlayerHelper import com.github.libretube.helpers.PlayerHelper
import com.github.libretube.helpers.PlayerHelper.checkForSegments import com.github.libretube.helpers.PlayerHelper.checkForSegments
import com.github.libretube.helpers.PreferenceHelper
import com.github.libretube.helpers.ProxyHelper import com.github.libretube.helpers.ProxyHelper
import com.github.libretube.obj.PlayerNotificationData import com.github.libretube.obj.PlayerNotificationData
import com.github.libretube.parcelable.PlayerData import com.github.libretube.parcelable.PlayerData
@ -325,10 +327,15 @@ class OnlinePlayerService : LifecycleService() {
private suspend fun setMediaItem() { private suspend fun setMediaItem() {
val streams = streams ?: return val streams = streams ?: return
val (uri, mimeType) = if (streams.audioStreams.isNotEmpty() && !PlayerHelper.disablePipedProxy) { val (uri, mimeType) =
if (!PreferenceHelper.getBoolean(
PreferenceKeys.USE_HLS_OVER_DASH,
false,
) && streams.audioStreams.isNotEmpty() && !PlayerHelper.disablePipedProxy
) {
PlayerHelper.createDashSource( PlayerHelper.createDashSource(
streams, streams,
this this,
) to MimeTypes.APPLICATION_MPD ) to MimeTypes.APPLICATION_MPD
} else { } else {
ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8 ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8