how to dispose the rest of audio player instances when I play another one?

34 Views Asked by At

I have implemented chat app the messages can be text, video, images and recorded audio. i have a problem concerning recorded audio message, I used audioplayers package to implement recording audio and playing it features. the list of messages are displayed with ListView; I want when I play an audio, if there is another audioWidgets that are playing or paused they will be restarted again this is the link of audio player widget : [code](https://pastebin.com/B7AHdzXB)

1

There are 1 best solutions below

0
Dali Hmida On

instantiating the audio player in the widget was the problem in my case. so I create one instance of audio player with Cubit and I used every time when I play a recorded audio