Fix muting behavior with the MediaElement backend #1966
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short description of changes:
wavesurfer.js
currently handles muting the media by setting the backend's volume to 0 and remembering the previous value, but it also checks whether the backend maintains muting state and uses it to override its own. This is currently used by theMediaElement
to make wavesurfer aware of muting/volume changes performed directly on theAudio
element, but muting throughwavesurfer.js
itself triggers a backend volume change without changing the backend'sisMuted
state, so the end result is the volume switching to 0 and the media being unmuted, leading to inconsistent and erratic behavior.This PR adds an optional
setMute
method to backends so that theMediaElement
backend can handle muting by itself.Breaking in the external API:
None.
Breaking changes in the internal API:
None (the
setMute
method is optional so that other backends do not need change—but if we are ok with breaking the internal API by requiring thesetMute
method, we can move thewavesurfer.js
code to the WebAudio backend).Related Issues and other PRs:
I believe the “immediately unmuting” behavior was introduced by #1635. This PR fixes it while still handling external changes to the
Audio
element state.refs #1931
refs #1703