I found here a solution for playing an audio file in WPF, which I extracted into a method, and calling this method with another method. But when a symbol PlaySound()is called sound, it is not reproduced. Does anyone have an idea why this is happening? Sound files are also marked as content, but changing the type of the resource also did not solve the problem?
My sound reproduction method:
private void PlaySound()
{
Uri uri = new Uri(@"pack://application:,,,/Sounds/jabSound.wav");
var player = new MediaPlayer();
player.Open(uri);
player.Play();
}
Then I call the method in this way, but it doesn’t play the sound file, PlaySound();
source
share