Friends,
Here is the code snippet to embed a Video File in Silverlight.
I tried it with .wmv file and it worked fine.
Hope it helps someone !
Cheers
Anand
XAML File Content
<Border x:Name="BorderVideo" BorderThickness="5" BorderBrush="Blue" CornerRadius="25" Canvas.ZIndex="1" Width="670" Height="550" >
<StackPanel Orientation="Vertical">
<MediaElement x:Name="ChurchSong"
Width="640"
Height="480"
AutoPlay="False"
Source="MVI_0957_WMV V9.wmv" Canvas.ZIndex="0" >
</MediaElement>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button x:Name="buttonStopandRewind" Content="Stop and Rewind" Width="100" Margin="10,10,10,10" Click="buttonStopandRewind_Click" />
<Button x:Name="buttonPause" Content="Pause" Width="100" Margin="10,10,10,10" Click="buttonPause_Click" />
<Button x:Name="buttonPlay" Content="Play" Width="100" Margin="10,10,10,10" Click="buttonPlay_Click" />
<Button x:Name="buttonSkip" Content="Skip 5 Secs" Width="100" Margin="10,10,10,10" Click="buttonSkip_Click" />
</StackPanel>
</StackPanel>
</Border>
.cs File Content
private void buttonStopandRewind_Click(object sender, RoutedEventArgs e)
{
this.ChurchSong.Stop();
}
private void buttonPause_Click(object sender, RoutedEventArgs e)
{
this.ChurchSong.Pause();
}
private void buttonPlay_Click(object sender, RoutedEventArgs e)
{
this.ChurchSong.Play();
}
private void buttonSkip_Click(object sender, RoutedEventArgs e)
{
this.ChurchSong.Position = this.ChurchSong.Position.Add(new TimeSpan(0, 0, 5));
}
No comments:
Post a Comment