Skip to content

feat(desktop): expose whether the first frame has been rendered - #263

Open
comprido96 wants to merge 1 commit into
kdroidFilter:masterfrom
comprido96:feat/desktop-first-frame
Open

comprido96 wants to merge 1 commit into
kdroidFilter:masterfrom
comprido96:feat/desktop-first-frame

Conversation

@comprido96

Copy link
Copy Markdown

Problem

A UI that keeps a loader or a placeholder over the video needs to know when the first frame of a media is on screen. isLoading is not that signal: it is forced to false after three seconds without frames, and it also covers seeks. The decoded frame (currentFrameState) is internal.

Change

VideoPlayerState.hasRenderedFirstFrame: false after openUri / openFile until a frame of the new media has been handed to the surface. Snapshot-observable.

  • macOS and Windows derive it from currentFrameState, which every open clears (releaseAllResources).
  • Linux keeps the last frame on the surface across an open, so it tracks a flag of its own, reset in openUri and set by the first non-null frame.
  • The interface default is false, so Android, iOS and web report false for now. I can extend it to those platforms if you prefer it there before merging.

Testing

  • :mediaplayer:compileKotlinJvm passes. Android and the other targets only see the interface default.
  • On macOS, the same condition ("a frame was handed to currentFrameState") drove the loader of a desktop app during integration.
  • I could not exercise this exact code in a headless Gradle test: the native capture timer needs the AppKit main run loop. Windows and Linux are compiled, not run.

Prepared with an AI coding assistant (Claude Code) while integrating the library into a macOS desktop app, and tested as described above. Happy to adjust, split or drop anything that does not fit the project.

🤖 Generated with Claude Code

A caller that shows a loader or a placeholder over the video needs to know
when there is a picture to show. isLoading is not that signal (it is forced
off after three seconds without frames, and it covers seeks), and the decoded
frame itself (currentFrameState) is internal.

Add VideoPlayerState.hasRenderedFirstFrame: false after openUri/openFile until
a frame of the new media has been handed to the surface. macOS and Windows
derive it from currentFrameState, which every open clears; Linux keeps the
last frame on the surface across an open, so it tracks the flag on its own.
Other platforms report false for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants