Working player contained within main page and control delegated to viewmodels
This commit is contained in:
@ -11,7 +11,6 @@ namespace Aurora.Design.Views.Songs
|
||||
#region Fields
|
||||
private ObservableCollection<BaseMedia> _songsList;
|
||||
private BaseMedia _selectedSong;
|
||||
private BaseMedia _playingSong;
|
||||
private PlayerService _player;
|
||||
|
||||
#endregion Fields
|
||||
@ -21,7 +20,7 @@ namespace Aurora.Design.Views.Songs
|
||||
{
|
||||
_player = PlayerService.Instance;
|
||||
_songsList = new ObservableCollection<BaseMedia>();
|
||||
PlayCommand = new Command(PlayExecute, PlayCanExecute);
|
||||
PlayCommand = new Command(OnPlayExecute, CanPlayExecute);
|
||||
|
||||
_player.PlaybackStateChanged += OnPlaybackStateChanged;
|
||||
|
||||
@ -43,12 +42,6 @@ namespace Aurora.Design.Views.Songs
|
||||
set { SetProperty(ref _selectedSong, value); }
|
||||
}
|
||||
|
||||
public BaseMedia PlayingSong
|
||||
{
|
||||
get { return _playingSong; }
|
||||
set { SetProperty(ref _playingSong, value); }
|
||||
}
|
||||
|
||||
public Command PlayCommand { get; private set; }
|
||||
|
||||
#endregion Properties
|
||||
@ -63,16 +56,16 @@ namespace Aurora.Design.Views.Songs
|
||||
#endregion Methods
|
||||
|
||||
#region Commmands
|
||||
public override bool PreviousCanExecute()
|
||||
public override bool CanPreviousExecute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public override void PreviousExecute()
|
||||
public override void OnPreviousExecute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool PlayCanExecute()
|
||||
public override bool CanPlayExecute()
|
||||
{
|
||||
switch (_player.PlaybackState)
|
||||
{
|
||||
@ -92,11 +85,12 @@ namespace Aurora.Design.Views.Songs
|
||||
return false;
|
||||
}
|
||||
|
||||
public async override void PlayExecute()
|
||||
public async override void OnPlayExecute()
|
||||
{
|
||||
if (!_player.IsMediaLoaded(_selectedSong))
|
||||
base.Media = _selectedSong;
|
||||
if (!_player.IsMediaLoaded(base.Media))
|
||||
{
|
||||
await _player.LoadMedia(_selectedSong).ConfigureAwait(true);
|
||||
await _player.LoadMedia(base.Media).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
_player.Play();
|
||||
@ -115,12 +109,12 @@ namespace Aurora.Design.Views.Songs
|
||||
}
|
||||
}
|
||||
|
||||
public override bool NextCanExecute()
|
||||
public override bool CanNextExecute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void NextExecute()
|
||||
public override void OnNextExecute()
|
||||
{
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user