You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
I am having issues playing audioplayer in a widget: I have all the initialization code in the initState of the widhet it seems that the audioplayer is initialized everytime the widget is opened in another widget, and remains initialized, which is OK on one hand, because it continues to play when I move from one page to another, but not OK because it is creating more and more audioplayers. I noticed it because I am using a subscription stream to send a message that the audio is playing, and more and more of these messages came through.
Am I doing something wrong? Should I do the initialization in a different way? Or is it just that the objects linger around and wait to be discarded in some kind of garbage collection?
The text was updated successfully, but these errors were encountered:
You can initialize your player separately from your widget or in a static field. In fact, I recommend moving all logic to play/pause, etc. out of the widget state into a separate class (e.g. audio controller) - you only need one for the entire app. The widget in the UI should simply display the current state of playing by subscribing to notifications from the audio controller in it initState().
I am having issues playing audioplayer in a widget: I have all the initialization code in the initState of the widhet it seems that the audioplayer is initialized everytime the widget is opened in another widget, and remains initialized, which is OK on one hand, because it continues to play when I move from one page to another, but not OK because it is creating more and more audioplayers. I noticed it because I am using a subscription stream to send a message that the audio is playing, and more and more of these messages came through.
Am I doing something wrong? Should I do the initialization in a different way? Or is it just that the objects linger around and wait to be discarded in some kind of garbage collection?
The text was updated successfully, but these errors were encountered: