diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
index 7db15281f6..ead0b7fdbf 100644
--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
+++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
@@ -697,7 +697,16 @@ namespace MediaBrowser.Api.UserLibrary
var item = _dtoService.GetItemByDtoId(request.Id, user.Id);
- var task = _sessionManager.OnPlaybackProgress(item, request.PositionTicks, request.IsPaused, request.IsMuted, GetSession().Id);
+ var info = new PlaybackProgressInfo
+ {
+ Item = item,
+ PositionTicks = request.PositionTicks,
+ IsMuted = request.IsMuted,
+ IsPaused = request.IsPaused,
+ SessionId = GetSession().Id
+ };
+
+ var task = _sessionManager.OnPlaybackProgress(info);
Task.WaitAll(task);
}
@@ -717,7 +726,14 @@ namespace MediaBrowser.Api.UserLibrary
var session = GetSession();
- var task = _sessionManager.OnPlaybackStopped(item, request.PositionTicks, session.Id);
+ var info = new PlaybackStopInfo
+ {
+ Item = item,
+ PositionTicks = request.PositionTicks,
+ SessionId = session.Id
+ };
+
+ var task = _sessionManager.OnPlaybackStopped(info);
Task.WaitAll(task);
}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index df777c0ce5..3b94ea35c1 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -175,6 +175,8 @@
+
+
diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs
index 0932ee52d5..138aa1fc36 100644
--- a/MediaBrowser.Controller/Session/ISessionManager.cs
+++ b/MediaBrowser.Controller/Session/ISessionManager.cs
@@ -62,24 +62,18 @@ namespace MediaBrowser.Controller.Session
///
/// Used to report playback progress for an item
///
- /// The item.
- /// The position ticks.
- /// if set to true [is paused].
- /// if set to true [is muted].
- /// The session id.
+ /// The info.
/// Task.
///
- Task OnPlaybackProgress(BaseItem item, long? positionTicks, bool isPaused, bool isMuted, Guid sessionId);
+ Task OnPlaybackProgress(PlaybackProgressInfo info);
///
/// Used to report that playback has ended for an item
///
- /// The item.
- /// The position ticks.
- /// The session id.
+ /// The info.
/// Task.
///
- Task OnPlaybackStopped(BaseItem item, long? positionTicks, Guid sessionId);
+ Task OnPlaybackStopped(PlaybackStopInfo info);
///
/// Sends the system command.
diff --git a/MediaBrowser.Controller/Session/PlaybackProgressInfo.cs b/MediaBrowser.Controller/Session/PlaybackProgressInfo.cs
new file mode 100644
index 0000000000..a075432605
--- /dev/null
+++ b/MediaBrowser.Controller/Session/PlaybackProgressInfo.cs
@@ -0,0 +1,38 @@
+using MediaBrowser.Controller.Entities;
+using System;
+
+namespace MediaBrowser.Controller.Session
+{
+ public class PlaybackProgressInfo
+ {
+ ///
+ /// Gets or sets the item.
+ ///
+ /// The item.
+ public BaseItem Item { get; set; }
+
+ ///
+ /// Gets or sets the session id.
+ ///
+ /// The session id.
+ public Guid SessionId { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether this instance is paused.
+ ///
+ /// true if this instance is paused; otherwise, false.
+ public bool IsPaused { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether this instance is muted.
+ ///
+ /// true if this instance is muted; otherwise, false.
+ public bool IsMuted { get; set; }
+
+ ///
+ /// Gets or sets the position ticks.
+ ///
+ /// The position ticks.
+ public long? PositionTicks { get; set; }
+ }
+}
diff --git a/MediaBrowser.Controller/Session/PlaybackStopInfo.cs b/MediaBrowser.Controller/Session/PlaybackStopInfo.cs
new file mode 100644
index 0000000000..5d1ce01315
--- /dev/null
+++ b/MediaBrowser.Controller/Session/PlaybackStopInfo.cs
@@ -0,0 +1,26 @@
+using MediaBrowser.Controller.Entities;
+using System;
+
+namespace MediaBrowser.Controller.Session
+{
+ public class PlaybackStopInfo
+ {
+ ///
+ /// Gets or sets the item.
+ ///
+ /// The item.
+ public BaseItem Item { get; set; }
+
+ ///
+ /// Gets or sets the session id.
+ ///
+ /// The session id.
+ public Guid SessionId { get; set; }
+
+ ///
+ /// Gets or sets the position ticks.
+ ///
+ /// The position ticks.
+ public long? PositionTicks { get; set; }
+ }
+}
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
index 79dfbc8a52..346c496ce3 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
@@ -266,46 +266,43 @@ namespace MediaBrowser.Server.Implementations.Session
///
/// Used to report playback progress for an item
///
- /// The item.
- /// The position ticks.
- /// if set to true [is paused].
- /// The session id.
+ /// The info.
/// Task.
///
/// positionTicks
- public async Task OnPlaybackProgress(BaseItem item, long? positionTicks, bool isPaused, bool isMuted, Guid sessionId)
+ public async Task OnPlaybackProgress(PlaybackProgressInfo info)
{
- if (item == null)
+ if (info == null)
{
- throw new ArgumentNullException();
+ throw new ArgumentNullException("info");
}
- if (positionTicks.HasValue && positionTicks.Value < 0)
+ if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0)
{
throw new ArgumentOutOfRangeException("positionTicks");
}
- var session = Sessions.First(i => i.Id.Equals(sessionId));
+ var session = Sessions.First(i => i.Id.Equals(info.SessionId));
- UpdateNowPlayingItem(session, item, isPaused, isMuted, positionTicks);
+ UpdateNowPlayingItem(session, info.Item, info.IsPaused, info.IsMuted, info.PositionTicks);
- var key = item.GetUserDataKey();
+ var key = info.Item.GetUserDataKey();
var user = session.User;
- if (positionTicks.HasValue)
+ if (info.PositionTicks.HasValue)
{
var data = _userDataRepository.GetUserData(user.Id, key);
- UpdatePlayState(item, data, positionTicks.Value);
+ UpdatePlayState(info.Item, data, info.PositionTicks.Value);
await _userDataRepository.SaveUserData(user.Id, key, data, CancellationToken.None).ConfigureAwait(false);
}
EventHelper.QueueEventIfNotNull(PlaybackProgress, this, new PlaybackProgressEventArgs
{
- Item = item,
+ Item = info.Item,
User = user,
- PlaybackPositionTicks = positionTicks
+ PlaybackPositionTicks = info.PositionTicks
}, _logger);
}
@@ -313,36 +310,35 @@ namespace MediaBrowser.Server.Implementations.Session
///
/// Used to report that playback has ended for an item
///
- /// The item.
- /// The position ticks.
- /// The session id.
+ /// The info.
/// Task.
- ///
- public async Task OnPlaybackStopped(BaseItem item, long? positionTicks, Guid sessionId)
+ /// info
+ /// positionTicks
+ public async Task OnPlaybackStopped(PlaybackStopInfo info)
{
- if (item == null)
+ if (info == null)
{
- throw new ArgumentNullException();
+ throw new ArgumentNullException("info");
}
- if (positionTicks.HasValue && positionTicks.Value < 0)
+ if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0)
{
throw new ArgumentOutOfRangeException("positionTicks");
}
- var session = Sessions.First(i => i.Id.Equals(sessionId));
+ var session = Sessions.First(i => i.Id.Equals(info.SessionId));
- RemoveNowPlayingItem(session, item);
+ RemoveNowPlayingItem(session, info.Item);
- var key = item.GetUserDataKey();
+ var key = info.Item.GetUserDataKey();
var user = session.User;
var data = _userDataRepository.GetUserData(user.Id, key);
- if (positionTicks.HasValue)
+ if (info.PositionTicks.HasValue)
{
- UpdatePlayState(item, data, positionTicks.Value);
+ UpdatePlayState(info.Item, data, info.PositionTicks.Value);
}
else
{
@@ -356,9 +352,9 @@ namespace MediaBrowser.Server.Implementations.Session
EventHelper.QueueEventIfNotNull(PlaybackStopped, this, new PlaybackProgressEventArgs
{
- Item = item,
+ Item = info.Item,
User = user,
- PlaybackPositionTicks = positionTicks
+ PlaybackPositionTicks = info.PositionTicks
}, _logger);
}
diff --git a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs
index 95eb5948f3..0781e82286 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -128,7 +128,16 @@ namespace MediaBrowser.Server.Implementations.Session
var isPaused = vals.Length > 2 && string.Equals(vals[2], "true", StringComparison.OrdinalIgnoreCase);
var isMuted = vals.Length > 3 && string.Equals(vals[3], "true", StringComparison.OrdinalIgnoreCase);
- _sessionManager.OnPlaybackProgress(item, positionTicks, isPaused, isMuted, session.Id);
+ var info = new PlaybackProgressInfo
+ {
+ Item = item,
+ PositionTicks = positionTicks,
+ IsMuted = isMuted,
+ IsPaused = isPaused,
+ SessionId = session.Id
+ };
+
+ _sessionManager.OnPlaybackProgress(info);
}
}
else if (string.Equals(message.MessageType, "PlaybackStopped", StringComparison.OrdinalIgnoreCase))
@@ -155,7 +164,14 @@ namespace MediaBrowser.Server.Implementations.Session
}
}
- _sessionManager.OnPlaybackStopped(item, positionTicks, session.Id);
+ var info = new PlaybackStopInfo
+ {
+ Item = item,
+ PositionTicks = positionTicks,
+ SessionId = session.Id
+ };
+
+ _sessionManager.OnPlaybackStopped(info);
}
}