private void PlayQueuedSong(QueueItemViewModel vm) { Log("Sending Media Play", Category.Debug); _eventAggregator.GetEvent <OnMediaPlay <AllJoinedTable> >() .Publish(vm.QueuedSong); }
/// <summary> /// Called when [remove song]. Removes passed in song from queue /// </summary> /// <param name="queueItemViewModel">The queue item view model.</param> private void OnRemoveSong(QueueItemViewModel queueItemViewModel) { Log("Removing song from queue", Category.Debug); try { RemoveQueuedSong(queueItemViewModel); } catch (Exception ex) { Log(ex.Message, Category.Exception); throw; } }
private void QueueSongs_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { try { var song = e.NewItems[0] as AllJoinedTable; if (song != null) { QueueItemViewModel queueItemVm = _unityContainer.Resolve(typeof(QueueItemViewModel)) as QueueItemViewModel; queueItemVm.QueuedSong = song; QueueItems.Add(queueItemVm); } } catch (Exception ex) { Log(ex.Message, Category.Exception); throw; } } }
private void PlayQueueItem(QueueItemViewModel vm) { if (vm != null) { Log("Sending Media Play", Category.Debug); try { Application.Current.Dispatcher.Invoke(() => { PlayQueuedSong(vm); OnRemoveSong(vm); }); } catch (Exception ex) { Log(ex.Message, Category.Exception); throw; } } }
/// <summary> /// Removes the queued song from the provider and the local collection /// </summary> /// <param name="queueItemViewModel">The queue item view model.</param> private void RemoveQueuedSong(QueueItemViewModel queueItemViewModel) { _queuedSongDataProvider.QueueSongs.Remove(queueItemViewModel.QueuedSong); QueueItems.Remove(queueItemViewModel); }