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.
This commit is contained in:
AudricV 2022-08-18 18:59:45 +02:00 committed by Stypox
parent a4a9957a15
commit 41da8fc05f
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
3 changed files with 13 additions and 1 deletions

View File

@ -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);

View File

@ -1367,5 +1367,7 @@
<string name="streams_notifications_channels_key">streams_notifications_channels</string>
<string name="player_notification_screen_key">player_notification_screen</string>
<!-- ExoPlayer settings -->
<string name="exoplayer_settings_key">exoplayer_settings_key</string>
<string name="use_exoplayer_decoder_fallback_key">use_exoplayer_decoder_fallback_key</string>
</resources>

View File

@ -13,4 +13,12 @@
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="@string/use_exoplayer_decoder_fallback_key"
android:summary="@string/use_exoplayer_decoder_fallback_summary"
android:title="@string/use_exoplayer_decoder_fallback_title"
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
</PreferenceScreen>