diff --git a/Aurora/Design/Views/Party/PartyViewModel.cs b/Aurora/Design/Views/Party/PartyViewModel.cs index b2b33e6..e03e642 100644 --- a/Aurora/Design/Views/Party/PartyViewModel.cs +++ b/Aurora/Design/Views/Party/PartyViewModel.cs @@ -27,7 +27,8 @@ namespace Aurora.Design.Views.Party private string _hostname; private ObservableCollection _members; private ObservableCollection _queue; - private BaseMedia _selectedSong; + private BaseMedia _selectedMedia; + private PlayerService _player; public PartyViewModel() { @@ -38,6 +39,7 @@ namespace Aurora.Design.Views.Party _queue = new ObservableCollection(); SetState(PartyState.SelectingHost); + this._player = PlayerService.Instance; PlayCommand = new Command(OnPlayExecute); @@ -119,8 +121,8 @@ namespace Aurora.Design.Views.Party /// public BaseMedia SelectedSong { - get { return _selectedSong; } - set { SetProperty(ref _selectedSong, value); } + get { return _selectedMedia; } + set { SetProperty(ref _selectedMedia, value); } } /// @@ -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()