Fixed memory leak issue with song image source not getting disposed. Added playbackbar configuration button.
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
|
||||
public partial class MainViewModel : ViewModelBase
|
||||
{
|
||||
public string Greeting => "Welcome to Avalonia!";
|
||||
public static string Greeting => "Welcome to Avalonia!";
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ using System.Windows.Input;
|
||||
|
||||
namespace Harmonia.UI.ViewModels;
|
||||
|
||||
public partial class PlaybackBarViewModel : ViewModelBase
|
||||
public partial class PlaybackBarViewModel : ViewModelBase, IDisposable
|
||||
{
|
||||
private readonly IAudioPlayer _audioPlayer;
|
||||
private readonly IAudioImageCache _audioImageCache;
|
||||
@@ -52,6 +52,7 @@ public partial class PlaybackBarViewModel : ViewModelBase
|
||||
}
|
||||
private set
|
||||
{
|
||||
_songImageSource?.Dispose();
|
||||
_songImageSource = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
@@ -217,4 +218,10 @@ public partial class PlaybackBarViewModel : ViewModelBase
|
||||
{
|
||||
_audioPlayer.NextAsync();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SongImageSource?.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Harmonia.UI.ViewModels;
|
||||
|
||||
public class PlayingSongInfoViewModel : ViewModelBase
|
||||
public class PlayingSongInfoViewModel : ViewModelBase, IDisposable
|
||||
{
|
||||
private readonly IAudioPlayer _audioPlayer;
|
||||
private readonly IAudioImageCache _audioImageCache;
|
||||
@@ -41,6 +41,7 @@ public class PlayingSongInfoViewModel : ViewModelBase
|
||||
}
|
||||
private set
|
||||
{
|
||||
_songImageSource?.Dispose();
|
||||
_songImageSource = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
@@ -88,4 +89,10 @@ public class PlayingSongInfoViewModel : ViewModelBase
|
||||
using MemoryStream stream = new(songPictureInfo.Data);
|
||||
SongImageSource = new(stream);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SongImageSource?.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<!-- Playback Buttons -->
|
||||
<Grid Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Classes="Flat" Command="{Binding PreviousSongCommand}">
|
||||
@@ -102,6 +102,22 @@
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<Grid Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Classes="Flat">
|
||||
<PathIcon Classes="FlatButtonIcon" Data="{StaticResource SemiIconSetting}"></PathIcon>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Placement="Top">
|
||||
<RadioButton Content="Compact" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" GroupName="Density" />
|
||||
<RadioButton Content="Comfortable" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" GroupName="Density" />
|
||||
<RadioButton Content="Cozy" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" GroupName="Density" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user