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

Fix performance issues with seeking while audio is playing #2045

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
wavesurfer.js changelog
=======================

Next (unreleased)
-----------------

- Fix performance issues with `seekTo` while audio is playing (#2045)

4.1.1 (24.09.2020)
------------------
- Revert Code cleanup for Observer class (#2069)
Expand Down
8 changes: 0 additions & 8 deletions src/wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,20 +900,12 @@ export default class WaveSurfer extends util.Observer {
}
this.fireEvent('interaction', () => this.seekTo(progress));

const paused = this.backend.isPaused();
// avoid draw wrong position while playing backward seeking
if (!paused) {
this.backend.pause();
}
// avoid small scrolls while paused seeking
const oldScrollParent = this.params.scrollParent;
this.params.scrollParent = false;
this.backend.seekTo(progress * this.getDuration());
this.drawer.progress(progress);

if (!paused) {
this.backend.play();
}
this.params.scrollParent = oldScrollParent;
this.fireEvent('seek', progress);
}
Expand Down