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

Restore Chosen Playback Speed After Seeking #823

Closed
wants to merge 0 commits into from

Conversation

ganeshh123
Copy link

When seeking using the progress bar, the playback speed is reset to 1.

I've changed the code to restore the playback speed after seeking to the new position in the progress bar.

Comment on lines 62 to 70
await controller.seekTo(context.calcRelativePosition(
controller.value.duration,
globalPosition,
));
// For some reason playback speed gets reset when
// seeking, so it needs to be restored
Future.delayed(const Duration(milliseconds: 1000), () {
controller.setPlaybackSpeed(currentPlaybackSpeed);
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider combining both async calls, one after the other:

final currentPlaybackSpeed = controller.value.playbackSpeed;
await controller.seekTo(context.calcRelativePosition(
      controller.value.duration,
      globalPosition,
    )).then((_) {
  controller.setPlaybackSpeed(currentPlaybackSpeed);
});

@ganeshh123
Copy link
Author

Thanks, I tried that code, but for some reason the speed resets again. Maybe the 1 second wait is necessary?

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