Android (Tasker): You’re driving home, rocking out to Queen, and suddenly Facebook interrupts your music to let you know you have a new comment. Your rhythm is now ruined. Fortunately Tasker can save you and your groove with this action.
The video above from WonderHowTo shows how to create a Tasker action that will automatically enable Do Not Disturb mode whenever you turn on your music. It will then disable DND once you stop playing music. You can still modify your settings to allow certain high priority notifications to get through even if you’re listening to music, but it should prevent the annoying social media stuff from interrupting your flow every 30 seconds.
How to Stop Notifications from Interrupting Your Music [WonderHowTo]