Podlite 1.12: set speed and skipping silences before the audio opens; reopen on a skip toggle

ExoPlayer 2.18 sets up skipping silences when it opens the audio, so the engine now gets both settings before
prepare, and turning the option on or off while an episode plays reopens it at the same spot. Tested on the
Xperia J against test/mock_abs.py: 2x speed, silences skipped, the toggle mid-play, notification buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
XoséandClaude Opus 5.5 committed 2026-11-01 22:33:51 +01:00
1 parent 666a7eb8cd
commit c771aa01bd
2 files changed
+18 -2

No files matched your search

@@ -121,6 +121,7 @@ final class ExoEngine implements Engine {
public void setVolume(float v) { player.setVolume(v); }
/** Before prepare for skipping silences to work: ExoPlayer 2.18 switches it on only when it sets up the audio. */
public void setSpeed(float speed, boolean skipSilence) {
player.setPlaybackParameters(new PlaybackParameters(speed));
player.setSkipSilenceEnabled(skipSilence);
+17 -2
View File
@@ -68,6 +68,7 @@ public class PlayerService extends Service implements Engine.Listener, AudioMana
private boolean prepared;
private String sourceUrl; // what the engine was opened with, to reopen it in the other engine
private boolean fallback; // this episode didn't decode in ExoPlayer: Android's MediaPlayer
private boolean engineSkip; // whether the engine was opened skipping silences
private String coverFor; // the notification and lock screen's cover
private Bitmap cover;
private Episode ep;
@@ -456,6 +457,10 @@ public class PlayerService extends Service implements Engine.Listener, AudioMana
sourceUrl = url;
mp = Platform.newEngine(getApplicationContext(), fallback);
mp.setListener(this);
// before the audio is opened: ExoPlayer sets up skipping silences only then
Prefs prefs = Prefs.get(this);
engineSkip = prefs.skipSilence();
mp.setSpeed(prefs.speed(), engineSkip);
try {
if (local) {
mp.setSource(new File(url), null);
@@ -491,10 +496,20 @@ public class PlayerService extends Service implements Engine.Listener, AudioMana
}
}
/** Speed or skipping silences changed in the player screen or Settings. */
/** Speed or skipping silences changed in the player screen or Settings. Speed changes as it plays; skipping
* silences only takes effect when the audio is opened, so the episode is reopened here at the same spot. */
void applySpeed() {
Prefs p = Prefs.get(this);
if (mp != null) mp.setSpeed(p.speed(), p.skipSilence());
if (mp == null) return;
if (Platform.SPEED && prepared && sourceUrl != null && p.skipSilence() != engineSkip) {
boolean wasPlaying = state == PLAYING;
resumeMs = positionMs();
lastPosMs = resumeMs;
playOnPrepared = wasPlaying;
prepare(sourceUrl, null);
return;
}
mp.setSpeed(p.speed(), engineSkip);
}
private void start() {