Flutter-AssetsAudioPlayer
Flutter-AssetsAudioPlayer copied to clipboard
2 different audio assets keep playing together?!
Flutter Version
My version : 3.3
Lib Version
My version : ^3.0.6
Platform (Android / iOS / web) + version
Platform : 11
Describe the bug
On my screen I have 2 separate Widgets. On touching Widget1 soundEffect1.mp3 plays... while on touching Widget2 soundEffect2.mp3 plays The problem is after I have touched Widget1 & its sound has played correctly.... Now when I touch Widget2... both sounds play?!?! By that I mean both : soundEffect2.mp3 & soundEffect1.mp3 I have tried all versions of instantiations... but I cant get soundEffect2.mp3 to play alone.
In the class of both widgets I have declared AssetAudioPlayers with all these options, but nothing works
final AssetsAudioPlayer _assetsAudioPlayer1 = AssetsAudioPlayer();//widget1
final AssetsAudioPlayer _assetsAudioPlayer2= AssetsAudioPlayer();//widget2
final AssetsAudioPlayer _assetsAudioPlayer1 = AssetsAudioPlayer.withId("Id1");//widget1
final AssetsAudioPlayer _assetsAudioPlayer2 = AssetsAudioPlayer.withId("Id2");//widget2
inal AssetsAudioPlayer _assetsAudioPlayer1 = AssetsAudioPlayer.newPlayer();//widget1
final AssetsAudioPlayer _assetsAudioPlayer2 = AssetsAudioPlayer.newPlayer();//widget2
in all the above cases I have played them via
_assetsAudioPlayer1.open(Audio("assets/soundEffect1.mp3"));//in widget1
_assetsAudioPlayer2.open(Audio("assets/soundEffect2.mp3"));//in widget2
I finally tried
AssetsAudioPlayer.playAndForget(Audio("assets/soundEffect1.mp3"));//in widget1
AssetsAudioPlayer.playAndForget(Audio("assets/soundEffect2.mp3"));//in widget2
So after all these attempts I guess Im missing something.... How do I only play one sound... and not the other sound together. I have checked this on an emulator and 2 phones... the final effect of them both playing to gether is always there. awaiting any help. thanks, YOhan