When a headset is unplugged or a Bluetooth device disconnected, the audio stream automatically reroutes to the built-in speaker. If you listen to music at a high volume, this can be a noisy surprise.
Users usually expect apps that include a music player with onscreen playback controls to pause playback in this case. Other apps, like games that don't include controls, should keep playing. The user can adjust the volume with the device's hardware controls.
Handle audio focus -->
The player will handle the audio focus shifts. Basically It would:
https://github.com/owncloud/android/assets/111801812/32cbe89d-71cb-4f25-97f3-8eafbd518029
Handle audio becoming noisy -->
https://github.com/owncloud/android/assets/111801812/e1ef4c66-1b8b-4bed-8d3e-f998bed28ec6
You can see here after turning of bluetooth the playback pauses.