本文整理汇总了C#中MediaItem.ToDidl方法的典型用法代码示例。如果您正苦于以下问题:C# MediaItem.ToDidl方法的具体用法?C# MediaItem.ToDidl怎么用?C# MediaItem.ToDidl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaItem
的用法示例。
在下文中一共展示了MediaItem.ToDidl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: server_BrowseMetadata
private int server_BrowseMetadata(Action action, String object_id, String filter, Int32 starting_index, Int32 requested_count, String sort_criteria, HttpRequestContext context)
{
Console.WriteLine("BrowseMetadata: " + object_id);
if (object_id == "0")
{
var root = new MediaContainer();
root.Title = "Root";
root.ObjectID = "0";
root.ParentID = "-1";
root.Class = new ObjectClass("object.container.storageFolder", "");
var didl = Didl.header + root.ToDidl(filter) + Didl.footer;
action.SetArgumentValue("Result", didl);
action.SetArgumentValue("NumberReturned", "1");
action.SetArgumentValue("TotalMatches", "1");
// update ID may be wrong here, it should be the one of the container?
// TODO: We need to keep track of the overall updateID of the CDS
action.SetArgumentValue("UpdateId", "1");
return 0;
}
else if (object_id == "1")
{
var item = new MediaItem();
item.Title = "Item";
item.ObjectID = "1";
item.ParentID = "0";
item.Class = new ObjectClass("object.item.audioItem.musicTrack", "");
var resource = new MediaResource();
resource.ProtoInfo = ProtocolInfo.GetProtocolInfoFromMimeType("audio/mp3", true, context);
// get list of ips and make sure the ip the request came from is used for the first resource returned
// this ensures that clients which look only at the first resource will be able to reach the item
List<String> ips = UPnP.GetIpAddresses(true);
String localIP = context.LocalAddress.ip;
if (localIP != "0.0.0.0")
{
ips.Remove(localIP);
ips.Insert(0, localIP);
}
// iterate through all ips and create a resource for each
foreach (String ip in ips)
{
resource.URI = new Uri("http://" + ip + ":" + context.LocalAddress.port + "/test/test.mp3").ToString();
item.AddResource(resource);
}
var didl = Didl.header + item.ToDidl(filter) + Didl.footer;
action.SetArgumentValue("Result", didl);
action.SetArgumentValue("NumberReturned", "1");
action.SetArgumentValue("TotalMatches", "1");
// update ID may be wrong here, it should be the one of the container?
// TODO: We need to keep track of the overall updateID of the CDS
action.SetArgumentValue("UpdateId", "1");
return 0;
}
return -1;
}