tags:

views:

180

answers:

2

hai i need to play audio files in WPF

am using the following code

    FileTextBox.Text = selectedFileName;
    MediaPlayer mp = new MediaPlayer();
    mp.Open(new Uri(selectedFileName, UriKind.Relative ));
    mp.Play();

its working well, but it doesnt plays the sound. why ???

+2  A: 

Your MediaPlayer object is probably being garbage collected before it has a chance to play the file because it has local scope. Try making the media player object a member variable of a class that has application lifetime and see if this fixes it.

Stu Mackellar
A: 

Please try http://alvas.net/alvas.audio.aspx instead

alex