public async Task HandleAsync(QueueEnded args) { await _logService.LogAppActivityAsync($"Playlist has ended for party with code {args.PartyCode}. Sending to all listeners"); Party party = await _partyService.GetPartyWithCodeAsync(args.PartyCode); if (party.GetListeners().Count < 1) { await _partyService.EndPartyAsync(args.PartyCode); return; } List <Track> playlistSongs = await _partyService.GenerateNewPlaylist(party, args.SeedTracksUris, args.SeedArtistUris); await party.AddNewQueueAsync(playlistSongs); await _partyHubContext.Clients.Group(args.PartyCode).SendAsync("UpdatePartyView", new { Song = party.GetCurrentSong(), Position = party.GetCurrentPositionInSong() }, party.GetHistory(), party.GetQueue() ); }
private void RegisterCurrentTriggers() { var updateProperty = new Action(() => { if (_queue?.LastOrDefault() == Current) { QueueEnded?.Invoke(this, new QueueEndedEventArgs()); } IMediaFile current = null; if (Count - 1 >= Index && Index >= 0) { current = _queue[Index]; } if (_current != current) { _current = current; OnPropertyChanged(nameof(Current)); QueueMediaChanged?.Invoke(this, new QueueMediaChangedEventArgs(Current)); } }); PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(Index)) { updateProperty(); } }; _queue.CollectionChanged += (sender, e) => { updateProperty(); }; if (Count - 1 >= Index && Index >= 0) { _current = _queue[Index]; } }