audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

onDurationChanged called constantly on Android

Open tantzygames opened this issue 5 years ago • 9 comments

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

tantzygames avatar Apr 08 '19 08:04 tantzygames

@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 avatar Jun 04 '19 23:06 luanpotter

@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?

subhash279 avatar Jun 11 '19 17:06 subhash279

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.

tantzygames avatar Jun 18 '19 23:06 tantzygames

same problem

saviourdog avatar Sep 20 '19 06:09 saviourdog

Same here

nt4f04uNd avatar Nov 05 '19 17:11 nt4f04uNd

+1

pierrea avatar Nov 13 '20 19:11 pierrea

@luanpotter this discussion is still valid? Is this still something that we want to add?

erickzanardo avatar Mar 25 '21 21:03 erickzanardo

What I hear from the comments here, is that an async mechanism is needed to know when the player is ready.

fdietze avatar May 05 '21 11:05 fdietze

This should be easy to fix by moving the onDuration event to when prepared was called.

Gustl22 avatar Aug 23 '22 20:08 Gustl22