public/silverlight/MainPage.xaml
<UserControl
x:Class="SilverlightMediaElement.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
mc:Ignorable="d"
Width="640" Height="360">
<UserControl.Resources>
<Style x:Key="roundThumbStyle" TargetType="Thumb">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Ellipse Stroke="#FFFFFFFF" StrokeThickness="2" Fill="#FF484848"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SliderStyle" TargetType="Slider">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Slider">
<Grid x:Name="Root" Background="Transparent">
<Grid.Resources>
<ControlTemplate x:Key="RightRepeatButtonTemplate">
<Rectangle Height="8" Margin="-5,0,0,0" Grid.Column="0" Grid.ColumnSpan="3"
StrokeThickness="0.5" RadiusY="1" RadiusX="1" Fill="#FF484848"/>
</ControlTemplate>
<ControlTemplate x:Key="LeftRepeatButtonTemplate">
<Rectangle Height="8" Margin="0,0,-5,0" Grid.Column="0" Grid.ColumnSpan="3"
StrokeThickness="0.5" RadiusY="1" RadiusX="1" Fill="#FFAFAFAF"/>
</ControlTemplate>
</Grid.Resources>
<Grid x:Name="HorizontalTemplate">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Grid.Column="0"
IsTabStop="False" Template="{StaticResource LeftRepeatButtonTemplate}"/>
<Rectangle x:Name="LeftTrack" Grid.Row="1" Fill="#00FFFFFF" Cursor="Hand" MouseLeftButtonDown="LeftTrack_MouseLeftButtonDown"/>
<Thumb Background="#00FFFFFF" Height="10" x:Name="HorizontalThumb" Width="10"
Grid.Column="1" Style="{StaticResource roundThumbStyle}" HorizontalAlignment="Left"
DragStarted="HorizontalThumb_DragStarted" DragCompleted="HorizontalThumb_DragCompleted"
Canvas.ZIndex="1"/>
<RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Grid.Column="2"
IsTabStop="False" Template="{StaticResource RightRepeatButtonTemplate}"/>
<Rectangle x:Name="RightTrack" Grid.Column="2" Grid.Row="1" Fill="#00FFFFFF" Cursor="Hand" MouseLeftButtonDown="LeftTrack_MouseLeftButtonDown"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="PlayButtonTemplate" TargetType="ToggleButton">
<Grid x:Name="grid" Background="Transparent">
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="FocusStates">
<vsm:VisualState x:Name="Focused">
<Storyboard>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Unfocused">
<Storyboard/>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="Normal">
<Storyboard/>
</vsm:VisualState>
<vsm:VisualState x:Name="MouseOver">
<Storyboard>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Pressed">
<Storyboard/>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="CheckStates">
<vsm:VisualState x:Name="Checked">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000"
Storyboard.TargetName="playSymbol"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000"
Storyboard.TargetName="pauseSymbol"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Unchecked">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pauseSymbol" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<Grid Margin="11,3,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"
Opacity="1" x:Name="playSymbol" Width="21" Height="22">
<Path Width="14" Height="15" Stretch="Fill" Fill="#FF7F7F7F"
Data="F1 M 15.1997,22.542L 29.7776,14.89L 15.2707,6.99886L 15.1997,22.542 Z "/>
</Grid>
<Grid Margin="11,2,0,0" Opacity="0" x:Name="pauseSymbol" Width="31" Height="15">
<Rectangle Stretch="Fill" Fill="#FF7F7F7F" HorizontalAlignment="Left"
Margin="0,0,0,0" Width="6"/>
<Rectangle Stretch="Fill" Fill="#FF7F7F7F" HorizontalAlignment="Stretch"
Margin="6,0,13,0" Width="6"/>
</Grid>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="MuteButtonTemplate" TargetType="ToggleButton">
<Grid Background="Transparent" Cursor="Hand">
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="FocusStates">
<vsm:VisualState x:Name="Focused">
<Storyboard>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Unfocused">
<Storyboard/>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="Normal">
<Storyboard/>
</vsm:VisualState>
<vsm:VisualState x:Name="MouseOver">
<Storyboard>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Pressed">
<Storyboard/>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="CheckStates">
<vsm:VisualState x:Name="Checked">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000"
Storyboard.TargetName="volumeSymbol"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Unchecked">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000"
Storyboard.TargetName="volumeSymbol"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<Grid HorizontalAlignment="Left" VerticalAlignment="Top"
Width="17">
<Path HorizontalAlignment="Left" Stretch="Fill"
Fill="#FF7F7F7F" Data="F1 M 23.1457,26.5056L 23.1457,33.8944L 25.7913,33.8944L 28.8235,37.4722L 30.5346,37.4722L 30.5665,23.0833L 28.8995,23.0833L 25.8679,26.5056L 23.1457,26.5056 Z "
Width="7.421" Height="14.389" UseLayoutRounding="False"
Margin="0,6.5,0,6.5"/>
<Grid HorizontalAlignment="Right" Width="7.003" x:Name="volumeSymbol" Margin="0,10">
<Path HorizontalAlignment="Right" VerticalAlignment="Stretch"
Width="2.398"
Data="M0.5,0.5 C0.5,0.5 2.5939558,2.7128265 2.5946648,7.0504856 C2.5953746,11.391507 0.50033337,13.889001 0.50033337,13.889001"
Stretch="Fill" Stroke="#FF7F7F7F" Margin="0,0,-0.398,0" UseLayoutRounding="False"/>
<Path HorizontalAlignment="Stretch" Margin="2.4,2.384,2.317,1.584" VerticalAlignment="Stretch"
Data="M0.5,0.50000006 C0.5,0.50000006 1.4786903,2.1275051 1.4781417,4.9569001 C1.4776551,7.4670725 0.35717732,9.892808 0.35717732,9.892808" Stretch="Fill" Stroke="#FF7F7F7F" UseLayoutRounding="False"/>
<Path HorizontalAlignment="Left" Margin="0,4.36,0,3.46" VerticalAlignment="Stretch" Width="1.542"
Data="M0.5,0.5 C0.5,0.5 1.0412779,1.4903735 1.042276,3.1459465 C1.0429831,4.3189368 0.66544437,6.0685911 0.66544437,6.0685911" Stretch="Fill" Stroke="#FF7F7F7F" d:LayoutOverrides="Width"/>
</Grid>
</Grid>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
<Grid Background="Transparent">
<ContentPresenter Width="Auto"/>
</Grid>
</ControlTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="Black" Width="640" Height="360">
<MediaElement Grid.Row="0" Grid.Column="0" Width="640" Height="360"
CacheMode="BitmapCache" AutoPlay="false" Name="media">
</MediaElement>
<Button x:Name="bigPlayButton" Template="{StaticResource ButtonTemplate}"
Click="BigPlayButton_Click" Grid.Row="0" Visibility="Collapsed">
<Canvas Width="100" Height="100">
<Path Width="100" Height="100" Canvas.Left="0" Canvas.Top="0" Stretch="Fill"
Fill="#77000000" Data="F1 M 15,0L 85,0C 93.2843,0 100,6.71573 100,15L 100,85C 100,93.2843 93.2843,100 85,100L 15,100C 6.71573,100 0,93.2843 0,85L 0,15C 0,6.71573 6.71573,0 15,0 Z "/>
<Path Width="40.8182" Height="47.1328" Canvas.Left="34.6439"
Canvas.Top="27.6003" Stretch="Fill" Fill="#FFFFFFFF"
Data="F1 M 75.4621,51.1667L 34.6439,27.6003L 34.6439,74.7331L 75.4621,51.1667 Z "/>
</Canvas>
</Button>
<TextBox Margin="25,25,0,0" Name="textBox1" VerticalScrollBarVisibility="Auto" Height="146" VerticalAlignment="Top" HorizontalAlignment="Left" Width="235" />
<Button Content="" Height="36" HorizontalAlignment="Right" x:Name="FullscreenButton" VerticalAlignment="Bottom" Width="31" Click="FullscreenButton_Click" Opacity="0" Background="#00000000" Cursor="Hand" />
<Grid x:Name="transportControls" VerticalAlignment="Bottom" Height="40" Background="#FF000000"
Grid.Row="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="0" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="10" />
<ColumnDefinition Width="Auto" MinWidth="10" />
</Grid.ColumnDefinitions>
<!-- play symbol showing is checked = false, Pause symbol showing is checked = true-->
<ToggleButton x:Name="playPauseButton" Template="{StaticResource PlayButtonTemplate}"
Click="PlayPauseButton_Click" IsChecked="false" Cursor="Hand"/>
<Grid x:Name="time" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>
<TextBlock x:Name="currentTimeTextBlock" Margin="0,1.5,10,0" Height="12"
FontFamily="Verdana" FontSize="10" Text="00:00" TextWrapping="Wrap"
Foreground="#FFFFFFFF" FontStyle="Normal" HorizontalAlignment="Right"
TextAlignment="Right" Grid.Column="0"/>
<Slider x:Name="timelineSlider" Margin="0,2,0,-1"
Maximum="1" Style="{StaticResource SliderStyle}" Grid.Column="1"
ValueChanged="TimelineSlider_ValueChanged"
Value="0"/>
<TextBlock Margin="0,1.5,0,0" Height="12" FontFamily="Verdana" FontSize="10"
Text="" TextWrapping="Wrap" Foreground="#FFFFFFFF"
FontStyle="Normal" HorizontalAlignment="Center" TextAlignment="Right"
Grid.Column="2"/>
<TextBlock x:Name="totalTimeTextBlock" Margin="0,1.5,0,0" Height="12"
FontFamily="Verdana" FontSize="10" Text="00:00" TextWrapping="Wrap"
Foreground="#FFFFFFFF" FontStyle="Normal" HorizontalAlignment="Left"
TextAlignment="Right" Grid.Column="3"/>
</Grid>
<ToggleButton IsChecked="false" Grid.Column="3" x:Name="muteButton"
Template="{StaticResource MuteButtonTemplate}" Click="MuteButton_Click"
VerticalAlignment="Center" Margin="0,0,6,0" Cursor="Hand"/>
<Slider Grid.Column="4" HorizontalAlignment="Stretch" Margin="3,0,0,0"
VerticalAlignment="Center" Maximum="1" x:Name="volumeSlider"
Background="#FF777777" Style="{StaticResource SliderStyle}" Width="50"
Value="{Binding ElementName=media, Mode=TwoWay, Path=Volume, UpdateSourceTrigger=Default}"/>
<Button x:Name="fullScreenButton" Grid.Column="5" Margin="8,10,4,10" Click="FullScreenButton_Click"
Template="{StaticResource ButtonTemplate}" VerticalAlignment="Center" Cursor="Hand">
<Path Height="14.375" HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" RenderTransformOrigin="0.212389379739761,0.208695650100708"
Data="M10.181361,8.375 L12.844413,11.008244 L14.125,9.7418737 L14.125,14.375 L9.675765,14.374833 L10.906104,13.158273 L8.125,10.408315 L10.181361,8.375 z M3.9666855,8.375 L6,10.431361 L3.3667567,13.094413 L4.6331258,14.375 L0,14.375 L0.00016707927,9.925765 L1.2167276,11.156104 L3.9666855,8.375 z M9.4918737,0 L14.125,0 L14.124833,4.449235 L12.908273,3.2188957 L10.158315,6 L8.125,3.943639 L10.758244,1.2805867 L9.4918737,0 z M0,0 L4.449235,0.00016686507 L3.2188957,1.2167276 L6,3.9666855 L3.943639,6 L1.280587,3.3667567 L0,4.6331258 L0,0 z"
Fill="#FF7F7F7F" Stretch="Fill" Stroke="#FF000000" StrokeThickness="0" />
</Button>
</Grid>
</Grid>
</UserControl>