Get the thumbnail working

For whatever reason, the symbols are fucked though. that _needs_ to be fixed, whatever happened.
This commit is contained in:
Mike Griese 2019-07-22 11:06:50 -05:00
parent 3f895d93e7
commit ff8eb619ea
3 changed files with 73 additions and 33 deletions

View file

@ -32,6 +32,16 @@ namespace winrt::TerminalApp::implementation
_PlayPauseIcon().Glyph(L"\xE768");
}
});
auto thumb = media.Thumbnail();
auto streamAsync = thumb.OpenReadAsync();
auto stream = streamAsync.get();
Dispatcher().RunAsync(CoreDispatcherPriority::Normal, [this, stream]() {
Media::Imaging::BitmapImage bitmapImage{};
bitmapImage.SetSourceAsync(stream);
_Thumbnail().Source(bitmapImage);
});
}
void MediaControlHost::_MediaPropertiesChanged(Control::GlobalSystemMediaTransportControlsSession session,
@ -44,7 +54,6 @@ namespace winrt::TerminalApp::implementation
Control::PlaybackInfoChangedEventArgs args)
{
_UpdateMediaInfo(session);
}
fire_and_forget MediaControlHost::_SetupMediaManager()

View file

@ -3,6 +3,9 @@
#include "../../cascadia/inc/cppwinrt_utils.h"
#include <winrt/Windows.Media.h>
#include <winrt/Windows.Media.Control.h>
#include <winrt/Windows.ui.xaml.media.h>
#include <winrt/Windows.ui.xaml.media.imaging.h>
#include <winrt/Windows.storage.streams.h>
namespace winrt::TerminalApp::implementation
{

View file

@ -19,9 +19,18 @@ the MIT License. See LICENSE in the project root for license information. -->
</Grid.RowDefinitions>
<RelativePanel
Margin="8,0,0,8"
Grid.Row="0"
HorizontalAlignment="Stretch">
<TextBlock
FontWeight="Bold"
RelativePanel.AlignLeftWithPanel="True"
TextWrapping="WrapWholeWords"
FontSize="16"
x:Name="_CurrentlyPlayingText">
Currently Playing:
</TextBlock>
<Button
x:Name="_CloseButton"
Background="Transparent"
@ -34,43 +43,62 @@ the MIT License. See LICENSE in the project root for license information. -->
</Button>
</RelativePanel>
<StackPanel Grid.Row="1">
<StackPanel
x:Name="_Buttons"
Orientation="Horizontal"
<Grid Grid.Row="1" Margin="8,2,8,8">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
x:Name="_Thumbnail"
Grid.Row="0"
Stretch="Uniform"
HorizontalAlignment="Center"
VerticalAlignment="Center">
VerticalAlignment="Center"></Image>
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Background" Value="Transparent"></Setter>
</Style>
</StackPanel.Resources>
<StackPanel
Grid.Row="1"
Orientation="Vertical">
<Button x:Name="_PreviousButton">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE892;"/>
</Button>
<Button x:Name="_PlayPauseButton">
<!-- Pause is xE769 -->
<FontIcon x:Name="_PlayPauseIcon" FontFamily="Segoe MDL2 Assets" Glyph="&#xE768;"/>
</Button>
<Button x:Name="_NextButton">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE893;"/>
</Button>
<StackPanel
x:Name="_Buttons"
Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Background" Value="Transparent"></Setter>
</Style>
</StackPanel.Resources>
<Button x:Name="_PreviousButton">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE892;"/>
</Button>
<Button x:Name="_PlayPauseButton">
<!-- Pause is xE769 -->
<FontIcon x:Name="_PlayPauseIcon" FontFamily="Segoe MDL2 Assets" Glyph="&#xE768;"/>
</Button>
<Button x:Name="_NextButton">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE893;"/>
</Button>
</StackPanel>
<TextBlock
TextWrapping="WrapWholeWords"
HorizontalAlignment="Center" x:Name="_Title" FontSize="20">
</TextBlock>
<TextBlock
TextWrapping="WrapWholeWords"
HorizontalAlignment="Center" x:Name="_Band">
</TextBlock>
</StackPanel>
<TextBlock
TextWrapping="WrapWholeWords"
HorizontalAlignment="Center" x:Name="_Title" FontSize="20">
Title
</TextBlock>
<TextBlock
TextWrapping="WrapWholeWords"
HorizontalAlignment="Center" x:Name="_Band">
Band
</TextBlock>
</StackPanel>
</Grid>
</Grid>