mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
playback tracking is less dumb now
This commit is contained in:
parent
615c77e9bd
commit
b1a01d59d6
5 changed files with 46 additions and 12 deletions
|
@ -20,6 +20,7 @@ namespace FRESHMusicPlayer.Handlers.Configuration
|
|||
public bool IntegrateDiscordRPC { get; set; } = false;
|
||||
public bool IntegrateSMTC { get; set; } = true;
|
||||
public bool ShowRemainingProgress { get; set; } = false;
|
||||
public bool PlaybackTracking { get; set; } = false;
|
||||
public UpdateMode UpdateMode { get; set; } = UpdateMode.Prompt;
|
||||
public DateTime UpdatesLastChecked { get; set; }
|
||||
public Skin Theme { get; set; } = Skin.Dark;
|
||||
|
|
|
@ -24,17 +24,30 @@ namespace FRESHMusicPlayer.Handlers
|
|||
|
||||
player.SongChanged += Player_SongChanged;
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
player.SongChanged -= Player_SongChanged;
|
||||
Write(TrackingFile);
|
||||
}
|
||||
|
||||
private void Player_SongChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
TrackingFile.Entries.Add(new TrackingEntry
|
||||
var trackingEntry = new TrackingEntry
|
||||
{
|
||||
DatePlayed = DateTime.Now,
|
||||
Track = DatabaseUtils.Read().Find(x => x.Path == player.FilePath)
|
||||
});
|
||||
Write(TrackingFile);
|
||||
Track = new DatabaseTrack
|
||||
{
|
||||
Path = player.FilePath,
|
||||
Artist = MainWindow.CurrentTrack.Artist,
|
||||
Title = MainWindow.CurrentTrack.Title,
|
||||
Album = MainWindow.CurrentTrack.Album,
|
||||
TrackNumber = MainWindow.CurrentTrack.TrackNumber,
|
||||
Length = MainWindow.CurrentTrack.Duration
|
||||
}
|
||||
};
|
||||
TrackingFile.Entries.Add(trackingEntry);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace FRESHMusicPlayer
|
|||
private async void Window_SourceInitialized(object sender, EventArgs e)
|
||||
{
|
||||
UpdateIntegrations();
|
||||
ProcessSettings();
|
||||
ProcessSettings(true);
|
||||
await UpdateHandler.UpdateApp();
|
||||
}
|
||||
private void Smtc_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs args)
|
||||
|
@ -268,11 +268,19 @@ namespace FRESHMusicPlayer
|
|||
RightFrame.Source = null;
|
||||
SelectedAuxiliaryPane = SelectedAuxiliaryPane.None;
|
||||
}
|
||||
public void ProcessSettings()
|
||||
public void ProcessSettings(bool initialize = false)
|
||||
{
|
||||
VolumeBar.Value = App.Config.Volume;
|
||||
ChangeTabs(App.Config.CurrentMenu);
|
||||
TrackingHandler = new PlaytimeTrackingHandler(Player);
|
||||
if (initialize)
|
||||
{
|
||||
VolumeBar.Value = App.Config.Volume;
|
||||
ChangeTabs(App.Config.CurrentMenu);
|
||||
}
|
||||
if (App.Config.PlaybackTracking) TrackingHandler = new PlaytimeTrackingHandler(Player);
|
||||
else if (TrackingHandler != null)
|
||||
{
|
||||
TrackingHandler?.Close();
|
||||
TrackingHandler = null;
|
||||
}
|
||||
}
|
||||
#region Tabs
|
||||
private void ChangeTabs(SelectedMenu tab)
|
||||
|
@ -510,6 +518,7 @@ namespace FRESHMusicPlayer
|
|||
{
|
||||
App.Config.Volume = (int)VolumeBar.Value;
|
||||
App.Config.CurrentMenu = SelectedMenu;
|
||||
TrackingHandler?.Close();
|
||||
ConfigurationHandler.Write(App.Config);
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<ComboBoxItem Content="Portuguese"/>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
<Grid Height="30" Margin="0,0,0,5" >
|
||||
<!--<Grid Height="30" Margin="0,0,0,5" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="150"/>
|
||||
|
@ -57,8 +57,9 @@
|
|||
<ComboBoxItem Content="Test"/>
|
||||
<ComboBoxItem Content="Test2"/>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</Grid>-->
|
||||
<CheckBox x:Name="General_ProgressCheck" Content="{x:Static resx:Resources.SETTINGS_TIMEWINDOWTITLE}" FontSize="14" Foreground="{StaticResource PrimaryTextColor}" Checked="General_ProgressChanged" Unchecked="General_ProgressChanged"/>
|
||||
<CheckBox x:Name="General_TrackingCheck" Content="Playback Tracking" FontSize="14" Foreground="{StaticResource PrimaryTextColor}" Checked="General_TrackingChanged" Unchecked="General_TrackingChanged"/>
|
||||
<TextBlock Text="{x:Static resx:Resources.SETTINGS_INTEGRATION}" Foreground="{StaticResource PrimaryTextColor}" FontSize="16" FontWeight="Bold" Padding="0,0,0,5" Margin="-10,0,0,0"/>
|
||||
<CheckBox x:Name="Integration_DiscordRPCCheck" Content="Discord Rich Presence" FontSize="14" Foreground="{StaticResource PrimaryTextColor}" Margin="0,0,0,5" Checked="General_DiscordRPCChanged" Unchecked="General_DiscordRPCChanged"/>
|
||||
<CheckBox x:Name="Integration_SMTCCheck" Content="System Transport Controls" FontSize="14" Foreground="{StaticResource PrimaryTextColor}" Checked="Integration_SMTCChanged" Unchecked="Integration_SMTCChanged"/>
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace FRESHMusicPlayer.Pages
|
|||
private void InitFields()
|
||||
{
|
||||
General_ProgressCheck.IsChecked = App.Config.ShowTimeInWindow;
|
||||
General_TrackingCheck.IsChecked = App.Config.PlaybackTracking;
|
||||
Integration_DiscordRPCCheck.IsChecked = App.Config.IntegrateDiscordRPC;
|
||||
Integration_SMTCCheck.IsChecked = App.Config.IntegrateSMTC;
|
||||
FMPCoreVersionLabel.Text = MainWindow.Player.VersionString();
|
||||
|
@ -114,7 +115,14 @@ namespace FRESHMusicPlayer.Pages
|
|||
(Application.Current.MainWindow as MainWindow)?.UpdateIntegrations();
|
||||
}
|
||||
}
|
||||
|
||||
private void General_TrackingChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (pageInitialized)
|
||||
{
|
||||
App.Config.PlaybackTracking = (bool)General_TrackingCheck.IsChecked;
|
||||
(Application.Current.MainWindow as MainWindow)?.ProcessSettings();
|
||||
}
|
||||
}
|
||||
private void General_LanguageCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (pageInitialized)
|
||||
|
@ -210,6 +218,8 @@ namespace FRESHMusicPlayer.Pages
|
|||
DatabaseUtils.Import(tracks.ToArray());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public enum LanguageCombo
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue