public async Task SendPlaylist(PlaylistUpdateDTO dto) { try { await this.playHub.Clients.All.SendPlaylist(dto); } catch (Exception xe) { log.Error(xe); } }
public async Task ClearPlaylist(string deviceKey) { var dr = GetDeviceRuntime(deviceKey); if (dr != null) { dr.Playlist.Items.Clear(); //dr.CurrentPlaylistSequenceNumber = 0; //dr.CurrentPSN = (0, 0); dr.CurrentPosition.Reset(); var dto = new PlaylistUpdateDTO { DeviceKey = deviceKey, DisplayName = dr.DisplayName, Items = dr.Playlist.Items.Select(x => x.ToDTO()) }; await SendPlaylist(dto); } }
public async Task AddPlaylistItem(string deviceKey, PlaylistItem pli) { using (var scope = new ScopedDbContext <MusicDb>(serviceProvider)) { var dr = GetDeviceRuntime(deviceKey); if (dr != null) { var item = pli.ToRuntime(scope.Db, dr); if (item != null) { dr.Playlist.Items.Add(pli.ToRuntime(scope.Db, dr)); var dto = new PlaylistUpdateDTO { DeviceKey = deviceKey, Items = dr.Playlist.Items.Select(x => x.ToDTO()) }; await SendPlaylist(dto); } } } }