Prevent websites from taking over audio on iPhone?
If your device is jailbroken, you can install Don't Kill the Beat. This prevents apps other than Music.app from playing music. To allow an app to play music (e.g. a video in Safari), pause the music in Music.app manually yourself, such as with the Control Center.