-
Notifications
You must be signed in to change notification settings - Fork 845
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
AndroidAudioError java.lang.IllegalStateException during setSource #1703
Comments
UpdateIt definitely has something to do with
|
Thanks for the report. Is there a reason to call |
Hi, The function will have to loop every seconds. It's something to do with my internal hardware test for mobile phones. One of them is phone speaker. This function is supposed to repeated the same .mp3 sound while speaking something until it received respond from user. I set the countdown to 15 seconds hence the specific 15 loop. The whole function is actually longer than that and even have Riverpod state. But it contain internal company code so i rather avoid showing it here. The main thing here is that my Flutter sample above that comes with the report definitely reproduce the issue so it's either the .mp3 file itself, or something else entirely. |
But the loop is not And it's true, something changed in the last update, which may is responsible to cause the error, see: This means, yes, there is room for improvement, but I would blame the android MediaPlayer lib for that, as it shouldn't throw, like you wouldn't expect. We are planning to switch anyways, see #1526. But also this test does not replicate any real world scenario: var playCounter = 0:
final player = AudioPlayer();
await player.setReleaseMode(ReleaseMode.stop);
await player.setSource(AssetSource(
'sound/one.mp3',
),
);
player.onPlayerComplete.listen((_) async {
if (playcounter >= 15) return;
playCounter++;
await player.stop();
await player.resume();
});
await player.resume(); Or just activate the loop mode and wait 15 seconds with |
I'm not sure if the intention is to set a new source 15 times, even if it is the same for testing purposes. |
This issue was closed by the stale bot due to inactivity. |
Hey, is this correct? on the init method:
} the on the event: onPop: () async { Is this creating a different player for each sound? |
Checklist
Current bug behaviour
I'm writing a function that will keep playing audio file on loop. This is what it looked like from my method.
This error will not happen if i untick 'Uncaught Exception' in VSCode which obviously is undesired. And the app still crash regardless after a few loops.
Expected behaviour
The player played a sound on loop without issues.
Steps to reproduce
flutter run
on the code sample.Code sample
Code sample
pubspec.yaml
Affected platforms
Android
Platform details
OPPO Reno 5 Pro 256GB, Using ColorOS 13 (Android 13) API Level 33.
AudioPlayers Version
5.2.1
Build mode
debug
Audio Files/URLs/Sources
https://voca.ro/1fURFPHbF0zJ
Screenshots
No response
Logs
Full Logs
Debugger Log
Console Log
Flutter doctor:
Related issues / more information
#1611
Working on PR
no way
The text was updated successfully, but these errors were encountered: