1

I'm trying to get one .wav file to play as ambient music though when another sound is played, it halts the ambient music and I've tried doing play-loop and tried the various sync, async , load.

I think I'm missing something here. Thank you in advance.

RoR
  • 15,934
  • 22
  • 71
  • 92

2 Answers2

2

Check this question on SO and the suggestions made there. The basic problem is that SoundPlayer can only play one sound stream at a time - if you want to play multiple sounds concurrently you need a different solution.

Community
  • 1
  • 1
BrokenGlass
  • 158,293
  • 28
  • 286
  • 335
1

It is possible to use Windows Media Player for the ambient sound, and play another sound with SoundPlayer at the same time:

// example begin
WMPLib.WindowsMediaPlayer mediaPlayer = new WMPLib.WindowsMediaPlayer();
mediaPlayer.URL = "<theAudioFile>";
mediaPlayer.settings.setMode("loop", true);
mediaPlayer.controls.play();
// example end

A reference to Windows Media Player assembly needs to be added to the solution as well.

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Nemo
  • 11
  • 1