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: setMediaElement to properly subscribe/unsubscribe media events #3278

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

jahangiranwari
Copy link
Contributor

@jahangiranwari jahangiranwari commented Oct 17, 2023

Short description

When we change the underlying media element using setMediaElement the progress bar would not update as the track was playing. This was because of various media events subscriptions was missing.

Resolves #3266

Implementation details

To ensure that we are properly handling setting of a new media element setMediaElement has been tweaked as follows:

  1. Unsubscribe from all event listeners for current media element
  2. Attach the new media element
  3. Subscribe to media (player) events for newly attached media

How to test it

  1. Create a Wavesurfer instance
  2. Attached another media element using setMediaElement
  3. Play

The progress bar should be updated as the track play progresses.

Screenshots

Checklist

  • This PR is covered by e2e tests
  • It introduces no breaking API changes

- First we unsubscribe from all existing media event listeners
- Then after setting new media element we subscribe to media events
@jahangiranwari jahangiranwari changed the title Fix setMediaElement to properly subscribe/unsubscribe media events Fix: setMediaElement to properly subscribe/unsubscribe media events Oct 17, 2023
Copy link
Owner

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

Looks great, thank you sir!

@katspaugh katspaugh merged commit f5b9490 into katspaugh:main Oct 18, 2023
2 checks passed
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.

2 participants