Audio.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using MediaBrowser.Model.Entities;
  3. using System.Collections.Generic;
  4. using System.Runtime.Serialization;
  5. namespace MediaBrowser.Controller.Entities.Audio
  6. {
  7. /// <summary>
  8. /// Class Audio
  9. /// </summary>
  10. public class Audio : BaseItem, IHasMediaStreams
  11. {
  12. /// <summary>
  13. /// Gets or sets the media streams.
  14. /// </summary>
  15. /// <value>The media streams.</value>
  16. public List<MediaStream> MediaStreams { get; set; }
  17. /// <summary>
  18. /// Override this to true if class should be grouped under a container in indicies
  19. /// The container class should be defined via IndexContainer
  20. /// </summary>
  21. /// <value><c>true</c> if [group in index]; otherwise, <c>false</c>.</value>
  22. [IgnoreDataMember]
  23. public override bool GroupInIndex
  24. {
  25. get
  26. {
  27. return true;
  28. }
  29. }
  30. /// <summary>
  31. /// The unknown album
  32. /// </summary>
  33. private static readonly MusicAlbum UnknownAlbum = new MusicAlbum {Name = "<Unknown>"};
  34. /// <summary>
  35. /// Override this to return the folder that should be used to construct a container
  36. /// for this item in an index. GroupInIndex should be true as well.
  37. /// </summary>
  38. /// <value>The index container.</value>
  39. [IgnoreDataMember]
  40. public override Folder IndexContainer
  41. {
  42. get
  43. {
  44. return Parent is MusicAlbum ? Parent : Album != null ? new MusicAlbum {Name = Album, PrimaryImagePath = PrimaryImagePath } : UnknownAlbum;
  45. }
  46. }
  47. /// <summary>
  48. /// Gets or sets the artist.
  49. /// </summary>
  50. /// <value>The artist.</value>
  51. public string Artist { get; set; }
  52. /// <summary>
  53. /// Gets or sets the album.
  54. /// </summary>
  55. /// <value>The album.</value>
  56. public string Album { get; set; }
  57. /// <summary>
  58. /// Gets or sets the album artist.
  59. /// </summary>
  60. /// <value>The album artist.</value>
  61. public string AlbumArtist { get; set; }
  62. /// <summary>
  63. /// Gets the type of the media.
  64. /// </summary>
  65. /// <value>The type of the media.</value>
  66. public override string MediaType
  67. {
  68. get
  69. {
  70. return Model.Entities.MediaType.Audio;
  71. }
  72. }
  73. /// <summary>
  74. /// Creates the name of the sort.
  75. /// </summary>
  76. /// <returns>System.String.</returns>
  77. protected override string CreateSortName()
  78. {
  79. return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("0000 - ") : "")
  80. + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name;
  81. }
  82. /// <summary>
  83. /// Determines whether the specified name has artist.
  84. /// </summary>
  85. /// <param name="name">The name.</param>
  86. /// <returns><c>true</c> if the specified name has artist; otherwise, <c>false</c>.</returns>
  87. public bool HasArtist(string name)
  88. {
  89. return string.Equals(Artist, name, StringComparison.OrdinalIgnoreCase) || string.Equals(AlbumArtist, name, StringComparison.OrdinalIgnoreCase);
  90. }
  91. public override string DisplayMediaType
  92. {
  93. get
  94. {
  95. return "Song";
  96. }
  97. set
  98. {
  99. base.DisplayMediaType = value;
  100. }
  101. }
  102. }
  103. }