Skip to content

Seek to the live edge for CMTime.positiveInfinity - #27

Open
vincentborko wants to merge 1 commit into
skiptools:mainfrom
vincentborko:fix/seek-live-edge
Open

Seek to the live edge for CMTime.positiveInfinity#27
vincentborko wants to merge 1 commit into
skiptools:mainfrom
vincentborko:fix/seek-live-edge

Conversation

@vincentborko

Copy link
Copy Markdown
Contributor

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.positiveInfinity already exists in SkipAV, but the Android AVPlayer.seek(to:) fed it straight into Int64(time.seconds * 1000.0) — there seconds is Double.infinity, which saturates to Long.MAX_VALUE, so Player.seekTo receives 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) via seekTo(duration), else Player.seekToDefaultPosition() — the live edge for live streams (per the Media3 docs / your note on the issue).
  • numeric times → unchanged.
  • other non-numeric times (indefinite/invalid/negativeInfinity) → ignored rather than seeking to a garbage offset, matching AVPlayer's no-op for such seeks.

seek(to:completionHandler:) now delegates to seek(to:) so every seek path shares the same handling.

Bridging

No bridging changes — the fix lives entirely inside the existing #elseif SKIP branch; the iOS path (@_exported import AVKit) is untouched.

Testing

swift test is green on both platforms (native XCTest + transpiled Robolectric). testAVPlayerAdditions now also exercises the positiveInfinity/indefinite/invalid seek 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

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>
@cla-bot cla-bot Bot added the cla-signed label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMTime.positiveInfinity unavailable in Skip; how to seek to live edge for HLS?

1 participant