background Audio plays in Unity Editor but does not play in web player

Hey Guys

I have a car game, and all of the engine sounds are working in the editor and compiled web player. But as soon as i add in the background music it stops working in the Complied Web Player version.

here is the code:

var BackgroundMusic : AudioClip = null;
var BackgroundMusicVolume : float = 0.6;

private var backgroundMusic : AudioSource = null;

function Start () {

	backgroundMusic = gameObject.AddComponent(AudioSource);
	backgroundMusic.loop = true;
	backgroundMusic.playOnAwake = true;
	backgroundMusic.clip = BackgroundMusic;
//	backgroundMusic.maxVolume = BackgroundMusicVolume;
//	backgroundMusic.minVolume = BackgroundMusicVolume;
	backgroundMusic.volume = BackgroundMusicVolume;


Any help will be greatly appreciated.


Ill answer this myself.

Rather than add the music via code i just dragged the audio clip into the game, creating a 2D Audio Source game object and i just clicked the play on awake and loop. I feel a little silly really :stuck_out_tongue: