I wrote my app with Jetpack Compose and navigation component. Also using MVVM. I have a single activity with five screen. when user enter to list screen1 from home screen, maybe play a sound. I want to stop and release Media Player when user press back and leave screen. because of Navigating with Compose, there is no fragments , I have just composable screen associate with view model. now I wondering where should I release my resources like Media Player? because Media Player is UI thing, my view model does not know anything about it.
My solouion: using DisposableEffect so on Lifecycle.Event.ON_STOP , I stop media player