mirror of https://github.com/jellyfin/jellyfin.git
cache now playing item
This commit is contained in:
parent
1a81f310a6
commit
bbaa0977fd
|
@ -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>
|
/// <summary>
|
||||||
/// Used to report that playback has started for an item
|
/// Used to report that playback has started for an item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -583,7 +600,7 @@ namespace Emby.Server.Implementations.Session
|
||||||
|
|
||||||
var libraryItem = string.IsNullOrWhiteSpace(info.ItemId)
|
var libraryItem = string.IsNullOrWhiteSpace(info.ItemId)
|
||||||
? null
|
? null
|
||||||
: _libraryManager.GetItemById(new Guid(info.ItemId));
|
: GetNowPlayingItem(session, info.ItemId);
|
||||||
|
|
||||||
await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false);
|
await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -669,7 +686,7 @@ namespace Emby.Server.Implementations.Session
|
||||||
|
|
||||||
var libraryItem = string.IsNullOrWhiteSpace(info.ItemId)
|
var libraryItem = string.IsNullOrWhiteSpace(info.ItemId)
|
||||||
? null
|
? null
|
||||||
: _libraryManager.GetItemById(new Guid(info.ItemId));
|
: GetNowPlayingItem(session, info.ItemId);
|
||||||
|
|
||||||
await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false);
|
await UpdateNowPlayingItem(session, info, libraryItem).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -773,7 +790,7 @@ namespace Emby.Server.Implementations.Session
|
||||||
|
|
||||||
var libraryItem = string.IsNullOrWhiteSpace(info.ItemId)
|
var libraryItem = string.IsNullOrWhiteSpace(info.ItemId)
|
||||||
? null
|
? null
|
||||||
: _libraryManager.GetItemById(new Guid(info.ItemId));
|
: GetNowPlayingItem(session, info.ItemId);
|
||||||
|
|
||||||
// Normalize
|
// Normalize
|
||||||
if (string.IsNullOrWhiteSpace(info.MediaSourceId))
|
if (string.IsNullOrWhiteSpace(info.MediaSourceId))
|
||||||
|
@ -1782,18 +1799,18 @@ namespace Emby.Server.Implementations.Session
|
||||||
throw new ArgumentNullException("itemId");
|
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)
|
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)
|
public void ReportTranscodingInfo(string deviceId, TranscodingInfo info)
|
||||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Model.Session;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Session
|
namespace MediaBrowser.Controller.Session
|
||||||
{
|
{
|
||||||
|
@ -106,7 +107,9 @@ namespace MediaBrowser.Controller.Session
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The now playing item.</value>
|
/// <value>The now playing item.</value>
|
||||||
public BaseItemInfo NowPlayingItem { get; set; }
|
public BaseItemInfo NowPlayingItem { get; set; }
|
||||||
|
|
||||||
|
public BaseItem FullNowPlayingItem { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the device id.
|
/// Gets or sets the device id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue