I could play wav audio file in Resources with the code below.
The files were added to Resources by:
Practice_AccessResource > File > Properties > Resources > Audio > Add > ExistingFiles
//only can play audio file with SoundPlayer class.
System.IO.Stream strForMusic = Practice_AccessResourceFile.Properties.Resources.TaDa;
System.Media.SoundPlayer sountPlayer = new
System.Media.SoundPlayer(strForMusic);
sountPlayer.Play();
FYI, the project name is the "Practice_AccessResourceFile", and name of wav audio file is TaDa.wav , sorry that I could not change the name for u.
Is there any way to play audio file with MediaPlayer in WPF?
System.IO.Stream stream = Properties.Resources.TaDa;
MediaPlayer musicPlayer = new System.Windows.Media.MediaPlayer();
//musicPlayer.Open(new System.Uri(stream)); //This is not working
//musicPlayer.Play();
I have to play two music simultaneously, and it's not possible with SoundPlayer.
Can anyone help me play audio file with MediaPlayer class in WPF?