From 936bfa029ef5fd6cc85d9f0fd448c4c19e767822 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 30 Aug 2024 18:11:26 +0200 Subject: [PATCH] Increase buffer duration (#7362) When podcasts use dynamic ad insertion and the media file changes between different network requests, users might experience jumps. Now, try to basically download the whole episode as soon as one hits the play button. That should avoid most of the jumps. --- .../playback/service/internal/ExoPlayerWrapper.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java index 8a5c60b5d..9816c2231 100644 --- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java +++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java @@ -47,7 +47,6 @@ import androidx.media3.ui.TrackNameProvider; import de.danoeh.antennapod.net.common.UserAgentInterceptor; import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting; import de.danoeh.antennapod.playback.service.R; -import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.net.common.HttpCredentialEncoder; import de.danoeh.antennapod.net.common.NetworkUtils; import de.danoeh.antennapod.model.playback.Playable; @@ -97,10 +96,10 @@ public class ExoPlayerWrapper { private void createPlayer() { DefaultLoadControl.Builder loadControl = new DefaultLoadControl.Builder(); - loadControl.setBufferDurationsMs(30000, 120000, + loadControl.setBufferDurationsMs((int) TimeUnit.HOURS.toMillis(1), (int) TimeUnit.HOURS.toMillis(3), DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS, DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS); - loadControl.setBackBuffer(UserPreferences.getRewindSecs() * 1000 + 500, true); + loadControl.setBackBuffer((int) TimeUnit.MINUTES.toMillis(5), true); trackSelector = new DefaultTrackSelector(context); exoPlayer = new ExoPlayer.Builder(context, new DefaultRenderersFactory(context)) .setTrackSelector(trackSelector) @@ -154,7 +153,7 @@ public class ExoPlayerWrapper { } }); simpleCache = new SimpleCache(new File(context.getCacheDir(), "streaming"), - new LeastRecentlyUsedCacheEvictor(50 * 1024 * 1024), new StandaloneDatabaseProvider(context)); + new LeastRecentlyUsedCacheEvictor(100 * 1024 * 1024), new StandaloneDatabaseProvider(context)); initLoudnessEnhancer(exoPlayer.getAudioSessionId()); }