Song.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace MusicPlayer
  7. {
  8. public class Song
  9. {
  10. public string SongID { get; set; }
  11. public string Name { get; set; }
  12. public string Album { get; set; }
  13. public string Artist { get; set; }
  14. public string Genre { get; set; }
  15. public string Url { get { return GetURL(); } set { SetURL(value); } }
  16. public int Seconds { get; set; }
  17. private APIHandler api;
  18. private string url;
  19. public Song(string songid, string name, string album, string artist, string genre, int seconds, APIHandler api)
  20. {
  21. SongID = songid;
  22. Name = name;
  23. Album = album;
  24. Artist = artist;
  25. Seconds = seconds;
  26. Genre = genre;
  27. this.api = api;
  28. url = "";
  29. }
  30. protected virtual string GetURL()
  31. {
  32. if (url == "")
  33. {
  34. url = api.GetSongURLByID(SongID);
  35. }
  36. return url;
  37. }
  38. private void SetURL(string str)
  39. {
  40. url = str;
  41. }
  42. public override string ToString()
  43. {
  44. return $"{this.SongID}|{this.Name}|{this.Album}|{this.Artist}|{this.Genre}|{this.Seconds}";
  45. }
  46. }
  47. }