support samsung dlna bookmarks

This commit is contained in:
Luke Pulverenti 2016-12-26 12:37:49 -05:00
parent d9b0438591
commit 5765b51680
3 changed files with 46 additions and 18 deletions

View File

@ -268,7 +268,7 @@ namespace Emby.Dlna.ContentDirectory
} }
else else
{ {
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, item, null, null, deviceId, filter); _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, item, user, null, null, deviceId, filter);
} }
provided++; provided++;
@ -294,7 +294,7 @@ namespace Emby.Dlna.ContentDirectory
} }
else else
{ {
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, childItem, item, serverItem.StubType, deviceId, filter); _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, childItem, user, item, serverItem.StubType, deviceId, filter);
} }
} }
} }
@ -390,7 +390,7 @@ namespace Emby.Dlna.ContentDirectory
} }
else else
{ {
_didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, i, item, serverItem.StubType, deviceId, filter); _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, i, user, item, serverItem.StubType, deviceId, filter);
} }
} }

View File

@ -61,7 +61,7 @@ namespace Emby.Dlna.Didl
_user = user; _user = user;
} }
public string GetItemDidl(DlnaOptions options, BaseItem item, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo) public string GetItemDidl(DlnaOptions options, BaseItem item, User user, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo)
{ {
var settings = new XmlWriterSettings var settings = new XmlWriterSettings
{ {
@ -86,7 +86,7 @@ namespace Emby.Dlna.Didl
WriteXmlRootAttributes(_profile, writer); WriteXmlRootAttributes(_profile, writer);
WriteItemElement(options, writer, item, context, null, deviceId, filter, streamInfo); WriteItemElement(options, writer, item, user, context, null, deviceId, filter, streamInfo);
writer.WriteFullEndElement(); writer.WriteFullEndElement();
//writer.WriteEndDocument(); //writer.WriteEndDocument();
@ -111,7 +111,15 @@ namespace Emby.Dlna.Didl
} }
} }
public void WriteItemElement(DlnaOptions options, XmlWriter writer, BaseItem item, BaseItem context, StubType? contextStubType, string deviceId, Filter filter, StreamInfo streamInfo = null) public void WriteItemElement(DlnaOptions options,
XmlWriter writer,
BaseItem item,
User user,
BaseItem context,
StubType? contextStubType,
string deviceId,
Filter filter,
StreamInfo streamInfo = null)
{ {
var clientId = GetClientId(item, null); var clientId = GetClientId(item, null);
@ -135,7 +143,7 @@ namespace Emby.Dlna.Didl
AddGeneralProperties(item, null, context, writer, filter); AddGeneralProperties(item, null, context, writer, filter);
//AddBookmarkInfo(item, user, element); AddSamsungBookmarkInfo(item, user, writer);
// refID? // refID?
// storeAttribute(itemNode, object, ClassProperties.REF_ID, false); // storeAttribute(itemNode, object, ClassProperties.REF_ID, false);
@ -555,17 +563,37 @@ namespace Emby.Dlna.Didl
writer.WriteFullEndElement(); writer.WriteFullEndElement();
} }
//private void AddBookmarkInfo(BaseItem item, User user, XmlElement element) private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer)
//{ {
// var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey()); if (!item.SupportsPositionTicksResume || item is Folder)
{
return;
}
// if (userdata.PlaybackPositionTicks > 0) XmlAttribute secAttribute = null;
// { foreach (var attribute in _profile.XmlRootAttributes)
// var dcmInfo = element.OwnerDocument.CreateElement("sec", "dcmInfo", NS_SEC); {
// dcmInfo.InnerText = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture)); if (string.Equals(attribute.Name, "xmlns:sec", StringComparison.OrdinalIgnoreCase))
// element.AppendChild(dcmInfo); {
// } secAttribute = attribute;
//} break;
}
}
// Not a samsung device
if (secAttribute == null)
{
return;
}
var userdata = _userDataManager.GetUserData(user.Id, item);
if (userdata.PlaybackPositionTicks > 0)
{
var elementValue = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture));
AddValue(writer, "sec", "dcmInfo", elementValue, secAttribute.Value);
}
}
/// <summary> /// <summary>
/// Adds fields used by both items and folders /// Adds fields used by both items and folders

View File

@ -493,7 +493,7 @@ namespace Emby.Dlna.PlayTo
playlistItem.StreamUrl = playlistItem.StreamInfo.ToDlnaUrl(_serverAddress, _accessToken); playlistItem.StreamUrl = playlistItem.StreamInfo.ToDlnaUrl(_serverAddress, _accessToken);
var itemXml = new DidlBuilder(profile, user, _imageProcessor, _serverAddress, _accessToken, _userDataManager, _localization, _mediaSourceManager, _logger, _libraryManager, _mediaEncoder) var itemXml = new DidlBuilder(profile, user, _imageProcessor, _serverAddress, _accessToken, _userDataManager, _localization, _mediaSourceManager, _logger, _libraryManager, _mediaEncoder)
.GetItemDidl(_config.GetDlnaConfiguration(), item, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo); .GetItemDidl(_config.GetDlnaConfiguration(), item, user, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo);
playlistItem.Didl = itemXml; playlistItem.Didl = itemXml;