Seek to the live edge for CMTime.positiveInfinity - #27
Open
vincentborko wants to merge 1 commit into
Open
Conversation
AVPlayer.seek(to: .positiveInfinity) is the standard way to jump to the live edge of an HLS stream, but the transpiled seek fed the value straight into Int64(seconds * 1000), producing a garbage offset. Map positiveInfinity to a known duration (VOD) or Player.seekToDefaultPosition() (live edge), and ignore other non-numeric times. Fixes skiptools#19. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Motivation
Fixes #19. On Apple platforms
player.seek(to: .positiveInfinity)is the idiomatic way to jump to the live edge of an HLS stream.CMTime.positiveInfinityalready exists in SkipAV, but the AndroidAVPlayer.seek(to:)fed it straight intoInt64(time.seconds * 1000.0)— theresecondsisDouble.infinity, which saturates toLong.MAX_VALUE, soPlayer.seekToreceives a meaningless offset instead of the live edge..indefinite/.invalid(NaN seconds) were likewise passed through unchecked.Fix
In the transpiled
seek(to:):positiveInfinity→ clamp to a known duration (VOD) viaseekTo(duration), elsePlayer.seekToDefaultPosition()— the live edge for live streams (per the Media3 docs / your note on the issue).indefinite/invalid/negativeInfinity) → ignored rather than seeking to a garbage offset, matching AVPlayer's no-op for such seeks.seek(to:completionHandler:)now delegates toseek(to:)so every seek path shares the same handling.Bridging
No bridging changes — the fix lives entirely inside the existing
#elseif SKIPbranch; the iOS path (@_exported import AVKit) is untouched.Testing
swift testis green on both platforms (native XCTest + transpiled Robolectric).testAVPlayerAdditionsnow also exercises thepositiveInfinity/indefinite/invalidseek paths. Note: the live-edge vs. saturated-offset difference only manifests against a real HLS stream (Robolectric has no media pipeline), so that addition is a smoke check of the new code paths rather than a behavioral assertion.🤖 Generated with Claude Code