diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-11 23:02:22 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-11 23:02:22 -0500 |
| commit | bbaa0977fdeaa16f0d43bd043ebf794d1b7aec83 (patch) | |
| tree | ab4544f31be0b1ac0e5ee1057d6bc6bc5f5cde0f | |
| parent | 1a81f310a614542471a03bd8993eeded6ab81f10 (diff) | |
cache now playing item
| -rw-r--r-- | Emby.Server.Implementations/Session/SessionManager.cs | 33 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Session/SessionInfo.cs | 5 |
2 files changed, 29 insertions, 9 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 960fe0739..300b67ae2 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -566,6 +566,23 @@ namespace Emby.Server.Implementations.Session } } + private BaseItem GetNowPlayingItem(SessionInfo session, string itemId) + { + var idGuid = new Guid(itemId); + + var item = session.FullNowPlayingItem; + if (item != null && item.Id == idGuid) + { + return item; + } + + item = _libraryManager.GetItemById(itemId); + + session.FullNowPlayingItem = item; + + return item; + } + /// <summary> /// Used to report that playback has started for an item /// </summary> @@ -583,7 +600,7 @@ namespace Emby.Server.Implementations.Session var libraryItem = string.IsNullOrWhiteSpace(info.ItemId) ? null - : _libraryManager.GetItemById(new Guid(info.ItemId)); + : GetNowPlayingItem(session, info.ItemId); await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false); @@ -669,7 +686,7 @@ namespace Emby.Server.Implementations.Session var libraryItem = string.IsNullOrWhiteSpace(info.ItemId) ? null - : _libraryManager.GetItemById(new Guid(info.ItemId)); + : GetNowPlayingItem(session, info.ItemId); await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false); @@ -773,7 +790,7 @@ namespace Emby.Server.Implementations.Session var libraryItem = string.IsNullOrWhiteSpace(info.ItemId) ? null - : _libraryManager.GetItemById(new Guid(info.ItemId)); + : GetNowPlayingItem(session, info.ItemId); // Normalize if (string.IsNullOrWhiteSpace(info.MediaSourceId)) @@ -1782,18 +1799,18 @@ namespace Emby.Server.Implementations.Session throw new ArgumentNullException("itemId"); } - var item = _libraryManager.GetItemById(new Guid(itemId)); + //var item = _libraryManager.GetItemById(new Guid(itemId)); - var info = GetItemInfo(item, null, null); + //var info = GetItemInfo(item, null, null); - ReportNowViewingItem(sessionId, info); + //ReportNowViewingItem(sessionId, info); } public void ReportNowViewingItem(string sessionId, BaseItemInfo item) { - var session = GetSession(sessionId); + //var session = GetSession(sessionId); - session.NowViewingItem = item; + //session.NowViewingItem = item; } public void ReportTranscodingInfo(string deviceId, TranscodingInfo info) diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index b3e82f925..343b15a04 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -3,6 +3,7 @@ using MediaBrowser.Model.Session; using System; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Entities; namespace MediaBrowser.Controller.Session { @@ -106,7 +107,9 @@ namespace MediaBrowser.Controller.Session /// </summary> /// <value>The now playing item.</value> public BaseItemInfo NowPlayingItem { get; set; } - + + public BaseItem FullNowPlayingItem { get; set; } + /// <summary> /// Gets or sets the device id. /// </summary> |
