Player working for party view

This commit is contained in:
watsonb8 2019-11-08 20:25:36 -05:00
parent 63efcdad69
commit 426a368385

View File

@ -27,7 +27,8 @@ namespace Aurora.Design.Views.Party
private string _hostname;
private ObservableCollection<PartyMember> _members;
private ObservableCollection<BaseMedia> _queue;
private BaseMedia _selectedSong;
private BaseMedia _selectedMedia;
private PlayerService _player;
public PartyViewModel()
{
@ -38,6 +39,7 @@ namespace Aurora.Design.Views.Party
_queue = new ObservableCollection<BaseMedia>();
SetState(PartyState.SelectingHost);
this._player = PlayerService.Instance;
PlayCommand = new Command(OnPlayExecute);
@ -119,8 +121,8 @@ namespace Aurora.Design.Views.Party
/// <value></value>
public BaseMedia SelectedSong
{
get { return _selectedSong; }
set { SetProperty(ref _selectedSong, value); }
get { return _selectedMedia; }
set { SetProperty(ref _selectedMedia, value); }
}
/// <summary>
@ -227,15 +229,13 @@ namespace Aurora.Design.Views.Party
try
{
//Execute task without waiting
await ClientService.Instance.GetEvents().ConfigureAwait(false);
SetState(PartyState.Hosting);
await ClientService.Instance.GetEvents().ConfigureAwait(true);
}
catch (Exception ex)
{
Console.WriteLine("Exception occurred while receiviing events: ", ex.Message);
}
SetState(PartyState.Hosting);
}
private bool CanHostExecute()
@ -339,8 +339,26 @@ namespace Aurora.Design.Views.Party
public override async void OnPlayExecute()
{
await PlayerService.Instance.LoadMedia(_selectedSong).ConfigureAwait(true);
PlayerService.Instance.Play();
base.Media = this._selectedMedia;
if (!_player.IsMediaLoaded(base.Media))
{
await _player.LoadMedia(base.Media).ConfigureAwait(true);
}
_player.Play();
switch (_player.PlaybackState)
{
case PlaybackState.Buffering:
{
_player.Play();
break;
}
case PlaybackState.Playing:
{
_player.Pause();
break;
}
}
}
public override bool CanPlayExecute()