catch when negative playback position is reported

This commit is contained in:
Luke Pulverenti 2013-07-18 08:00:57 -04:00
parent 69f4ef6c77
commit aec36e8096

View File

@ -255,14 +255,13 @@ namespace MediaBrowser.Server.Implementations.Session
/// <summary> /// <summary>
/// Used to report playback progress for an item /// Used to report playback progress for an item
/// </summary> /// </summary>
/// <param name="user">The user.</param>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="positionTicks">The position ticks.</param> /// <param name="positionTicks">The position ticks.</param>
/// <param name="isPaused">if set to <c>true</c> [is paused].</param> /// <param name="isPaused">if set to <c>true</c> [is paused].</param>
/// <param name="sessionId">The session id.</param> /// <param name="sessionId">The session id.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException"> /// <exception cref="System.ArgumentNullException"></exception>
/// </exception> /// <exception cref="System.ArgumentOutOfRangeException">positionTicks</exception>
public async Task OnPlaybackProgress(BaseItem item, long? positionTicks, bool isPaused, Guid sessionId) public async Task OnPlaybackProgress(BaseItem item, long? positionTicks, bool isPaused, Guid sessionId)
{ {
if (item == null) if (item == null)
@ -270,6 +269,11 @@ namespace MediaBrowser.Server.Implementations.Session
throw new ArgumentNullException(); throw new ArgumentNullException();
} }
if (positionTicks.HasValue && positionTicks.Value < 0)
{
throw new ArgumentOutOfRangeException("positionTicks");
}
var session = Sessions.First(i => i.Id.Equals(sessionId)); var session = Sessions.First(i => i.Id.Equals(sessionId));
UpdateNowPlayingItem(session, item, isPaused, positionTicks); UpdateNowPlayingItem(session, item, isPaused, positionTicks);
@ -310,6 +314,11 @@ namespace MediaBrowser.Server.Implementations.Session
throw new ArgumentNullException(); throw new ArgumentNullException();
} }
if (positionTicks.HasValue && positionTicks.Value < 0)
{
throw new ArgumentOutOfRangeException("positionTicks");
}
var session = Sessions.First(i => i.Id.Equals(sessionId)); var session = Sessions.First(i => i.Id.Equals(sessionId));
RemoveNowPlayingItem(session, item); RemoveNowPlayingItem(session, item);