Backport from the iOS version: never mark early endings as played, stall warning, Close
- An episode only counts as played when playback reaches the last minute. Saved files that "complete" early (cut-short download, SD card problems) were marked as played on the server, as were streams ending 30-60 s early; now a stream is retried and a file is reported. - "Playing" but the position not moving for 12 s: say so. - Menu -> "Pechar MiniABS" (Latest/Shows/Saved and the player): save the position, stop playback and close the app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2c23ec9131
commit
a6d2c8b2d2
4 files changed
+43
-5
No files matched your search
@@ -85,6 +85,9 @@ public class PlayerService extends Service implements MediaPlayer.OnPreparedList
|
||||
private long playingSince;
|
||||
|
||||
private long lastTick;
|
||||
private int stallPos = -1; // position last seen moving
|
||||
private long stallSince;
|
||||
private boolean stallWarned;
|
||||
private float listened; // seconds listened since the last sync
|
||||
private long lastSync;
|
||||
private volatile boolean syncing;
|
||||
@@ -552,10 +555,16 @@ public class PlayerService extends Service implements MediaPlayer.OnPreparedList
|
||||
public void onCompletion(MediaPlayer p) {
|
||||
if (p != mp) return;
|
||||
int pos = positionMs(), dur = durationMs();
|
||||
// Old Android's streamer "completes" when the connection drops. Treat that as an error.
|
||||
if (!local && dur > 0 && pos < dur - 30000) {
|
||||
// Only playback that got to (nearly) the end counts as listened; anything else is never
|
||||
// reported as played. Old Android's streamer "completes" when the connection drops, and a
|
||||
// saved file cut short (SD card, interrupted copy) "completes" early too.
|
||||
if (dur > 0 && pos < dur - 60000) {
|
||||
lastPosMs = pos;
|
||||
retryStream("Perdeuse a conexión, reconectando…");
|
||||
if (!local && contentUrl != null) {
|
||||
retryStream("Perdeuse a conexión, reconectando…");
|
||||
} else {
|
||||
fail("O ficheiro rematou antes de tempo (" + Util.clock(pos) + "). Proba a descargalo de novo.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
state = ENDED;
|
||||
@@ -672,6 +681,16 @@ public class PlayerService extends Service implements MediaPlayer.OnPreparedList
|
||||
App.setProgress(ep.id, lastPosMs / 1000.0, dur, false);
|
||||
if (now - lastSync > SYNC_EVERY) syncNow(false);
|
||||
if (now - playingSince > 60000) retries = 0;
|
||||
// "playing" but not moving for 12 s: say so instead of staying silent
|
||||
if (lastPosMs != stallPos) {
|
||||
stallPos = lastPosMs;
|
||||
stallSince = now;
|
||||
stallWarned = false;
|
||||
} else if (!stallWarned && now - stallSince > 12000) {
|
||||
stallWarned = true;
|
||||
status = "A reprodución quedou parada. Proba a pausar e reproducir de novo.";
|
||||
android.widget.Toast.makeText(this, status, android.widget.Toast.LENGTH_LONG).show();
|
||||
}
|
||||
if (sleepAt > 0 && now >= sleepAt) {
|
||||
sleepAt = 0;
|
||||
pause();
|
||||
|
||||
Reference in new issue
Block a user