<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:danmaku="using:Bili.App.Controls.Danmaku"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Controls.Player"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    xmlns:uwp="using:Richasy.FluentIcon.Uwp">
    <Style TargetType="local:BiliMediaPlayer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:BiliMediaPlayer">
                    <Grid>
                        <Grid
                            x:Name="RootGrid"
                            Background="Black"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                            <MediaPlayerElement x:Name="MediaPlayerElement" AreTransportControlsEnabled="False" />
                            <Grid x:Name="DanmakuContainer">
                                <danmaku:DanmakuView
                                    x:Name="DanmakuView"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ProgressPosition="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ProgressSeconds}"
                                    ViewModel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.DanmakuViewModel}" />
                            </Grid>
                            <Rectangle
                                x:Name="InteractionControl"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Fill="Transparent" />
                            <muxc:ProgressRing
                                Width="40"
                                Height="40"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                IsActive="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsBuffering}" />
                            <Grid RowSpacing="8">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Grid
                                    Padding="12,0"
                                    VerticalAlignment="Bottom"
                                    ColumnSpacing="12">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid
                                        x:Name="TempMessageContainer"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        Visibility="Collapsed">
                                        <Grid
                                            x:Name="TempMessageGrid"
                                            Padding="16,8"
                                            Background="{ThemeResource MediaTransportControlsPanelBackground}"
                                            CornerRadius="{StaticResource ControlCornerRadius}">
                                            <TextBlock
                                                x:Name="TempMessageBlock"
                                                MaxWidth="320"
                                                TextWrapping="Wrap" />
                                        </Grid>
                                    </Grid>
                                    <controls:PlayerTip
                                        x:Name="PreviousViewInformer"
                                        Title="{loc:Locale Name=ViewHistory}"
                                        Grid.Column="1"
                                        HorizontalAlignment="Right"
                                        ActionContent="{loc:Locale Name=ContinuePreviousView}"
                                        AdditionalTitle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ProgressTipCountdown}"
                                        CloseCommand="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ClearSourceProgressCommand}"
                                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.JumpToLastProgressCommand}"
                                        IsOpen="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowProgressTip, Mode=TwoWay}"
                                        Message="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ProgressTip}" />

                                    <controls:PlayerTip
                                        x:Name="NextVideoInformer"
                                        Title="{loc:Locale Name=PlayNextVideo}"
                                        Grid.Column="1"
                                        HorizontalAlignment="Right"
                                        ActionContent="{loc:Locale Name=PlayNow}"
                                        AdditionalTitle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.NextVideoCountdown}"
                                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PlayNextCommand}"
                                        IsOpen="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowNextVideoTip, Mode=TwoWay}"
                                        Message="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.NextVideoTipText}" />
                                </Grid>

                                <local:InteractionChoicePanel
                                    x:Name="ChoiceContainer"
                                    Grid.Row="1"
                                    HorizontalAlignment="Center"
                                    ViewModel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel}"
                                    Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsInteractionVideo, Converter={StaticResource BoolToVisibilityConverter}}" />

                                <Grid Grid.Row="2" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.HasSubtitles}">
                                    <Grid
                                        x:Name="SubtitleContainer"
                                        Margin="24,4"
                                        HorizontalAlignment="Center"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.CanShowSubtitle}">
                                        <Grid
                                            Background="{ThemeResource MediaTransportControlsPanelBackground}"
                                            CornerRadius="{StaticResource OverlayCornerRadius}"
                                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.CurrentSubtitle, Converter={StaticResource ObjectToVisibilityConverter}}">
                                            <TextBlock
                                                x:Name="SubtitleBlock"
                                                MaxWidth="1200"
                                                Margin="16,8"
                                                HorizontalAlignment="Center"
                                                FontSize="22"
                                                Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.CurrentSubtitle}"
                                                TextTrimming="CharacterEllipsis"
                                                TextWrapping="Wrap" />
                                        </Grid>
                                    </Grid>
                                </Grid>

                                <local:BiliMediaTransportControls
                                    x:Name="MediaTransportControls"
                                    Grid.Row="3"
                                    Margin="12"
                                    TransportVisibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowMediaTransport, Converter={StaticResource BoolToVisibilityConverter}}"
                                    ViewModel="{TemplateBinding ViewModel}" />
                            </Grid>
                        </Grid>
                        <Grid
                            x:Name="PlayErrorContainer"
                            MinHeight="200"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Background="{ThemeResource LayerFillColorDefaultBrush}"
                            CornerRadius="{StaticResource OverlayCornerRadius}"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError}">
                            <StackPanel
                                Padding="20,12"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
                                CornerRadius="{StaticResource OverlayCornerRadius}"
                                Spacing="8">
                                <Image
                                    Width="120"
                                    HorizontalAlignment="Center"
                                    Source="ms-appx:///Assets/ERROR_rgba.png"
                                    Stretch="Uniform" />
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ErrorText}"
                                    TextAlignment="Center" />
                                <Button
                                    x:Name="RefreshButton"
                                    HorizontalAlignment="Center"
                                    Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReloadCommand}"
                                    Content="{loc:Locale Name=Refresh}" />
                            </StackPanel>
                        </Grid>
                        <Button
                            x:Name="ExitFullPlayerButton"
                            AutomationProperties.Name="{loc:Locale Name=BackToDefaultView}"
                            Style="{StaticResource AccentButtonStyle}"
                            Width="32"
                            Height="32"
                            Margin="32"
                            Padding="0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ExitFullPlayerCommand}"
                            ToolTipService.ToolTip="{loc:Locale Name=BackToDefaultView}"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowExitFullPlayerButton}">
                            <uwp:RegularFluentIcon FontSize="14" Symbol="Dismiss20" />
                        </Button>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LivePlayerStyle" TargetType="local:BiliMediaPlayer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:BiliMediaPlayer">
                    <Grid>
                        <Grid
                            x:Name="RootGrid"
                            Background="Black"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                            <MediaPlayerElement x:Name="MediaPlayerElement" AreTransportControlsEnabled="False" />
                            <Grid x:Name="CoverContainer" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsLiveAudioOnly, Converter={StaticResource BoolToVisibilityConverter}}">
                                <controls:CommonImageEx ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Cover}" Stretch="UniformToFill" />
                                <Border
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    Background="{ThemeResource AppMaskAcrylicBrush}" />
                                <controls:CommonImageEx
                                    Width="120"
                                    Height="120"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    CornerRadius="60"
                                    ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Cover}" />
                            </Grid>
                            <Grid x:Name="DanmakuContainer">
                                <danmaku:DanmakuView
                                    x:Name="DanmakuView"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ProgressPosition="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ProgressSeconds}"
                                    ViewModel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.DanmakuViewModel}" />
                            </Grid>
                            <Rectangle
                                x:Name="InteractionControl"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Fill="Transparent" />
                            <muxc:ProgressRing
                                Width="40"
                                Height="40"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                IsActive="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsBuffering}" />
                            <Grid RowSpacing="8">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Grid
                                    Padding="12,0"
                                    VerticalAlignment="Bottom"
                                    ColumnSpacing="12">
                                    <Grid
                                        x:Name="TempMessageContainer"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        Visibility="Collapsed">
                                        <Grid
                                            x:Name="TempMessageGrid"
                                            Padding="16,8"
                                            Background="{ThemeResource MediaTransportControlsPanelBackground}"
                                            CornerRadius="{StaticResource ControlCornerRadius}">
                                            <TextBlock
                                                x:Name="TempMessageBlock"
                                                MaxWidth="320"
                                                TextWrapping="Wrap" />
                                        </Grid>
                                    </Grid>
                                </Grid>

                                <local:BiliMediaTransportControls
                                    x:Name="MediaTransportControls"
                                    Style="{StaticResource LiveTransportStyle}"
                                    Grid.Row="1"
                                    Margin="12"
                                    TransportVisibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowMediaTransport, Converter={StaticResource BoolToVisibilityConverter}}"
                                    ViewModel="{TemplateBinding ViewModel}" />
                            </Grid>
                        </Grid>
                        <Grid
                            x:Name="PlayErrorContainer"
                            MinHeight="200"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Background="{ThemeResource LayerFillColorDefaultBrush}"
                            CornerRadius="{StaticResource OverlayCornerRadius}"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError}">
                            <StackPanel
                                Padding="20,12"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
                                CornerRadius="{StaticResource OverlayCornerRadius}"
                                Spacing="8">
                                <Image
                                    Width="120"
                                    HorizontalAlignment="Center"
                                    Source="ms-appx:///Assets/ERROR_rgba.png"
                                    Stretch="Uniform" />
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ErrorText}"
                                    TextAlignment="Center" />
                                <Button
                                    x:Name="RefreshButton"
                                    HorizontalAlignment="Center"
                                    Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReloadCommand}"
                                    Content="{loc:Locale Name=Refresh}" />
                            </StackPanel>
                        </Grid>
                        <Button
                            x:Name="ExitFullPlayerButton"
                            AutomationProperties.Name="{loc:Locale Name=BackToDefaultView}"
                            Style="{StaticResource AccentButtonStyle}"
                            Width="32"
                            Height="32"
                            Margin="32"
                            Padding="0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ExitFullPlayerCommand}"
                            ToolTipService.ToolTip="{loc:Locale Name=BackToDefaultView}"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowExitFullPlayerButton}">
                            <uwp:RegularFluentIcon FontSize="14" Symbol="Dismiss20" />
                        </Button>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="XboxVideoPlayerStyle" TargetType="local:BiliMediaPlayer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:BiliMediaPlayer">
                    <Grid>
                        <Grid
                            x:Name="RootGrid"
                            Background="Black"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                            <MediaPlayerElement x:Name="MediaPlayerElement" AreTransportControlsEnabled="False" />
                            <Grid x:Name="DanmakuContainer">
                                <danmaku:DanmakuView
                                    x:Name="DanmakuView"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ProgressPosition="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ProgressSeconds}"
                                    ViewModel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.DanmakuViewModel}" />
                            </Grid>
                            <Rectangle
                                x:Name="InteractionControl"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Fill="Transparent" />
                            <muxc:ProgressRing
                                Width="40"
                                Height="40"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                IsActive="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsBuffering}" />
                            <Grid RowSpacing="8">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Grid
                                    Padding="12,0"
                                    VerticalAlignment="Bottom"
                                    ColumnSpacing="12">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid
                                        x:Name="TempMessageContainer"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        Visibility="Collapsed">
                                        <Grid
                                            x:Name="TempMessageGrid"
                                            Padding="16,8"
                                            Background="{ThemeResource MediaTransportControlsPanelBackground}"
                                            CornerRadius="{StaticResource ControlCornerRadius}">
                                            <TextBlock
                                                x:Name="TempMessageBlock"
                                                MaxWidth="320"
                                                TextWrapping="Wrap" />
                                        </Grid>
                                    </Grid>
                                    <controls:PlayerTip
                                        x:Name="PreviousViewInformer"
                                        Title="{loc:Locale Name=ViewHistory}"
                                        Grid.Column="1"
                                        HorizontalAlignment="Right"
                                        ActionContent="{loc:Locale Name=ContinuePreviousView}"
                                        CloseCommand="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ClearSourceProgressCommand}"
                                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.JumpToLastProgressCommand}"
                                        IsOpen="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowProgressTip, Mode=TwoWay}"
                                        Message="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ProgressTip}" />

                                    <controls:PlayerTip
                                        x:Name="NextVideoInformer"
                                        Title="{loc:Locale Name=PlayNextVideo}"
                                        Grid.Column="1"
                                        HorizontalAlignment="Right"
                                        ActionContent="{loc:Locale Name=PlayNow}"
                                        AdditionalTitle="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.NextVideoCountdown}"
                                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PlayNextCommand}"
                                        IsOpen="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowNextVideoTip, Mode=TwoWay}"
                                        Message="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.NextVideoTipText}" />
                                </Grid>

                                <local:InteractionChoicePanel
                                    x:Name="ChoiceContainer"
                                    Grid.Row="1"
                                    HorizontalAlignment="Center"
                                    ViewModel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel}"
                                    Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsInteractionVideo, Converter={StaticResource BoolToVisibilityConverter}}" />

                                <Grid Grid.Row="2" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.HasSubtitles}">
                                    <Grid
                                        x:Name="SubtitleContainer"
                                        Margin="24,4"
                                        HorizontalAlignment="Center"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.CanShowSubtitle}">
                                        <Grid
                                            Background="{ThemeResource MediaTransportControlsPanelBackground}"
                                            CornerRadius="{StaticResource OverlayCornerRadius}"
                                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.CurrentSubtitle, Converter={StaticResource ObjectToVisibilityConverter}}">
                                            <TextBlock
                                                x:Name="SubtitleBlock"
                                                MaxWidth="1200"
                                                Margin="16,8"
                                                HorizontalAlignment="Center"
                                                FontSize="22"
                                                Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SubtitleViewModel.CurrentSubtitle}"
                                                TextTrimming="CharacterEllipsis"
                                                TextWrapping="Wrap" />
                                        </Grid>
                                    </Grid>
                                </Grid>

                                <local:BiliMediaTransportControls
                                    x:Name="MediaTransportControls"
                                    Style="{StaticResource XboxTransportStye}"
                                    Grid.Row="3"
                                    Margin="12"
                                    TransportVisibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowMediaTransport, Converter={StaticResource BoolToVisibilityConverter}}"
                                    ViewModel="{TemplateBinding ViewModel}" />
                            </Grid>
                        </Grid>
                        <Grid
                            x:Name="PlayErrorContainer"
                            MinHeight="200"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Background="{ThemeResource LayerFillColorDefaultBrush}"
                            CornerRadius="{StaticResource OverlayCornerRadius}"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError}">
                            <StackPanel
                                Padding="20,12"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
                                CornerRadius="{StaticResource OverlayCornerRadius}"
                                Spacing="8">
                                <Image
                                    Width="120"
                                    HorizontalAlignment="Center"
                                    Source="ms-appx:///Assets/ERROR_rgba.png"
                                    Stretch="Uniform" />
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ErrorText}"
                                    TextAlignment="Center" />
                                <Button
                                    x:Name="RefreshButton"
                                    HorizontalAlignment="Center"
                                    Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReloadCommand}"
                                    Content="{loc:Locale Name=Refresh}" />
                            </StackPanel>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="XboxLivePlayerStyle" TargetType="local:BiliMediaPlayer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:BiliMediaPlayer">
                    <Grid>
                        <Grid
                            x:Name="RootGrid"
                            Background="Black"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                            <MediaPlayerElement x:Name="MediaPlayerElement" AreTransportControlsEnabled="False" />
                            <Grid x:Name="CoverContainer" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsLiveAudioOnly, Converter={StaticResource BoolToVisibilityConverter}}">
                                <controls:CommonImageEx ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Cover}" Stretch="UniformToFill" />
                                <Border
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    Background="{ThemeResource AppMaskAcrylicBrush}" />
                                <controls:CommonImageEx
                                    Width="120"
                                    Height="120"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    CornerRadius="60"
                                    ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Cover}" />
                            </Grid>
                            <Grid x:Name="DanmakuContainer">
                                <danmaku:DanmakuView
                                    x:Name="DanmakuView"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ProgressPosition="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ProgressSeconds}"
                                    ViewModel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.DanmakuViewModel}" />
                            </Grid>
                            <Rectangle
                                x:Name="InteractionControl"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Fill="Transparent" />
                            <muxc:ProgressRing
                                Width="40"
                                Height="40"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                IsActive="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsBuffering}" />
                            <Grid RowSpacing="8">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Grid
                                    Padding="12,0"
                                    VerticalAlignment="Bottom"
                                    ColumnSpacing="12">
                                    <Grid
                                        x:Name="TempMessageContainer"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        Visibility="Collapsed">
                                        <Grid
                                            x:Name="TempMessageGrid"
                                            Padding="16,8"
                                            Background="{ThemeResource MediaTransportControlsPanelBackground}"
                                            CornerRadius="{StaticResource ControlCornerRadius}">
                                            <TextBlock
                                                x:Name="TempMessageBlock"
                                                MaxWidth="320"
                                                TextWrapping="Wrap" />
                                        </Grid>
                                    </Grid>
                                </Grid>

                                <local:BiliMediaTransportControls
                                    x:Name="MediaTransportControls"
                                    Style="{StaticResource XboxLiveTransportStyle}"
                                    Grid.Row="1"
                                    Margin="12"
                                    TransportVisibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsShowMediaTransport, Converter={StaticResource BoolToVisibilityConverter}}"
                                    ViewModel="{TemplateBinding ViewModel}" />
                            </Grid>
                        </Grid>
                        <Grid
                            x:Name="PlayErrorContainer"
                            MinHeight="200"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Background="{ThemeResource LayerFillColorDefaultBrush}"
                            CornerRadius="{StaticResource OverlayCornerRadius}"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError}">
                            <StackPanel
                                Padding="20,12"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
                                CornerRadius="{StaticResource OverlayCornerRadius}"
                                Spacing="8">
                                <Image
                                    Width="120"
                                    HorizontalAlignment="Center"
                                    Source="ms-appx:///Assets/ERROR_rgba.png"
                                    Stretch="Uniform" />
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ErrorText}"
                                    TextAlignment="Center" />
                                <Button
                                    x:Name="RefreshButton"
                                    HorizontalAlignment="Center"
                                    Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReloadCommand}"
                                    Content="{loc:Locale Name=Refresh}" />
                            </StackPanel>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
