I am trying to load and play a wave file using:
SoundPlayer simpleSound = new SoundPlayer(@"pack://application:,,,/MyAssembly;component/Sounds/10meters.wav");
simpleSound.Play();
With no success. I get a System.NotSupportedException
:( see below.
System.NotSupportedException: The URI prefix is not recognized.
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(Uri requestUri)
at System.Media.SoundPlayer.LoadSync()
at System.Media.SoundPlayer.LoadAndPlay(Int32 flags)
at System.Media.SoundPlayer.Play()
I looked over google and SO trying to find a solution, nothing worked. Playing the file with a direct path works fine
SoundPlayer simpleSound = new SoundPlayer(@"D:\Projects\MyAssembly\Sounds\10meters.wav");
simpleSound.Play();
I also checked MyAssembly content, the resource is there.
Does SoundPlayer
not support packing or there anything I am not doing correctly?