I want to continuously play music in my app on loop similar to many game apps available on the store.
However I am not sure when to initialize the music loop start and how to stop it. I created a class which contains the logic to start and stop the music.
Also My App Structure is like this
Main.dart
Wrapper.dart
(Here is where I did try initializing Audioplayer this is called to check login so a new instance of the player is created and the music overlaps)
>> Signin.dart
(If not signed in redirects here)
>> Home.dart
(If signed in redirects here)
class Music {
AudioCache cache;
AudioPlayer player;
void _playFile() async{
player = await cache.play('my_audio.mp3');
}
void _stopFile() {
player?.stop();
}
}