Mark Lynch
Mark Lynch

Reputation: 11

How can I play an audio file in WPF mediaElement without waiting for it to load the file completely ?

I have several large WAV files (about 5 - 10 minutes in play time) that I want to play via WPF MediaElement. But when I set the source to one of these files and call the Play method, MediaElement seems to wait untill the file has loaded completely before begining to play it. Any one know of a way to get it to play while the rest of the file is loaded. Or suggest another way to play these WAV files back, not using MediaElement?

Upvotes: 1

Views: 5850

Answers (1)

Aqeel
Aqeel

Reputation: 689

Add mediaElement controll to your window then add following code to play the audio file

mediaElement1.LoadedBehavior = MediaState.Manual;
                mediaElement1.Source = new Uri("C://test.wma", UriKind.RelativeOrAbsolute);
                mediaElement1.Play();

this code works for me.

Upvotes: 3

Related Questions