setMediaElement not updating progress bar #3266
Closed
jahangiranwari
started this conversation in
General
Replies: 2 comments 16 replies
-
Good catch. I think adding setMediaElement was a bad idea. It essentially requires a re-initialization of the entire waveform and all the events, so I don’t see the point of such a setter. As you can see in the original global player example, it’s possible to simply re-create a wavesurfer instance. |
Beta Was this translation helpful? Give feedback.
10 replies
-
@katspaugh is it safe to assume that |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With the new setMediaElement feature to attach a
<audio>
at runtime we noticed that although we are able to share the same underlying HTMLMediaElement element between two players it doesn't update the progress bar on both players.To demonstrate the issue and using React Global Player example as reference created this gist. When we click Play the track starts playing in the global player and we can seek on either player indicating that they are sharing the same underlying
<audio>
element. But the track player's progress bar doesn't move.On deeper investigation identified the root cause as missing
timeupdate
listener on the newly attached HTMLMediaElement. The same can be confirmed by uncommenting these lines in the same gist.Possible Solutions
One possible solution could be to track the
timeupdate
listener independently of other subscriptions and subscribe/unsubscribe to it insetMediaElement
.Another solution could be to have public methods that would allow us to subscribe/unsubscribe from all player events currently used in initPlayerEvents.
Beta Was this translation helpful? Give feedback.
All reactions