1

I would like to add the following example https://suragch.medium.com/background-audio-in-flutter-with-audio-service-and-just-audio-3cce17b4a7d a button that replaces the playlist with another one and plays it.

I created a function that removes all the songs from the previous playlist and loads the new one. However, I can't get it to play. How do I do this?

void changeAndPlayPlaylist() async {
  final pageManager = getIt<PageManager>();
  pageManager.removeAll();
  await pageManager.loadPlaylist2();
  pageManager.play;
}

If instead I make two buttons; one that replaces and one that plays works correctly.

void changePlaylist() async {
  final pageManager = getIt<PageManager>();
  pageManager.removeAll();
  await pageManager.loadPlaylist2();
}


void play() {
  final pageManager = getIt<PageManager>();
  pageManager.play();
}

Thanks for your help

I would have expected that combining the two functions into one would work

elle D
  • 25
  • 4

0 Answers0