diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-03-25 13:52:36 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-03-25 13:52:36 -0400 |
| commit | d9108f69f35080acb5ebefaefcd469595529afa2 (patch) | |
| tree | 3f04e719877b9cdec9529ca34406b753f6492abc /MediaBrowser.Server.Implementations/Session/SessionManager.cs | |
| parent | d6832e7a41c2a24f7dd998284e8e4f6eacf1d188 (diff) | |
| parent | 72fe76ab1008f0bd38157cc37cde45797b5f6417 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/Emby
Diffstat (limited to 'MediaBrowser.Server.Implementations/Session/SessionManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Session/SessionManager.cs | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 08953b0be..98127d39a 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -705,7 +705,9 @@ namespace MediaBrowser.Server.Implementations.Session MediaInfo = info.Item, DeviceName = session.DeviceName, ClientName = session.Client, - DeviceId = session.DeviceId + DeviceId = session.DeviceId, + IsPaused = info.IsPaused, + PlaySessionId = info.PlaySessionId }, _logger); @@ -813,7 +815,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 +848,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; } |
