Playing a song in WPF

Abhisek
Posted by Abhisek under WPF category on | Views : 2462
Use the following code to play a song using WPF. You have to specify the path of the song. First you have to add a MediaElement.

<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<MediaElement Margin="10,10,11,72" Name="mediaElement1" Volume="50" Source="D:\1942 A LOVE STORY\EK LADKI KO.mp3" LoadedBehavior="Play">
<MediaElement.BitmapEffect>
<OuterGlowBitmapEffect />
</MediaElement.BitmapEffect>
</MediaElement>
</Grid>
</Window>


When the window will load it will start playing the song.

Comments or Responses

Login to post response