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,14 +327,19 @@ 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) =
PlayerHelper.createDashSource( if (!PreferenceHelper.getBoolean(
streams, PreferenceKeys.USE_HLS_OVER_DASH,
this false,
) to MimeTypes.APPLICATION_MPD ) && streams.audioStreams.isNotEmpty() && !PlayerHelper.disablePipedProxy
} else { ) {
ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8 PlayerHelper.createDashSource(
} streams,
this,
) to MimeTypes.APPLICATION_MPD
} else {
ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8
}
val mediaItem = MediaItem.Builder() val mediaItem = MediaItem.Builder()
.setUri(uri) .setUri(uri)