-
Notifications
You must be signed in to change notification settings - Fork 11
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
Video Scrubbing Issue #29
Comments
I have noticed this problem before. In Media Foundation API, I think the Media Foundation didn't take this situation into consideration. |
One way to slightly improve this behavior is by implementing a debounce feature for the seek operation, which helps prevent rapid or unnecessary triggering. Wouldn't it be feasible to perform this debouncing on the plugin side? // debounce duration
final Duration debounceTime = const Duration(milliseconds: 100);
// Debounce timer
Timer? _scrubDebounceTimer;
DateTime? _timerStartMoment;
// ...
/// Scrub the video and the animation with a debounce using a duration
/// of [debounceTime].
///
/// The debounce prevents the seek from being updated during any type of
/// scrub operation.
void scrub(Duration duration) {
// if is active create a new timer with the new seek value
if (_scrubDebounceTimer?.isActive ?? false) {
Duration elapsedTime = DateTime.now().difference(_timerStartMoment!);
// cancel the previous action
_scrubDebounceTimer!.cancel();
// evaluate the left duration to throw a seek event
final Duration leftDurationToUpdate = debounceTime - elapsedTime;
// re-recreate a timer with the new duration
_scrubDebounceTimer = Timer(leftDurationToUpdate, () => controller!.seekTo(duration);
return;
}
//
// If the timer is not active or not yet initialized, the timer
// and the datetime are initialize
//
_timerStartMoment = DateTime.now(); // time reference for when the [_seekDebounceTimer] started
_scrubDebounceTimer = Timer(debounceTime, () => controller!.seekTo(duration);
}
// ... |
I prefer not to do it in plugin side because I think API should do only the essential task as possible. In UI level, |
Media Foundation document has a page for scrub How to Perform Scrubbing. Seeking, Fast Forward, and Reverse Play In this example, seeking requests are queued but source code are complicated >.< I think it is necessary to handle Media foundation's async events for better seeking(scrub) but complicated >.< |
Oops... It seems easy to implement according to the webpage you mentioned above, So far I have no idea how to implemet it... orz |
Issue:
When scrubbing through a video, it appears that the preview is stacking frames from the seek requests instead of displaying the correct frame corresponding to the scrubbed position. Is there a way to fix this issue with the Media Foundation API or this management has to be done on frontend?
Current behavior
video_player_win_example.2024-02-21.12-03-57.-.Trim.mp4
Code sample
Flutter doctor
The text was updated successfully, but these errors were encountered: