Continuous music on selected scenes?

I found this code to play music through out multiple scenes, is there a way to play the music only on selected scenes and not all?

using UnityEngine;
using System.Collections;
 
public class example : MonoBehaviour {
void Awake() {
DontDestroyOnLoad(transform.gameObject);
}
}

Do you mean you want the music to pause on certain scenes, but then pick back up at the same place in other scenes. Yes, yo can do that.
To get the loaded level use Application.loadedLevel or Application.loadedLevelName. You can audio.Pause() the music and because its gameobject has been set to DontDestroyOnLoad(), it should resume when you call audio.Play() in the specific scenes.

Additionally, you can get the specific position by calling audio.timeSamples.

http://answers.unity3d.com/questions/413203/continuous-music-across-multiple-scenes.html