Save the failed session's position before preparing the episode again
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
056c53a808
commit
7214c57624
2 files changed
+87
-1
No files matched your search
@@ -1734,7 +1734,14 @@ document.addEventListener('alpine:init', () => {
|
||||
_playEpisodeLocal(track, options = {}) {
|
||||
const ref = this._episodeRef(track);
|
||||
if (!ref) return;
|
||||
const previous = this._episode;
|
||||
this._endEpisode('stop');
|
||||
// Preparing the same episode again (for example Play after its
|
||||
// source failed): its final report must reach the register
|
||||
// first, or the server would resume from an older checkpoint
|
||||
// and refuse the report as superseded afterwards.
|
||||
const before = previous && previous.episodeId === ref.episode_id
|
||||
? previous.writes : null;
|
||||
const token = ++this._episodeToken;
|
||||
const raw = options.position_seconds;
|
||||
const known = raw != null && raw !== '' && Number.isFinite(Number(raw));
|
||||
@@ -1789,7 +1796,13 @@ document.addEventListener('alpine:init', () => {
|
||||
};
|
||||
if (known) body.position_ms = Math.round(position * 1000);
|
||||
this._updateMediaSession();
|
||||
return this._episodeRequest(ref.episode_id, 'playback', body)
|
||||
const prepare = () => this._episode?.token === token
|
||||
? this._episodeRequest(ref.episode_id, 'playback', body)
|
||||
: null;
|
||||
const request = before
|
||||
? Promise.race([before, new Promise(resolve => setTimeout(resolve, 5000))]).then(prepare)
|
||||
: prepare();
|
||||
return Promise.resolve(request)
|
||||
.then(info => {
|
||||
const episode = this._episode;
|
||||
// Another item was chosen meanwhile: never start this one.
|
||||
|
||||
Reference in new issue
Block a user