introduce const for window name, more smtc info

This commit is contained in:
Royce551 2021-08-23 21:09:33 -05:00
parent b7a630697e
commit af2d85b005
3 changed files with 12 additions and 7 deletions

View file

@ -45,7 +45,7 @@ namespace FRESHMusicPlayer.Forms
ProgressIndicator1.Text = time.ToString(@"mm\:ss");
if (App.Config.ShowRemainingProgress) ProgressIndicator2.Text
= $"-{TimeSpan.FromSeconds(time.TotalSeconds - Math.Floor(window.Player.CurrentBackend.TotalTime.TotalSeconds)):mm\\:ss}";
if (App.Config.ShowTimeInWindow) Title = $"{time:mm\\:ss}/{window.Player.CurrentBackend.TotalTime:mm\\:ss} | FRESHMusicPlayer";
if (App.Config.ShowTimeInWindow) Title = $"{time:mm\\:ss}/{window.Player.CurrentBackend.TotalTime:mm\\:ss} | {MainWindow.WindowName}";
if (!isDragging) ProgressSlider.Value = time.TotalSeconds;
window.Player.AvoidNextQueue = false;
}

View file

@ -3,6 +3,7 @@ using FRESHMusicPlayer.Backends;
using FRESHMusicPlayer.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
@ -44,7 +45,10 @@ namespace FRESHMusicPlayer.Handlers.Integrations
var updater = smtc.DisplayUpdater;
updater.Type = MediaPlaybackType.Music;
updater.MusicProperties.Artist = string.Join(", ", track.Artists);
//updater.MusicProperties.AlbumArtist = track.AlbumArtist; // TODO: figure out how to deal with this
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)));
updater.MusicProperties.Title = track.Title;
updater.Update();
}

View file

@ -53,7 +53,6 @@ namespace FRESHMusicPlayer
/// </summary>
public partial class MainWindow : Window
{
public Menu SelectedMenu = Menu.Tracks;
public AuxiliaryPane SelectedAuxiliaryPane = AuxiliaryPane.None;
public Player Player;
@ -61,6 +60,8 @@ namespace FRESHMusicPlayer
public GUILibrary Library;
public IMetadataProvider CurrentTrack;
public const string WindowName = "FRESHMusicPlayer [Ver. 11 Development; Not stable!]";
public PlaytimeTrackingHandler TrackingHandler;
public bool PauseAfterCurrentTrack = false;
@ -100,7 +101,7 @@ namespace FRESHMusicPlayer
#endif
Library = new GUILibrary(library, NotificationHandler);
}
catch (IOException) // library is *probably* being used by another FMP.
catch (IOException) // library is *probably* being used by another FMP, write initial files, hopefully existing FMP will pick them up
{
File.WriteAllLines(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FRESHMusicPlayer", "instance"), initialFile ?? Array.Empty<string>());
Application.Current.Shutdown();
@ -415,7 +416,7 @@ namespace FRESHMusicPlayer
#region Player
private void Player_SongStopped(object sender, EventArgs e)
{
Title = "FRESHMusicPlayer";
Title = WindowName;
TitleLabel.Text = ArtistLabel.Text = Properties.Resources.MAINWINDOW_NOTHINGPLAYING;
progressTimer.Stop();
CoverArtBox.Source = null;
@ -428,7 +429,7 @@ namespace FRESHMusicPlayer
private void Player_SongChanged(object sender, EventArgs e)
{
CurrentTrack = Player.CurrentBackend.Metadata;
Title = $"{string.Join(", ", CurrentTrack.Artists)} - {CurrentTrack.Title} | FRESHMusicPlayer";
Title = $"{string.Join(", ", CurrentTrack.Artists)} - {CurrentTrack.Title} | {WindowName}";
TitleLabel.Text = CurrentTrack.Title;
ArtistLabel.Text = string.Join(", ", CurrentTrack.Artists) == "" ? Properties.Resources.MAINWINDOW_NOARTIST : string.Join(", ", CurrentTrack.Artists);
ProgressBar.Maximum = Player.CurrentBackend.TotalTime.TotalSeconds;
@ -524,7 +525,7 @@ namespace FRESHMusicPlayer
ProgressIndicator1.Text = time.ToString(@"mm\:ss");
if (App.Config.ShowRemainingProgress) ProgressIndicator2.Text
= $"-{TimeSpan.FromSeconds(time.TotalSeconds - Math.Floor(Player.CurrentBackend.TotalTime.TotalSeconds)):mm\\:ss}";
if (App.Config.ShowTimeInWindow) Title = $"{time:mm\\:ss}/{Player.CurrentBackend.TotalTime:mm\\:ss} | FRESHMusicPlayer";
if (App.Config.ShowTimeInWindow) Title = $"{time:mm\\:ss}/{Player.CurrentBackend.TotalTime:mm\\:ss} | {WindowName}";
if (!isDragging) ProgressBar.Value = time.TotalSeconds;
Player.AvoidNextQueue = false;