当前位置: 首页>>代码示例>>C#>>正文


C# MediaItem.AddResource方法代码示例

本文整理汇总了C#中MediaItem.AddResource方法的典型用法代码示例。如果您正苦于以下问题:C# MediaItem.AddResource方法的具体用法?C# MediaItem.AddResource怎么用?C# MediaItem.AddResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaItem的用法示例。


在下文中一共展示了MediaItem.AddResource方法的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;
        }
开发者ID:Eruzo,项目名称:xbmc,代码行数:64,代码来源:Program.cs


注:本文中的MediaItem.AddResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。