-
Notifications
You must be signed in to change notification settings - Fork 823
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
Error: Attempt to call getDuration in wrong state #266
Comments
While initializing audio player use below method - |
I already listen for onDurationChanged. I would like to show the user the duration of the audio before it starts playing. |
You can get the duration without playing, check this on the example app: https://github.com/luanpotter/audioplayers/blob/master/example/lib/main.dart#L112 |
Yes, I have done that, but I still get the same error.
Some reason it keeps complaining about |
As suggested by @erickzanardo , above example to fetch duration is working fine. I implemented same in demo. |
Did you test with a remote URL? For example, https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3 Or does getDuration() only work with local asset files? If you get it to work with remote URL I would love to see the function for getting a remote URL duration. |
Turns out the duration is working correctly. The files I was testing were not in the proper format. |
The solution proposed by @shikha1992 does not work, unless I set duration of a delay to 500ms (at 250ms it works sometimes). This is definitely a bug. The same code for iOs works without a delay. |
I had the same Problem with getDuration and when i want to read mp3 Tags, i don't want a 250-500ms delay for every single song. |
I've had to implement the delay. I went through hoop after hoop after hoop. Ultimately, I just elected to NOT show or care about the duration until playback started :( Seems I have a lot of flutter code that basically says: if( true == isAndroid ) { /* do all the workaround stuff here because android */ } :( |
Thanks,I fixed the problem with delay 300ms in Android |
I get the following error when trying to get duration for a remote URL. I am trying to get the duration to load before I show the widget because it is really confusing for the user to see a position of 0 and a duration of 0.
The text was updated successfully, but these errors were encountered: