Skip to content

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

Open
vincentborko wants to merge 2 commits into
skiptools:mainfrom
vincentborko:fix/seek-live-edge
Open

vincentborko wants to merge 2 commits into
skiptools:mainfrom
vincentborko:fix/seek-live-edge

Conversation

@vincentborko

@vincentborko vincentborko commented Jul 24, 2026 •

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. (AVFoundation itself raises NSInvalidArgumentException for these, so there is no iOS behavior to mirror beyond not seeking.)

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 seek on both platforms and the indefinite/invalid seeks on Android only: on the macos-15-intel runner AVFoundation raised for the indefinite seek, which the first CI run caught. (It did not raise on a local arm64 run.) 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.

Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR.

🤖 Generated with Claude Code

@cla-bot cla-bot Bot added the cla-signed label Jul 24, 2026
vincentborko and others added 2 commits September 25, 2026 19:47
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>
AVFoundation raises NSInvalidArgumentException for a seek to an indefinite
time ("Seeking is not possible to time {INDEFINITE}"), which failed the
macos-15-intel job. The ignore-non-numeric behavior is Android-only, so the
test now runs those two seeks under #if SKIP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Qh5nkgtHPgaRKT7fJK1Db
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