/// <summary> /// Get the current song information /// </summary> /// <returns>CurrentSong</returns> public async Task <CurrentSong> CurrentSongAsync() { var response = await SendCommandAsync("currentsong"); var currentSong = new CurrentSong(); foreach (var statusEntry in response.ResponseLines) { var nameValue = statusEntry.Split(new[] { ':' }, 2); var name = nameValue[0]; var value = nameValue[1].Trim(); switch (name) { case "file": currentSong.File = value; break; case "Title": currentSong.Title = value; break; case "Name": currentSong.Name = value; break; case "Pos": int pos; int.TryParse(value, out pos); currentSong.Pos = pos; break; case "Id": int id; int.TryParse(value, out id); currentSong.Id = id; break; default: Debug.WriteLine($"Unprocessed current song info: {nameValue[0]}"); break; } } return(currentSong); }
/// <summary> /// Get the current song information /// </summary> /// <returns>CurrentSong</returns> public async Task<CurrentSong> CurrentSongAsync() { var response = await SendCommandAsync("currentsong"); var currentSong = new CurrentSong(); foreach (var statusEntry in response.ResponseLines) { var nameValue = statusEntry.Split(new[] {':'}, 2); var name = nameValue[0]; var value = nameValue[1].Trim(); switch (name) { case "file": currentSong.File = value; break; case "Title": currentSong.Title = value; break; case "Name": currentSong.Name = value; break; case "Pos": int pos; int.TryParse(value, out pos); currentSong.Pos = pos; break; case "Id": int id; int.TryParse(value, out id); currentSong.Id = id; break; default: Debug.WriteLine($"Unprocessed current song info: {nameValue[0]}"); break; } } return currentSong; }