Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(windows): add topSeek event params as mentioned in docs #4456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Lyqqt
Copy link

@Lyqqt Lyqqt commented Mar 6, 2025

Summary

The seek event on the Windows platform does not include the parameters mentioned in the doc when dispatched; these need to be added.

Doc:onSeek

Motivation

Improve the platform code.

Changes

When dispatching the topSeek event, write the params currentTime and seekTime.

CurrentTime is current playback progress of the media.

SeekTime indicates the progress of the media when the seek event is triggered, and its value is derived from the progress of PositionChanged.

Test plan

  1. Case 1. Using the videoRef.current.seek(seconds); function.
  2. Case 2. Dragging the native Windows control component.

Expect: onSeek work fine.

<Video
  ref={videoRef}
  controls={true}
  onSeek={(e: onSeekData) => console.log(`currentTime=${e.currentTime} and seekTime=${seekTime}`)}
/>

strong_this->m_reactContext.DispatchEvent(*strong_this, L"topSeek", nullptr);
if (auto mediaPlayer = strong_this->m_player) {
auto currentTimeInSeconds = mediaPlayer.PlaybackSession().Position().count() / 10000000;
auto seekTimeInSeconds = strong_this->m_mediaPlayerPosition / 10000000;
Copy link
Author

@Lyqqt Lyqqt Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If seekTime needs to be of integer type:

seekTimeInSeconds is actually equal to currentTimeInSeconds. But their sources of meaning are slightly different. I'm unsure whether m_mediaPlayerPosition is necessary.

Example: {"currentTime": 274, "seekTime": 274}

Otherwise, it will be like this:

Example: {"currentTime": 274, "seekTime": 274.4}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To Triage
Development

Successfully merging this pull request may close these issues.

1 participant