feat: add onLoop event - #2047
Open
yoreljenkins wants to merge 1 commit into
Open
Conversation
yoreljenkins
marked this pull request as ready for review
August 25, 2026 14:23
Author
|
@cookpete This PR introduces the onLoop event! Please check if this is an implementation that you would like. I have a lot of usecases for this event, mostly tracking based. |
|
this is the only feature i'm missing from this package!! would be great if this could be added. @cookpete |
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.
Adds an
onLoopcallback that fires when native looping restarts the media.endedis deliberately never fired when theloopattribute is set, so there is currently no way to know a video has looped.onLoopdetects the restart fromtimeupdate, the current time jumping from the end of the media back to the start which works for every player in the library, not just<video>. It is gated on the element'sloopproperty, so nothing fires unless native looping is on.iterationcounts completed loops from1and resets when a newsrcloads.onTimeUpdatestill passes through untouched, andonLoopis filtered out of the props forwarded to the underlying element.The one false positive is seeking from within the last ~0.5s back to the first ~0.5s while looping, indistinguishable from a real loop at the event level. A backward seek anywhere else is correctly ignored.
Tests cover loop counting, backward-seek rejection,
loopoff, andonTimeUpdatepass-through.