Example #1
0
        private DLNAFile GetDLNAFileInformation(string objectID)
        {
            if (ContentDirectory == null)
            {
                return(null);
            }

            DLNAFile dlnaFile = null;

            #region Request
            string browseFlag     = "BrowseMetadata"; // BrowseDirectChildren or BrowseMetadata as allowed values
            string filter         = "upnp:album,upnp:artist,upnp:genre,upnp:title,upnp:icon,res@size,res@duration,res@bitrate,res@sampleFrequency,res@bitsPerSample,res@nrAudioChannels,res@protocolInfo,res@protection,res@importUri";
            int    startingIndex  = 0;
            int    requestedCount = 1;
            string sortCriteria   = "";

            object[] inArgs = new object[6];
            inArgs[0] = objectID;
            inArgs[1] = browseFlag;
            inArgs[2] = filter;
            inArgs[3] = startingIndex;
            inArgs[4] = requestedCount;
            inArgs[5] = sortCriteria;

            object outArgs = new object[4];
            ContentDirectory.InvokeAction("Browse", inArgs, ref outArgs);
            #endregion

            #region Responce
            object[] resultobj = (object[])outArgs;

            string result         = (string)resultobj[0];
            int    numberReturned = (int)(UInt32)resultobj[1];
            int    totalMatches   = (int)(UInt32)resultobj[2];
            int    updateID       = (int)(UInt32)resultobj[3];

            if (outArgs == null)
            {
                return(null);
            }
            #endregion

            //extracting file metadata from responce
            var myXMLDoc = new XmlDocument();

            myXMLDoc.LoadXml(Convert.ToString(result));

            if (myXMLDoc.DocumentElement.ChildNodes.Count == 1)
            {
                dlnaFile = (DLNAFile)DLNAObject.CreateDLNAObject(myXMLDoc.DocumentElement.ChildNodes[0]);
            }

            return(dlnaFile);
        }
Example #2
0
        public static object CreateDLNAObject(XmlNode xmlNode)
        {
            DLNAObject newObject = null;

            switch (xmlNode.Name.ToLower())
            {
            case "item":
            {
                newObject = new DLNAFile(xmlNode);
                break;
            }

            case "container":
            {
                newObject = new DLNAFolder(xmlNode);
                break;
            }
            }
            return(newObject);
        }