Skip to content

Commit

Permalink
Fix performance issues with seeking while audio is playing (katspaugh…
Browse files Browse the repository at this point in the history
…#2045)

* fix seekTo performance issues while playing audio
  • Loading branch information
todoroff authored and sandiz committed Sep 1, 2021
1 parent aedf1b7 commit 8cb7863
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
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 @@ -917,20 +917,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

0 comments on commit 8cb7863

Please sign in to comment.