diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-03-06 23:56:45 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-03-06 23:56:45 -0500 |
| commit | a8296cba37357a476b279bccd8d085ce123c600a (patch) | |
| tree | 6e147ecd0e875a13d5fc244e70a2f66b9bd29417 /MediaBrowser.Server.Implementations/Session/SessionManager.cs | |
| parent | f7e9e9f7a5da3c5fcd0e52d53c9e0daabae8b8ef (diff) | |
update recording stop
Diffstat (limited to 'MediaBrowser.Server.Implementations/Session/SessionManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Session/SessionManager.cs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 08953b0be..824e5e0e8 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -813,7 +813,7 @@ namespace MediaBrowser.Server.Implementations.Session foreach (var user in users) { - playedToCompletion = await OnPlaybackStopped(user.Id, key, libraryItem, info.PositionTicks).ConfigureAwait(false); + playedToCompletion = await OnPlaybackStopped(user.Id, key, libraryItem, info.PositionTicks, info.Failed).ConfigureAwait(false); } } @@ -846,25 +846,29 @@ namespace MediaBrowser.Server.Implementations.Session await SendPlaybackStoppedNotification(session, CancellationToken.None).ConfigureAwait(false); } - private async Task<bool> OnPlaybackStopped(Guid userId, string userDataKey, BaseItem item, long? positionTicks) + private async Task<bool> OnPlaybackStopped(Guid userId, string userDataKey, BaseItem item, long? positionTicks, bool playbackFailed) { - var data = _userDataRepository.GetUserData(userId, userDataKey); - bool playedToCompletion; + bool playedToCompletion = false; - if (positionTicks.HasValue) + if (!playbackFailed) { - playedToCompletion = _userDataRepository.UpdatePlayState(item, data, positionTicks.Value); - } - else - { - // If the client isn't able to report this, then we'll just have to make an assumption - data.PlayCount++; - data.Played = true; - data.PlaybackPositionTicks = 0; - playedToCompletion = true; - } + var data = _userDataRepository.GetUserData(userId, userDataKey); + + if (positionTicks.HasValue) + { + playedToCompletion = _userDataRepository.UpdatePlayState(item, data, positionTicks.Value); + } + else + { + // If the client isn't able to report this, then we'll just have to make an assumption + data.PlayCount++; + data.Played = true; + data.PlaybackPositionTicks = 0; + playedToCompletion = true; + } - await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false); + await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false); + } return playedToCompletion; } |
