<UserControl
    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"
    mc:Ignorable="d" 
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input" 
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
    x:Class="SilverlightMediaPlayer.MediaPlayer"
    xmlns:sw ="clr-namespace:System.Windows;assembly=System.Windows"
    Width="Auto" Height="Auto">
    
    <UserControl.Resources>
        <ControlTemplate x:Key="PlayButtonTemplate" TargetType="ToggleButton">
            <Grid x:Name="grid" Background="Transparent">
                <sw:VisualStateManager.VisualStateGroups>
                    <sw:VisualStateGroup x:Name="FocusStates">
                        <sw:VisualState x:Name="Focused">
                            <Storyboard>
                            </Storyboard>
                        </sw:VisualState>
                        <sw:VisualState x:Name="Unfocused">
                            <Storyboard/>
                        </sw:VisualState>
                    </sw:VisualStateGroup>
                    <sw:VisualStateGroup x:Name="CommonStates">
                        <sw:VisualState x:Name="Normal">
                            <Storyboard/>
                        </sw:VisualState>
                        <sw:VisualState x:Name="MouseOver">
                            <Storyboard>
                            </Storyboard>
                        </sw:VisualState>
                        <sw:VisualState x:Name="Pressed">
                            <Storyboard/>
                        </sw:VisualState>
                    </sw:VisualStateGroup>
                    <sw:VisualStateGroup x:Name="CheckStates">
                        <sw: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>
                        </sw:VisualState>
                        <sw: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>
                        </sw:VisualState>
                    </sw:VisualStateGroup>
                </sw: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>
    </UserControl.Resources>
    
    <Border x:Name="layoutRoot" BorderBrush="Black" >
		<Grid Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="Auto" x:Name="mediaCol"/>
    		</Grid.ColumnDefinitions>
    		<Grid.RowDefinitions>
    			<RowDefinition Height="Auto" x:Name="mediaRow"/>
    			<RowDefinition Height="Auto"/>
    			<RowDefinition Height="Auto" />
    		</Grid.RowDefinitions>

    		<!-- Pauses media playback. -->

            <MediaElement x:Name="media" Margin="5" AutoPlay="False"  Stretch="Uniform"   
                          MediaOpened="media_MediaOpened" 
                          MediaFailed="media_MediaFailed" 
                          Height="300"
                          Width="auto"/>
            <Grid Grid.Row="1">
            	<Grid.ColumnDefinitions>
            		<ColumnDefinition Width="0.787*"/>
            		<ColumnDefinition Width="0.213*"/>
            	</Grid.ColumnDefinitions>
            	<dataInput:Label x:Name="fileInfo" HorizontalAlignment="Left" Margin="0" FontSize="13.333" FontWeight="Bold" Foreground="#FF1198A3" Content="" d:LayoutOverrides="Height" Height="20" VerticalAlignment="Bottom"/>
            </Grid>
    		<Grid Margin="0" Grid.Row="2" Height="44">
    			<Grid.ColumnDefinitions>
    				<ColumnDefinition Width="42"/>
    				<ColumnDefinition Width="44"/>
    				<ColumnDefinition/>
    				<ColumnDefinition Width="64"/>
    				<ColumnDefinition Width="44"/>
    				<ColumnDefinition Width="44"/>
    				<ColumnDefinition Width="62"/>
    			</Grid.ColumnDefinitions>

    			<!-- Begins media playback. -->

<!-- Begins media playback. -->
                <!-- play symbol showing is checked = false, Pause symbol showing is checked = true-->
                <ToggleButton x:Name="playBtn" Template="{StaticResource PlayButtonTemplate}"
                Click="PlayMedia" IsChecked="false"/>

       <!--         <Button x:Name="playBtn" Click="PlayMedia" Margin="2" Width="40" IsEnabled="False" >
    				<Path Fill="White" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" Data="F1 M 15,22L 40,15L 15,7.5L 15,22 Z" Height="20" Margin="5" Width="20"/>
    			</Button> -->

<!-- Stops media playback.-->
    			<Button x:Name="stopBtn" Click="StopMedia"
    				Margin="2" Width="40" Grid.Column="1" IsEnabled="False" >
    				<Path Fill="#FF7F7F7F" Stretch="Fill" Stroke="Black" Height="15" Width="15" UseLayoutRounding="True" Data="F1 M 5, 5 L 5, 10 L 10,10 L 10,5 L 5,5 Z" />

    			</Button>
    			<Grid x:Name="timelineGrid" Margin="0" Grid.Column="2" d:LayoutOverrides="GridBox" Visibility="Collapsed">

    				<Grid.ColumnDefinitions>
    					<ColumnDefinition/>
    					<ColumnDefinition Width="40"/>
    					<ColumnDefinition Width="10"/>
    					<ColumnDefinition Width="40"/>
    				</Grid.ColumnDefinitions>
    				<Slider x:Name="videoSlider" MinWidth="40" Margin="0" ValueChanged="videoSlider_ValueChanged" Maximum="1" />
    				<TextBlock x:Name="currentTimeBlock" Height="16" HorizontalAlignment="Right" Grid.Column="1" Foreground="#FF1198A3" Text="00:00" TextWrapping="Wrap" d:LayoutOverrides="Width"/>
    				<TextBlock Height="16" HorizontalAlignment="Center" Grid.Column="2" Foreground="#FF1198A3" Text="/" TextWrapping="Wrap"/>
    				<TextBlock x:Name="totalTimeBlock" Height="16" HorizontalAlignment="Left" Grid.Column="3" Foreground="#FF1198A3" Text="00:00" TextWrapping="Wrap"/>
    			</Grid>
    			<Slider x:Name="volumnSlider" Width="60" Grid.Column="3" Margin="2" 
                        Value="{Binding ElementName=media, Mode=TwoWay, Path=Volume, UpdateSourceTrigger=Default}" Maximum="1"/>

                <Button x:Name="btnFull" d:LayoutOverrides="HorizontalAlignment" Margin="2" Click="btnFull_Click" Width="40" Grid.Column="4">
    				<Path Height="30" 
    					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" HorizontalAlignment="Stretch" Margin="2" Width="30" RenderTransformOrigin="0.212389379739761,0.208695650100708" />
    			</Button>

    		</Grid>

    	</Grid>
	</Border>
</UserControl>
