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

onDurationChanged called constantly on Android #136

Closed
tantzygames opened this issue Apr 8, 2019 · 9 comments · Fixed by #1460
Closed

onDurationChanged called constantly on Android #136

tantzygames opened this issue Apr 8, 2019 · 9 comments · Fixed by #1460
Labels
discussion platform-android Affects the android platform

Comments

@tantzygames
Copy link

tantzygames commented Apr 8, 2019

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

@luanpotter
Copy link
Member

@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

@subhash279
Copy link
Contributor

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

@tantzygames
Copy link
Author

tantzygames commented Jun 18, 2019

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.

@saviourdog
Copy link

same problem

@nt4f04uNd
Copy link

Same here

@pierrea
Copy link

pierrea commented Nov 13, 2020

+1

@erickzanardo
Copy link
Member

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

@fdietze
Copy link
Contributor

fdietze commented May 5, 2021

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

@Gustl22 Gustl22 added the platform-android Affects the android platform label Aug 23, 2022
@Gustl22
Copy link
Collaborator

Gustl22 commented Aug 23, 2022

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

Gustl22 added a commit that referenced this issue Apr 6, 2023
#1460)

# Description

Unlike on other platforms, onDuration is constantly called on Android.
This PR avoids calling onDuration on every position event.
OnDuration is still once called with the correct duration after having
prepared the source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion platform-android Affects the android platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants