From 41da8fc05faf744f7e9a57a1a6adf2225be6cfd4 Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Thu, 18 Aug 2022 18:59:45 +0200
Subject: [PATCH] Add ability to use ExoPlayer's decoder fallback option
This option could help to avoid decoder initialization issues, which falls back
to lower-priority decoders if decoder initialization fails. This may result in
poor playback performance than when using primary decoders.
It is disabled by default, but can be enabled in ExoPlayer settings.
---
app/src/main/java/org/schabi/newpipe/player/Player.java | 4 +++-
app/src/main/res/values/settings_keys.xml | 2 ++
app/src/main/res/xml/exoplayer_settings.xml | 8 ++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
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 4243c233b..cc75a2c22 100644
--- a/app/src/main/java/org/schabi/newpipe/player/Player.java
+++ b/app/src/main/java/org/schabi/newpipe/player/Player.java
@@ -263,7 +263,9 @@ public final class Player implements PlaybackListener, Listener {
final PlayerDataSource dataSource = new PlayerDataSource(context,
new DefaultBandwidthMeter.Builder(context).build());
loadController = new LoadController();
- renderFactory = new DefaultRenderersFactory(context);
+ renderFactory = new DefaultRenderersFactory(context)
+ .setEnableDecoderFallback(prefs.getBoolean(
+ context.getString(R.string.use_exoplayer_decoder_fallback_key), false));
videoResolver = new VideoPlaybackResolver(context, dataSource, getQualityResolver());
audioResolver = new AudioPlaybackResolver(context, dataSource);
diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml
index f00c25c8c..7d8c48bda 100644
--- a/app/src/main/res/values/settings_keys.xml
+++ b/app/src/main/res/values/settings_keys.xml
@@ -1367,5 +1367,7 @@
streams_notifications_channels
player_notification_screen
+
exoplayer_settings_key
+ use_exoplayer_decoder_fallback_key
diff --git a/app/src/main/res/xml/exoplayer_settings.xml b/app/src/main/res/xml/exoplayer_settings.xml
index fd5637115..f5314182e 100644
--- a/app/src/main/res/xml/exoplayer_settings.xml
+++ b/app/src/main/res/xml/exoplayer_settings.xml
@@ -13,4 +13,12 @@
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
+
+
\ No newline at end of file