Describe the bug
A clear and concise description of what the bug is.
To Reproduce
play a sound using startPlayer.
before the sound has finished playing, play another sound with startPlayer
An exception is thrown "Exception: Player is not stopped", and the second sound is not played (though the first sound is stopped).
In prior releases, this worked as expected: the old sound stopped and the new sound began to play. From inspecting the code, it looks like startPlayer awaits stop() -- so it seems like this is also the intended behavior.
I downgraded to 9.17.8 and the behavior is as expected again. I haven't figured out exactly when the regression occurred.
Flutter Sound is not coded as to allow several startPlayer() at the same time on a given player. If you want to do that you must create two Flutter Sound players.
You probably had an exception that you ignored in the previous versions.
The problem we had is that the player was left in an undefined state after an exception. It was a problem, especially with ‘play from stream’.
Now, the player is correctly closed when we encounter an exception.
It's hard to argue with the guy who designed the thing, but a few observations:
I have tried to "await player.stopPlayer();" before playing the second sound... And it doesn't work, throws exactly the same exception!
The startPlayer code actually calls "await stopPlayer()" itself right above the error message... and you can see from the logs that it thinks it has stopped ("stopPlayerCompleted: true"). But the next thing in the logs is "Player is not stopped!". Again, stopping doesn't seem to be working correctly!
It worked perfectly before, definitely no exceptions unless they were caught internally to the soundPlayer.
Yes, you are probably right that there is a bug in Flutter Sound.
I was first confused that you was trying to play two files at the same time on a Player.
But Flutter Sound closes the previous file if already playing. That has always been like that.
That's OK and this is not an undocumented feature. Your code is OK.
It's too bad that you have no idea when the regression occurred. There has been many versions since 9.17.8.
This is probably a bug in closePlayer() :
either it does not close correctly the player.
either it closes correctly the player but returns a bad vale 'isPlaying'.
I released a new 9.10.5 that may fix your issue. But I am not sure that this patch is not harmful.
If you want you can try Taudio 9.10.5.
It is really easy to upgrade to Taudio. Just 5 minutes.
There is a little guide here to do the upgrade.