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 muting behavior with the MediaElement backend #1966

Merged
merged 2 commits into from
Jun 15, 2020
Merged

Fix muting behavior with the MediaElement backend #1966

merged 2 commits into from
Jun 15, 2020

Conversation

ClearlyClaire
Copy link
Contributor

@ClearlyClaire ClearlyClaire commented Jun 15, 2020

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 the MediaElement to make wavesurfer aware of muting/volume changes performed directly on the Audio element, but muting through wavesurfer.js itself triggers a backend volume change without changing the backend's isMuted 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 the MediaElement 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 the setMute method, we can move the wavesurfer.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

Copy link
Contributor

@thijstriemstra thijstriemstra left a comment

Choose a reason for hiding this comment

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

thanks. can you also add a single-sentence entry to the changelog (under 4.0.0 section)?

@ClearlyClaire
Copy link
Contributor Author

Done!

@thijstriemstra thijstriemstra merged commit 8b52847 into katspaugh:master Jun 15, 2020
@osheroff
Copy link
Contributor

hey folks, this PR broke a few tests (that were previously hidden behind some eslint issues). I'm not sure if the tests are incorrect or if the code is, but maybe someone wants to look?

@thijstriemstra
Copy link
Contributor

@osheroff fixed with #1968 that was merged just now.

sandiz pushed a commit to sandiz/wavesurfer.js that referenced this pull request Sep 1, 2021
* Fix muting behavior with the MediaElement backend

* Document changes
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.

None yet

3 participants