Buffer-depth-correct now-playing metadata (iOS + Android)#1
Open
jamneck wants to merge 4 commits into
Open
Conversation
Correlates AVPlayerItem.currentDate() (from HLS PROGRAM-DATE-TIME) against the public play_history feed instead of trusting /now-playing's live-edge value directly, so listeners whose buffer lags the live edge see the song actually reaching their ears. Falls back to existing behavior whenever the date/history isn't available or the station is in live DJ mode. Reviewed against a Codex adversarial pass: fixed an unsynchronized-access race on historyCache/historyFetchedAt (URLSession completion queues for the now-playing poll and the play_history refresh both touch it), and reordered so the history fetch only fires when a correction is actually possible. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Correlates Player.getCurrentLiveOffset() (Media3, thread-safe handoff to the main looper) against the public play_history feed instead of trusting /now-playing's live-edge value directly, so listeners whose buffer lags the live edge see the song actually reaching their ears. Falls back to existing behavior whenever the offset/history isn't available or the station is in live DJ mode. Reviewed against a Codex adversarial pass: fixed an unsynchronized-access race on historyCache/historyFetchedAtMs (the metadata updater's executor is a thread pool, not single-threaded, so overlapping polls could race), and scoped the onMetadataUpdate JSON payload rewrite to only fire when a correction actually happens (was previously unconditional). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
play_historyfeed, instead of trusting the live-edge/now-playingvalue directly — fixes now-playing being wrong for any listener whose HLS buffer lags the live edge.AVPlayerItem.currentDate()(reads HLSPROGRAM-DATE-TIME, which MediaMTX already emits — no server pipeline change needed).Player.getCurrentLiveOffset()(Media3), via a thread-safe handoff to the main looper.Test plan
./gradlew compileDebugJavaWithJavac→ BUILD SUCCESSFULswiftc -parseclean (fullswift build/xcodebuildneeds an installed iOS SDK not available in this sandbox — needs a real device/simulator build before shipping)🤖 Generated with Claude Code