The music plays some randomly selected tracks, say 1,2,3,4,5,6.
Tracks 1 to 5 are music, and 6 is the gun sound.
So some code structured like this will play all tracks randomly, but also trigger the flash only when track 6 is started .....
do
{
... Make random number for TrackNum,1-6...