public async Task UserAddedSong(AddSongToQueueCommand request) { PartyGoer partier = await _partyGoerService.GetCurrentPartyGoerAsync(); request.AddedBy = partier.GetUsername(); bool successfullyAddedSongToQueue = await _partyService.AddNewSongToQueue(request); if (successfullyAddedSongToQueue) { Party party = await _partyService.GetPartyWithAttendeeAsync(partier); // Update the view of the partier to the current playlist await Clients.Group(party.GetPartyCode()).SendAsync("UpdatePartyView", new { Song = party.GetCurrentSong(), Position = party.GetCurrentPositionInSong() }, party.GetHistory(), party.GetQueue() ); } else { await Clients.Client(Context.ConnectionId).SendAsync("UserModifiedPlaylist", new { error = true }); } }
public async Task <bool> AddNewSongToQueue(AddSongToQueueCommand request) { try { Party party = await _partyRepository.GetPartyWithCodeAsync(request.PartyCode); await party.AddTrackToQueueAsync(request); return(true); } catch (Exception ex) { await _logService.LogExceptionAsync(ex, "Error occured in AddNewSongToQueue"); return(false); } }
public async Task AddTrackToQueueAsync(AddSongToQueueCommand request) { Track track = new Track { Artists = request.Artists, AlbumImageUrl = request.AlbumImageUrl, Explicit = request.Explicit, Length = request.Length, Name = request.Name, Id = request.TrackUri + DetermineTrackIdExtension(request.TrackUri) }; _queue.QueueTrack(track); // check to see if music is playing, if not, lets start it if (_currentTrack == null) { await StartQueueAsync(); } }