Hi chef,
I've made a simple example of what I was suggesting. You were on the right track, just needed a few minor changes :)
The red button switches between layouts, and the blue button stops the music. You'll notice that when you switch between layouts, the music continues to play without stopping then restarting (because of our variable check)! However turning off the music, sets the variable back to 0, so when you switch to another layout, the music will restart again!
MusicOnOffExample
Music was supplied by tulamide :) You can find more free music by tulamide here.
Hope that makes things a little clearer :)