1

What is the correct way to pause MediaPlayer in Jetpack Compose? Suppose my UI has a list of sound items, and when clicking an item the sound is playing. I'm trying to figure out the best approach to pause the sound when the user goes background.

Nick is tired
  • 6,860
  • 20
  • 39
  • 51

1 Answers1

0

Your MediaPlayer should be usable through a ViewModel. In the onPause() callback in your Activity/Fragment, you should stop your MediaPlayer through your ViewModel

Sigma
  • 532
  • 3
  • 8