I have an S24 Ultra. I get a similar problem constantly when using wired earpieces. The notification "usb disconnected" rapidly followed by the notification "usb connected" repeatedly appears and stops all audio and puts any audio player into pause mode. I have taken all sorts of actions and some seem to work for a while, only to come back with such a vengeance that I now regret buying this phone. I would happily go back to my old phone but unfortunately I don't have it anymore.
This particular issue has been discussed on other forums, but there is, to date, no solution from Samsung.
Samsung, please do something! I cannot do my work . I must use wired headphones. The issue is possibly notification related. Whenever a notification comes in (perhaps from any source), I immediately get the "disconnected" notification. That notification triggers another usb notification, which rapidly and endlessly swaps between the two notifications.
Sometimes, if I am fast enough, I can tell the system not to inform me with this notification, but I do not always have that option for some reason. I have to do this for both of the two usb notifications. So far, this method has been successful.