Source property
Figure 2.
The Source attribute of the tag takes the full path of the video.
The following code snippet sets the Source property to a .wmv file.
<MediaElement Source="E:\BOLLY WOOD VIDEO\song.wmv" />
For Example
Drag and drop a MediaElement and three Button controls on the page and name them mediaElement1, Play Button, Pause Button. The form looks like this.
Figure 3.
XAML code
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="LayoutRoot" Background="White" Width="460" Height="360">
<MediaElement Height="238" HorizontalAlignment="Left" Margin="12,12,0,0"Name="mediaElement1"
VerticalAlignment="Top" Width="388" Volume="1" LoadedBehavior="Manual"UnloadedBehavior="Manual" Source="E:\BOLLY WOOD VIDEO\song.wmv" />
<Button Content="Play" Height="28" HorizontalAlignment="Left" Margin="12,260,0,0"
Name="PlayButton" VerticalAlignment="Top" Width="88" Click="PlayButton_Click" />
<Button Content="Pause" Height="30" HorizontalAlignment="Right" Margin="0,258,255,0"
Name="PauseButto" VerticalAlignment="Top" Width="85" Click="PauseButto_Click" />
</Grid>
</Window>
Now double click on the play button and add the following code.
Private Sub PlayButton_Click(ByVal sender As System.Object,ByVal eAsSystem.Windows.RoutedEventArgs)
Me.mediaElement1.Play()
End Sub
Now double click on the pause button and add the following code.
Private Sub PauseButto_Click(ByVal sender As System.Object,ByVal eAsSystem.Windows.RoutedEventArgs)
Me.mediaElement1.Stop()
End Sub
Now run the application press CTRL+F5.
Figure 4.
Now to play the video click on the play Button.
Figure 5.
To Pause the Video click on the Pause Button.
Figure 6.