https://grok.com fixed it.
@Override
protected void onDestroy() {
// Release the MediaController and player
if (mediaController != null) {
mediaController.stop();
mediaController.release();
mediaController = null;
}
if (controllerFuture != null) {
controllerFuture.cancel(true);
}
if (playerView != null) {
playerView.setPlayer(null);
}
// Stop the foreground service
Intent serviceIntent = new Intent(this, PlaybackService.class);
stopService(serviceIntent);
super.onDestroy();
}