mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
smtc cover art!
This commit is contained in:
parent
f5d193d961
commit
d8b1317737
3 changed files with 25 additions and 17 deletions
|
@ -11,7 +11,9 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using Windows.Graphics.Imaging;
|
||||
using Windows.Media;
|
||||
using Windows.Storage.Streams;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Integrations
|
||||
{
|
||||
|
@ -39,7 +41,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations
|
|||
smtc.ButtonPressed += Smtc_ButtonPressed;
|
||||
}
|
||||
|
||||
public void Update(IMetadataProvider track, PlaybackStatus status)
|
||||
public async void Update(IMetadataProvider track, PlaybackStatus status)
|
||||
{
|
||||
smtc.PlaybackStatus = (MediaPlaybackStatus)status;
|
||||
var updater = smtc.DisplayUpdater;
|
||||
|
@ -48,7 +50,18 @@ namespace FRESHMusicPlayer.Handlers.Integrations
|
|||
updater.MusicProperties.AlbumTitle = track.Album;
|
||||
updater.MusicProperties.TrackNumber = (uint)track.TrackNumber;
|
||||
updater.MusicProperties.AlbumTrackCount = (uint)track.TrackTotal;
|
||||
//updater.Thumbnail = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromStream(System.IO.WindowsRuntimeStreamExtensions.AsRandomAccessStream(new MemoryStream(track.CoverArt)));
|
||||
if (track.CoverArt != null)
|
||||
{
|
||||
var decoder = await BitmapDecoder.CreateAsync(new MemoryStream(track.CoverArt).AsRandomAccessStream());
|
||||
var transcodedImage = new InMemoryRandomAccessStream();
|
||||
|
||||
BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(transcodedImage, decoder);
|
||||
await encoder.FlushAsync();
|
||||
|
||||
transcodedImage.Seek(0);
|
||||
updater.Thumbnail = RandomAccessStreamReference.CreateFromStream(transcodedImage);
|
||||
}
|
||||
|
||||
updater.MusicProperties.Title = track.Title;
|
||||
updater.Update();
|
||||
}
|
||||
|
|
|
@ -27,25 +27,20 @@
|
|||
<Rectangle Fill="Transparent" Width="50" Grid.Column="2" Grid.RowSpan="3" Panel.ZIndex="2" MouseEnter="Rectangle_MouseEnter"/>
|
||||
<Viewbox Stretch="Uniform" Panel.ZIndex="2" Grid.Row="1" Grid.Column="1">
|
||||
<DockPanel LastChildFill="False" Width="700" Height="350">
|
||||
<Image Source="https://royce551.github.io/assets/images/fmp/fullfmplogo.png" DockPanel.Dock="Top" HorizontalAlignment="Left" Width="100" Margin="10,0,0,0"/>
|
||||
<Image Source="https://royce551.github.io/assets/images/fmp/fullfmplogo.png" DockPanel.Dock="Top" HorizontalAlignment="Left" Width="100" RenderOptions.BitmapScalingMode="HighQuality" Margin="10,0,0,0"/>
|
||||
|
||||
<Grid DockPanel.Dock="Bottom">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="CoverArtArea" Width="5"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="CoverArtBox" Margin="-64,10,5,0" VerticalAlignment="Top" Height="64" Width="64" HorizontalAlignment="Right" RenderOptions.BitmapScalingMode="HighQuality">
|
||||
<Image.ToolTip>
|
||||
<ToolTip>
|
||||
<Image x:Name="CoverArtBoxToolTip" Width="450" Height="450" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
</ToolTip>
|
||||
</Image.ToolTip>
|
||||
<Image x:Name="CoverArtBox" Margin="-64,10,5,0" VerticalAlignment="Top" Height="150" Width="150" HorizontalAlignment="Right" RenderOptions.BitmapScalingMode="HighQuality">
|
||||
</Image>
|
||||
<TextBlock x:Name="TitleLabel" HorizontalAlignment="Stretch" Margin="5,5,40,0" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_NOTHINGPLAYING}" VerticalAlignment="Top" FontWeight="Bold" FontSize="22" Grid.Column="1" Height="30" Foreground="{StaticResource PrimaryTextColor}" TextTrimming="CharacterEllipsis" Grid.ColumnSpan="2" Panel.ZIndex="0"/>
|
||||
<Slider x:Name="ProgressBar" Grid.Column="1" IsEnabled="False" HorizontalAlignment="Stretch" Margin="37,54,45,0" VerticalAlignment="Top" Height="21" Style="{StaticResource Progress_Slider}" Value="9.8"/>
|
||||
<TextBlock x:Name="ProgressIndicator1" Grid.Column="1" Margin="5,56,0,0" TextWrapping="NoWrap" Text="10:00" Foreground="{StaticResource SecondaryTextColor}" Height="15" VerticalAlignment="Top" HorizontalAlignment="Left" Width="28"/>
|
||||
<TextBlock x:Name="ProgressIndicator2" Grid.Column="1" Margin="0,56,0,0" TextWrapping="NoWrap" Text="10:00" Foreground="{StaticResource SecondaryTextColor}" Height="15" VerticalAlignment="Top" HorizontalAlignment="Right" Width="40"/>
|
||||
<TextBlock x:Name="ArtistLabel" HorizontalAlignment="Stretch" Margin="5,35,10,0" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_NOTHINGPLAYING}" VerticalAlignment="Top" Grid.Column="1" Height="20" Foreground="{StaticResource SecondaryTextColor}" TextTrimming="CharacterEllipsis"/>
|
||||
<TextBlock x:Name="TitleLabel" HorizontalAlignment="Stretch" Margin="5,89,40,-44" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_NOTHINGPLAYING}" FontWeight="Bold" FontSize="22" Grid.Column="1" Foreground="{StaticResource PrimaryTextColor}" TextTrimming="CharacterEllipsis" Panel.ZIndex="0"/>
|
||||
<Slider x:Name="ProgressBar" Grid.Column="1" IsEnabled="False" HorizontalAlignment="Stretch" Margin="37,138,45,0" VerticalAlignment="Top" Height="21" Style="{StaticResource Progress_Slider}" Value="9.8"/>
|
||||
<TextBlock x:Name="ProgressIndicator1" Grid.Column="1" Margin="5,140,0,0" TextWrapping="NoWrap" Text="10:00" Foreground="{StaticResource SecondaryTextColor}" Height="15" VerticalAlignment="Top" HorizontalAlignment="Left" Width="28"/>
|
||||
<TextBlock x:Name="ProgressIndicator2" Grid.Column="1" Margin="0,140,0,0" TextWrapping="NoWrap" Text="10:00" Foreground="{StaticResource SecondaryTextColor}" Height="15" VerticalAlignment="Top" HorizontalAlignment="Right" Width="40"/>
|
||||
<TextBlock x:Name="ArtistLabel" HorizontalAlignment="Stretch" Margin="5,119,10,0" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_NOTHINGPLAYING}" VerticalAlignment="Top" Grid.Column="1" Height="20" Foreground="{StaticResource SecondaryTextColor}" TextTrimming="CharacterEllipsis"/>
|
||||
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace FRESHMusicPlayer.Pages
|
|||
public void SetCoverArtVisibility(bool mode)
|
||||
{
|
||||
if (!mode) CoverArtArea.Width = new GridLength(5);
|
||||
else CoverArtArea.Width = new GridLength(75);
|
||||
else CoverArtArea.Width = new GridLength(155);
|
||||
}
|
||||
|
||||
private void Player_SongStopped(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in a new issue