audioplayers
audioplayers copied to clipboard
onDurationChanged called constantly on Android
This is reported to have been solved in #107 but it's happening to me in 0.10.0.
Also occurring in 0.10.1
@Kretin1 , that seems to be by design. The method is called every position update.
I believe it might be because while the audio buffers the duration might change.
Is it causing any problems to you though? If so, we can consider changing that. But it seems to me that you could just not listen to that event hahaha
@luanpotter I think onDurationChanged should be called just once to know the entire length of the audio. This is how it works even with html5 audio. Also it might be useful to have another listener onLoad to perform any task like moving the position of the audio before playing it. It would be interesting to know your view on this. Currently I am doing this in onDurationChanged but if its called repeatedly it won't be possible.
Also onDurationChanged is not called after setUrl() on android but it is called on ios. Is this something you are looking into?
I agree. I expected to use onDurationChanged to know when a clip has been loaded or changed. Currently I need to keep my own variable, and check if it's changed... something that I expect would be more efficient if done in the native code.
But most importantly, whatever you choose it should not work differently for Android and iOS.
same problem
Same here
+1
@luanpotter this discussion is still valid? Is this still something that we want to add?
What I hear from the comments here, is that an async mechanism is needed to know when the player is ready.
This should be easy to fix by moving the onDuration
event to when prepared
was called.