From a6ff85a208ec174f48ea31f4487c66d490a1ae1c Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Thu, 18 Aug 2022 19:21:29 +0200 Subject: [PATCH] Move media tunneling setting to ExoPlayer settings and make this setting available on release builds Media tunneling may be not supported by more devices than the ones we whitelisted before. As a matter of fact, the list of devices on which media tunneling is disabled could be not maintainable in the future, especially if the list of devices grows more and more. A preferable solution is to allow users to configure this setting themselves, allowing them to not wait for their device(s) to be whitelisted in a future NewPipe update. This solution has been applied in this commit and works on every build type. The corresponding preference in the debug settings has been of course removed and the code used to prevent media tunneling activation on specific devices has been removed. --- .../org/schabi/newpipe/player/Player.java | 11 ++------ .../org/schabi/newpipe/util/DeviceUtils.java | 28 ------------------- app/src/main/res/values/settings_keys.xml | 2 +- app/src/main/res/xml/debug_settings.xml | 8 ------ app/src/main/res/xml/exoplayer_settings.xml | 8 ++++++ 5 files changed, 11 insertions(+), 46 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index cc75a2c22..5dc9382e7 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -77,7 +77,6 @@ import com.google.android.exoplayer2.text.CueGroup; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; -import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoSize; import com.squareup.picasso.Picasso; import com.squareup.picasso.Target; @@ -115,7 +114,6 @@ import org.schabi.newpipe.player.ui.PlayerUiList; import org.schabi.newpipe.player.ui.PopupPlayerUi; import org.schabi.newpipe.player.ui.VideoPlayerUi; import org.schabi.newpipe.util.DependentPreferenceHelper; -import org.schabi.newpipe.util.DeviceUtils; import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.PicassoHelper; @@ -522,16 +520,11 @@ public final class Player implements PlaybackListener, Listener { // Setup UIs UIs.call(PlayerUi::initPlayer); - // enable media tunneling - if (DEBUG && PreferenceManager.getDefaultSharedPreferences(context) + // Disable media tunneling if requested by the user from ExoPlayer settings + if (!PreferenceManager.getDefaultSharedPreferences(context) .getBoolean(context.getString(R.string.disable_media_tunneling_key), false)) { - Log.d(TAG, "[" + Util.DEVICE_DEBUG_INFO + "] " - + "media tunneling disabled in debug preferences"); - } else if (DeviceUtils.shouldSupportMediaTunneling()) { trackSelector.setParameters(trackSelector.buildUponParameters() .setTunnelingEnabled(true)); - } else if (DEBUG) { - Log.d(TAG, "[" + Util.DEVICE_DEBUG_INFO + "] does not support media tunneling"); } } //endregion diff --git a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java index 4b08cfcb5..f656c6144 100644 --- a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java @@ -36,22 +36,6 @@ public final class DeviceUtils { private static Boolean isTV = null; private static Boolean isFireTV = null; - /* - * Devices that do not support media tunneling - */ - // Formuler Z8 Pro, Z8, CC, Z Alpha, Z+ Neo - private static final boolean HI3798MV200 = Build.VERSION.SDK_INT == 24 - && Build.DEVICE.equals("Hi3798MV200"); - // Zephir TS43UHD-2 - private static final boolean CVT_MT5886_EU_1G = Build.VERSION.SDK_INT == 24 - && Build.DEVICE.equals("cvt_mt5886_eu_1g"); - // Hilife TV - private static final boolean REALTEKATV = Build.VERSION.SDK_INT == 25 - && Build.DEVICE.equals("RealtekATV"); - // Philips QM16XE - private static final boolean QM16XE_U = Build.VERSION.SDK_INT == 23 - && Build.DEVICE.equals("QM16XE_U"); - private DeviceUtils() { } @@ -211,18 +195,6 @@ public final class DeviceUtils { context.getResources().getDisplayMetrics()); } - /** - * Some devices have broken tunneled video playback but claim to support it. - * See https://github.com/TeamNewPipe/NewPipe/issues/5911 - * @return false if affected device - */ - public static boolean shouldSupportMediaTunneling() { - return !HI3798MV200 - && !CVT_MT5886_EU_1G - && !REALTEKATV - && !QM16XE_U; - } - public static boolean isLandscape(final Context context) { return context.getResources().getDisplayMetrics().heightPixels < context.getResources() .getDisplayMetrics().widthPixels; diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 7d8c48bda..8ff617172 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -227,7 +227,6 @@ show_memory_leaks_key allow_disposed_exceptions_key show_original_time_ago_key - disable_media_tunneling_key show_image_indicators_key show_crash_the_player_key check_new_streams @@ -1369,5 +1368,6 @@ exoplayer_settings_key + disable_media_tunneling_key use_exoplayer_decoder_fallback_key diff --git a/app/src/main/res/xml/debug_settings.xml b/app/src/main/res/xml/debug_settings.xml index 7405e47ac..84bb281f3 100644 --- a/app/src/main/res/xml/debug_settings.xml +++ b/app/src/main/res/xml/debug_settings.xml @@ -34,14 +34,6 @@ app:singleLineTitle="false" app:iconSpaceReserved="false" /> - - + + \ No newline at end of file