<Page
    x:Class="YMhut.Box.WinUI.Views.MediaPlayerPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid x:Name="Root" Background="#0F1110" PointerMoved="Root_PointerMoved" KeyDown="Root_KeyDown" IsTabStop="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <CommandBar
            x:Name="TopCommandBar"
            Grid.Row="0"
            DefaultLabelPosition="Right"
            Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
            Padding="18,8">
            <AppBarButton Label="打开文件" Click="OpenFile_Click" />
            <AppBarButton Label="小窗" Click="CompactOverlay_Click" />
            <AppBarButton Label="普通窗口" Click="NormalWindow_Click" />
            <AppBarButton Label="全屏" Click="Fullscreen_Click" />
            <AppBarButton Label="退出全屏" Click="ExitFullscreen_Click" />
        </CommandBar>

        <Grid Grid.Row="1">
            <MediaPlayerElement
                x:Name="PlayerElement"
                AreTransportControlsEnabled="False"
                Stretch="Uniform"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch" />

            <Border
                x:Name="FullscreenControls"
                VerticalAlignment="Bottom"
                Margin="24"
                CornerRadius="24"
                Padding="18"
                Background="#DD171717"
                Visibility="Collapsed">
                <StackPanel Spacing="12">
                    <Grid ColumnSpacing="12">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Spacing="4">
                            <TextBlock x:Name="NowPlayingText" Foreground="White" FontSize="16" FontWeight="SemiBold" Text="尚未打开媒体" />
                            <TextBlock x:Name="FullscreenHintText" Foreground="#CCFFFFFF" Text="全屏模式下鼠标静止 3 秒后控制台会自动隐藏。" />
                        </StackPanel>
                        <StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
                            <Button Content="普通窗口" Click="NormalWindow_Click" />
                            <Button Content="小窗" Click="CompactOverlay_Click" />
                            <Button Content="退出全屏" Click="ExitFullscreen_Click" />
                        </StackPanel>
                    </Grid>

                    <Slider
                        x:Name="PlaybackPositionSlider"
                        Minimum="0"
                        Maximum="100"
                        Value="0"
                        PointerPressed="PlaybackPositionSlider_PointerPressed"
                        PointerReleased="PlaybackPositionSlider_PointerReleased"
                        ValueChanged="PlaybackPositionSlider_ValueChanged" />

                    <Grid ColumnSpacing="12">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <StackPanel Orientation="Horizontal" Spacing="8">
                            <Button x:Name="PlayPauseButton" Content="播放" Click="PlayPause_Click" />
                            <Button Content="停止" Click="Stop_Click" />
                        </StackPanel>

                        <TextBlock Grid.Column="1" x:Name="TimeText" Foreground="White" VerticalAlignment="Center" Text="00:00 / 00:00" />

                        <StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="8">
                            <TextBlock Text="音量" Foreground="#DDFFFFFF" VerticalAlignment="Center" />
                            <Slider x:Name="VolumeSlider" Width="160" Minimum="0" Maximum="1" Value="0.8" ValueChanged="VolumeSlider_ValueChanged" />
                        </StackPanel>

                        <StackPanel Grid.Column="3" />

                        <StackPanel Grid.Column="4" Orientation="Horizontal" Spacing="8">
                            <TextBlock Text="倍速" Foreground="#DDFFFFFF" VerticalAlignment="Center" />
                            <ComboBox x:Name="SpeedBox" Width="120" SelectionChanged="SpeedBox_SelectionChanged">
                                <ComboBoxItem Content="0.75x" Tag="0.75" />
                                <ComboBoxItem Content="1.0x" Tag="1.0" IsSelected="True" />
                                <ComboBoxItem Content="1.25x" Tag="1.25" />
                                <ComboBoxItem Content="1.5x" Tag="1.5" />
                                <ComboBoxItem Content="2.0x" Tag="2.0" />
                            </ComboBox>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </Border>
        </Grid>
    </Grid>
</Page>
