Audio.cs 3.4 KB

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