Skip to content

Commit

Permalink
Fix: [Envelope] react to media element volume changes (#3003)
Browse files Browse the repository at this point in the history
* Fix: [Envelope] react to media element volume changes

* 7.0.1
  • Loading branch information
katspaugh authored Jul 11, 2023
1 parent 4991237 commit 0c466b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wavesurfer.js",
"version": "7.0.0",
"version": "7.0.1",
"license": "BSD-3-Clause",
"author": "katspaugh",
"description": "Navigable audio waveform player",
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,14 @@ class EnvelopePlugin extends BasePlugin<EnvelopePluginEvents, EnvelopePluginOpti
this.initSvg()
this.initFadeEffects()

// Sync the plugin's volume with the media element volume
const media = this.wavesurfer.getMediaElement()
const onMediaVolumeChange = () => this.setVolume(media.volume)
media.addEventListener('volumechange', onMediaVolumeChange)

this.subscriptions.push(
() => media.removeEventListener('volumechange', onMediaVolumeChange),

this.wavesurfer.on('redraw', () => {
const duration = this.wavesurfer?.getDuration()
if (!duration) return
Expand Down

0 comments on commit 0c466b6

Please sign in to comment.