diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java b/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java index c51cfcd193..c55f94934a 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java +++ b/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java @@ -20,7 +20,6 @@ import org.jellyfin.androidtv.data.model.DataRefreshService; import org.jellyfin.androidtv.preference.UserPreferences; import org.jellyfin.androidtv.preference.UserSettingPreferences; -import org.jellyfin.androidtv.preference.constant.AudioBehavior; import org.jellyfin.androidtv.preference.constant.NextUpBehavior; import org.jellyfin.androidtv.preference.constant.RefreshRateSwitchingBehavior; import org.jellyfin.androidtv.ui.livetv.TvManager; @@ -521,10 +520,8 @@ private VideoOptions buildExoPlayerOptions(@Nullable Integer forcedSubtitleIndex } DeviceProfile internalProfile = new ExoPlayerProfile( isLiveTv && !userPreferences.getValue().get(UserPreferences.Companion.getLiveTvDirectPlayEnabled()), - userPreferences.getValue().get(UserPreferences.Companion.getAc3Enabled()), - userPreferences.getValue().get(UserPreferences.Companion.getAudioBehaviour()) == AudioBehavior.DOWNMIX_TO_STEREO, mFragment.getContext(), - userPreferences.getValue().get(UserPreferences.Companion.getPreferExoPlayerFfmpeg()) + userPreferences.getValue() ); internalOptions.setProfile(internalProfile); return internalOptions; diff --git a/app/src/main/java/org/jellyfin/androidtv/util/profile/ExoPlayerProfile.kt b/app/src/main/java/org/jellyfin/androidtv/util/profile/ExoPlayerProfile.kt index e75acfc1d8..b9f52b7744 100644 --- a/app/src/main/java/org/jellyfin/androidtv/util/profile/ExoPlayerProfile.kt +++ b/app/src/main/java/org/jellyfin/androidtv/util/profile/ExoPlayerProfile.kt @@ -2,6 +2,8 @@ package org.jellyfin.androidtv.util.profile import android.content.Context import org.jellyfin.androidtv.constant.Codec +import org.jellyfin.androidtv.preference.UserPreferences +import org.jellyfin.androidtv.preference.constant.AudioBehavior import org.jellyfin.androidtv.util.profile.ProfileHelper.audioDirectPlayProfile import org.jellyfin.androidtv.util.profile.ProfileHelper.deviceAV1CodecProfile import org.jellyfin.androidtv.util.profile.ProfileHelper.deviceAVCCodecProfile @@ -28,10 +30,8 @@ import org.jellyfin.apiclient.model.dlna.TranscodingProfile class ExoPlayerProfile( disableVideoDirectPlay: Boolean, - isAC3Enabled: Boolean, - downMixAudio: Boolean, context: Context, - preferFfmpeg: Boolean, + userPreferences: UserPreferences, ) : DeviceProfile() { private val downmixSupportedAudioCodecs = arrayOf( Codec.Audio.AAC, @@ -47,10 +47,10 @@ class ExoPlayerProfile( addAll(downmixSupportedAudioCodecs) add(Codec.Audio.AAC_LATM) add(Codec.Audio.ALAC) - if (isAC3Enabled) add(Codec.Audio.AC3) - if (isAC3Enabled) add(Codec.Audio.EAC3) + if (userPreferences[UserPreferences.ac3Enabled]) add(Codec.Audio.AC3) + if (userPreferences[UserPreferences.ac3Enabled]) add(Codec.Audio.EAC3) add(Codec.Audio.DCA) - if (supportsDts(context, preferFfmpeg)) add(Codec.Audio.DTS) + if (supportsDts(context, userPreferences[UserPreferences.preferExoPlayerFfmpeg])) add(Codec.Audio.DTS) add(Codec.Audio.MLP) add(Codec.Audio.TRUEHD) add(Codec.Audio.PCM_ALAW) @@ -83,9 +83,9 @@ class ExoPlayerProfile( if (supportsHevc) add(Codec.Video.HEVC) add(Codec.Video.H264) }.joinToString(",") - audioCodec = when (downMixAudio) { - true -> downmixSupportedAudioCodecs - false -> allSupportedAudioCodecsWithoutFFmpegExperimental + audioCodec = when (userPreferences[UserPreferences.audioBehaviour]) { + AudioBehavior.DOWNMIX_TO_STEREO -> downmixSupportedAudioCodecs + AudioBehavior.DIRECT_STREAM -> allSupportedAudioCodecsWithoutFFmpegExperimental }.joinToString(",") protocol = "hls" copyTimestamps = false @@ -132,9 +132,9 @@ class ExoPlayerProfile( Codec.Video.AV1 ).joinToString(",") - audioCodec = when (downMixAudio) { - true -> downmixSupportedAudioCodecs - false -> allSupportedAudioCodecs + audioCodec = when (userPreferences[UserPreferences.audioBehaviour]) { + AudioBehavior.DOWNMIX_TO_STEREO -> downmixSupportedAudioCodecs + AudioBehavior.DIRECT_STREAM -> allSupportedAudioCodecs }.joinToString(",") }) } @@ -206,7 +206,10 @@ class ExoPlayerProfile( // Limit video resolution support for older devices add(maxResolutionCodecProfile) // Audio channel profile - add(maxAudioChannelsCodecProfile(channels = if (downMixAudio) 2 else 8)) + add(maxAudioChannelsCodecProfile(when (userPreferences[UserPreferences.audioBehaviour]) { + AudioBehavior.DIRECT_STREAM -> 8 + AudioBehavior.DOWNMIX_TO_STEREO -> 2 + })) }.toTypedArray() subtitleProfiles = buildList {