SessionInfo.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using MediaBrowser.Controller.Entities;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace MediaBrowser.Controller.Session
  5. {
  6. /// <summary>
  7. /// Class SessionInfo
  8. /// </summary>
  9. public class SessionInfo
  10. {
  11. public SessionInfo()
  12. {
  13. QueueableMediaTypes = new List<string>();
  14. }
  15. /// <summary>
  16. /// Gets or sets a value indicating whether this instance can seek.
  17. /// </summary>
  18. /// <value><c>true</c> if this instance can seek; otherwise, <c>false</c>.</value>
  19. public bool CanSeek { get; set; }
  20. /// <summary>
  21. /// Gets or sets the queueable media types.
  22. /// </summary>
  23. /// <value>The queueable media types.</value>
  24. public List<string> QueueableMediaTypes { get; set; }
  25. /// <summary>
  26. /// Gets or sets the id.
  27. /// </summary>
  28. /// <value>The id.</value>
  29. public Guid Id { get; set; }
  30. /// <summary>
  31. /// Gets or sets the user id.
  32. /// </summary>
  33. /// <value>The user id.</value>
  34. public User User { get; set; }
  35. /// <summary>
  36. /// Gets or sets the type of the client.
  37. /// </summary>
  38. /// <value>The type of the client.</value>
  39. public string Client { get; set; }
  40. /// <summary>
  41. /// Gets or sets the last activity date.
  42. /// </summary>
  43. /// <value>The last activity date.</value>
  44. public DateTime LastActivityDate { get; set; }
  45. /// <summary>
  46. /// Gets or sets the name of the device.
  47. /// </summary>
  48. /// <value>The name of the device.</value>
  49. public string DeviceName { get; set; }
  50. /// <summary>
  51. /// Gets or sets the now viewing context.
  52. /// </summary>
  53. /// <value>The now viewing context.</value>
  54. public string NowViewingContext { get; set; }
  55. /// <summary>
  56. /// Gets or sets the type of the now viewing item.
  57. /// </summary>
  58. /// <value>The type of the now viewing item.</value>
  59. public string NowViewingItemType { get; set; }
  60. /// <summary>
  61. /// Gets or sets the now viewing item identifier.
  62. /// </summary>
  63. /// <value>The now viewing item identifier.</value>
  64. public string NowViewingItemId { get; set; }
  65. /// <summary>
  66. /// Gets or sets the name of the now viewing item.
  67. /// </summary>
  68. /// <value>The name of the now viewing item.</value>
  69. public string NowViewingItemName { get; set; }
  70. /// <summary>
  71. /// Gets or sets the now playing item.
  72. /// </summary>
  73. /// <value>The now playing item.</value>
  74. public BaseItem NowPlayingItem { get; set; }
  75. /// <summary>
  76. /// Gets or sets the now playing position ticks.
  77. /// </summary>
  78. /// <value>The now playing position ticks.</value>
  79. public long? NowPlayingPositionTicks { get; set; }
  80. /// <summary>
  81. /// Gets or sets a value indicating whether this instance is paused.
  82. /// </summary>
  83. /// <value><c>true</c> if this instance is paused; otherwise, <c>false</c>.</value>
  84. public bool IsPaused { get; set; }
  85. /// <summary>
  86. /// Gets or sets a value indicating whether this instance is muted.
  87. /// </summary>
  88. /// <value><c>true</c> if this instance is muted; otherwise, <c>false</c>.</value>
  89. public bool IsMuted { get; set; }
  90. /// <summary>
  91. /// Gets or sets the device id.
  92. /// </summary>
  93. /// <value>The device id.</value>
  94. public string DeviceId { get; set; }
  95. /// <summary>
  96. /// Gets or sets the application version.
  97. /// </summary>
  98. /// <value>The application version.</value>
  99. public string ApplicationVersion { get; set; }
  100. /// <summary>
  101. /// Gets or sets the session controller.
  102. /// </summary>
  103. /// <value>The session controller.</value>
  104. public ISessionController SessionController { get; set; }
  105. /// <summary>
  106. /// Gets a value indicating whether this instance is active.
  107. /// </summary>
  108. /// <value><c>true</c> if this instance is active; otherwise, <c>false</c>.</value>
  109. public bool IsActive
  110. {
  111. get
  112. {
  113. if (SessionController != null)
  114. {
  115. return SessionController.IsSessionActive;
  116. }
  117. return (DateTime.UtcNow - LastActivityDate).TotalMinutes <= 10;
  118. }
  119. }
  120. /// <summary>
  121. /// Gets a value indicating whether [supports remote control].
  122. /// </summary>
  123. /// <value><c>true</c> if [supports remote control]; otherwise, <c>false</c>.</value>
  124. public bool SupportsRemoteControl
  125. {
  126. get
  127. {
  128. if (SessionController != null)
  129. {
  130. return SessionController.SupportsMediaRemoteControl;
  131. }
  132. return false;
  133. }
  134. }
  135. }
  136. }