Added playlist view and initial playlist view logic.
This commit is contained in:
@@ -7,6 +7,7 @@ using Harmonia.Core.Models;
|
||||
using Harmonia.Core.Player;
|
||||
using Harmonia.Core.Playlists;
|
||||
using Harmonia.Core.Scanner;
|
||||
using Harmonia.UI.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -118,6 +119,57 @@ public partial class PlaybackBarViewModel : ViewModelBase, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public double Volume
|
||||
{
|
||||
get
|
||||
{
|
||||
return _audioPlayer.Volume;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (IsMuted)
|
||||
IsMuted = false;
|
||||
|
||||
_audioPlayer.Volume = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(VolumeState));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMuted
|
||||
{
|
||||
get
|
||||
{
|
||||
return _audioPlayer.IsMuted;
|
||||
}
|
||||
set
|
||||
{
|
||||
_audioPlayer.IsMuted = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(VolumeState));
|
||||
}
|
||||
}
|
||||
|
||||
public VolumeState VolumeState
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsMuted)
|
||||
return VolumeState.Muted;
|
||||
|
||||
if (Volume == 0)
|
||||
return VolumeState.Off;
|
||||
|
||||
if (Volume < .33)
|
||||
return VolumeState.Low;
|
||||
|
||||
if (Volume < .66)
|
||||
return VolumeState.Medium;
|
||||
|
||||
return VolumeState.High;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRandom
|
||||
{
|
||||
get
|
||||
@@ -131,11 +183,27 @@ public partial class PlaybackBarViewModel : ViewModelBase, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public RepeatState RepeatState
|
||||
{
|
||||
get
|
||||
{
|
||||
return _audioPlayer.RepeatState;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_audioPlayer.RepeatState = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand PlaySongCommand => new RelayCommand(Play);
|
||||
public ICommand PauseSongCommand => new RelayCommand(Pause);
|
||||
public ICommand StopSongCommand => new RelayCommand(Stop);
|
||||
public ICommand PreviousSongCommand => new RelayCommand(Previous);
|
||||
public ICommand NextSongCommand => new RelayCommand(Next);
|
||||
public ICommand ToggleMuteCommand => new RelayCommand(ToggleMute);
|
||||
public ICommand ToggleRandomizerCommand => new RelayCommand(ToggleRandomizer);
|
||||
public ICommand ToggleRepeatCommand => new RelayCommand(ToggleRepeat);
|
||||
|
||||
public PlaybackBarViewModel(IAudioPlayer audioPlayer, IAudioImageCache audioImageCache, IPlaylistRepository playlistRepository, IAudioFileScanner audioFileScanner)
|
||||
{
|
||||
@@ -219,6 +287,32 @@ public partial class PlaybackBarViewModel : ViewModelBase, IDisposable
|
||||
_audioPlayer.NextAsync();
|
||||
}
|
||||
|
||||
public void ToggleMute()
|
||||
{
|
||||
IsMuted = !IsMuted;
|
||||
}
|
||||
|
||||
public void ToggleRandomizer()
|
||||
{
|
||||
IsRandom = !IsRandom;
|
||||
}
|
||||
|
||||
public void ToggleRepeat()
|
||||
{
|
||||
RepeatState = GetNextRepeatState();
|
||||
}
|
||||
|
||||
private RepeatState GetNextRepeatState()
|
||||
{
|
||||
return _audioPlayer.RepeatState switch
|
||||
{
|
||||
RepeatState.Off => RepeatState.RepeatAll,
|
||||
RepeatState.RepeatAll => RepeatState.RepeatOne,
|
||||
RepeatState.RepeatOne => RepeatState.Off,
|
||||
_ => _audioPlayer.RepeatState,
|
||||
};
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SongImageSource?.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user