Пример #1
0
        public NodeItem Create(ItemDesc aDesc, ref UInt32 aNextId)
        {
            NodeItem item = new NodeItem(aNextId, aDesc.Id, aDesc.LibItem);

            aNextId++;
            return(item);
        }
Пример #2
0
 public void Add(NodeItem aItem)
 {
     iItemList.Add(aItem);
     if (iComparer != null)
     {
         iItemList.Sort(iComparer);
     }
 }
Пример #3
0
        public void Add(NodeContainer aParent, LibraryPlaylist aPlaylist, ref UInt32 aNextId)
        {
            // create the container for the playlist
            NodePlaylist playlist = new NodePlaylist(aPlaylist.Name, aNextId, null);

            aNextId++;

            // given that the ID (from the aNextId variable) is unique, it is easy to construct
            // a unique key for the playlist - having <playlistname><playlistid> ensures
            // uniqueness and alphabetical sorting
            aParent.Add(playlist.Name + playlist.Id.ToString(), playlist);

            // add all tracks
            foreach (long libItemId in aPlaylist.Items)
            {
                if (iItemDict.ContainsKey(libItemId))
                {
                    ItemDesc desc = iItemDict[libItemId];
                    NodeItem item = new NodeItem(aNextId, desc.Id, desc.LibItem);
                    aNextId++;
                    playlist.Add(item);
                }
            }
        }
Пример #4
0
 // these types are ignored
 public void Process(NodeItem aNode)
 {
 }
Пример #5
0
        public void Process(NodeItem aNode)
        {
            LibraryItem libItem = aNode.LibraryItem;

            musicTrack track = new musicTrack();

            track.Id          = aNode.Id.ToString();
            track.RefId       = aNode.RefId.ToString();
            track.ParentId    = iParent.Id.ToString();
            track.Restricted  = true;
            track.WriteStatus = "PROTECTED";

            if (libItem.Name != null)
            {
                track.Title = libItem.Name;
            }

            if (libItem.Album != null)
            {
                track.Album.Add(libItem.Album);
            }

            if (libItem.Artist != null)
            {
                artist artist = new artist();
                artist.Artist = libItem.Artist;
                track.Artist.Add(artist);
            }

            if (libItem.Genre != null)
            {
                track.Genre.Add(libItem.Genre);
            }

            if (libItem.DiscCount != -1)
            {
                track.OriginalDiscCount = (int)libItem.DiscCount;
            }

            if (libItem.DiscNumber != -1)
            {
                track.OriginalDiscNumber = (int)libItem.DiscNumber;
            }

            if (libItem.TrackNumber != -1)
            {
                track.OriginalTrackNumber = (int)libItem.TrackNumber;
            }

            resource res = new resource();

            if (libItem.BitRate != -1)
            {
                res.Bitrate = ((int)libItem.BitRate * 1000) / 8;
            }

            if (libItem.SampleRate != -1)
            {
                res.SampleFrequency = (int)libItem.SampleRate;
            }

            if (libItem.Size != -1)
            {
                res.Size = libItem.Size;
            }

            if (libItem.TotalTime != -1)
            {
                Upnp.Time totalTime = new Time(Convert.ToInt32(libItem.TotalTime / 1000));
                res.Duration = totalTime.ToString();
            }

            if (libItem.Kind.Contains("MPEG audio file"))
            {
                res.ProtocolInfo = "http-get:*:audio/mpeg:*";
            }
            else if (libItem.Kind.Contains("WAV audio file"))
            {
                res.ProtocolInfo = "http-get:*:audio/x-wav:*";
            }
            else if (libItem.Kind.Contains("AIFF audio file"))
            {
                res.ProtocolInfo = "http-get:*:audio/x-aiff:*";
            }
            else if (libItem.Kind.Contains("AAC audio file"))
            {
                res.ProtocolInfo = "http-get:*:audio/x-m4a:*";
            }
            else if (libItem.Kind.Contains("Apple Lossless audio file"))
            {
                res.ProtocolInfo = "http-get:*:audio/x-m4a:*";
            }
            else
            {
                // if the file kind is unrecognised, set the protocol info so the
                // DS will decide - this means that KDT will add the track to the
                // DS playlist and then the DS can decide whether it wants to play it
                res.ProtocolInfo = "http-get:*:*:*";
            }

            if (libItem.Location != null)
            {
                System.Uri uri = new System.Uri(libItem.Location);
                if (uri.Scheme == "file" && uri.Host == "localhost")
                {
                    // handle paths that are "/Users/..." or "/C:\\Users\\..." i.e. mac or windows
                    // strings passed to the VirtualFileSystem.Uri method must be unescaped. The unescaping
                    // was initially implemented at the point where the Location element is read from
                    // the XML file (the Location URI in the XML file is escaped). However, when this
                    // unescaped string was passed to the Uri constructor, the uri.AbsolutePath returns
                    // an **escaped** string, thus another unescape had to be performed here anyway. So,
                    // no point in doing it twice - just do it here
                    string path = System.Uri.UnescapeDataString(uri.AbsolutePath);
                    if (path[2] == ':')
                    {
                        path = path.Substring(1);
                    }
                    try
                    {
                        res.Uri = iSupport.VirtualFileSystem.Uri(path);
                    }
                    catch (HttpServerException) { }
                }
            }

            if (res.ProtocolInfo != "" && res.Uri != "")
            {
                track.Res.Add(res);
            }

            if (libItem.AlbumArtId != null)
            {
                string filename = iLibrary.GetAlbumArtFilenameNoExt(libItem.AlbumArtId) + libItem.AlbumArtExt;
                try
                {
                    string albumArtUri = iSupport.VirtualFileSystem.Uri(filename);
                    track.AlbumArtUri.Add(albumArtUri);
                }
                catch (HttpServerException) { }
            }

            iMetadata = track;
        }
Пример #6
0
        public void Add(NodeContainer aParent, ItemDesc aDesc, ref UInt32 aNextId)
        {
            NodeItem item = iFactory.Create(aDesc, ref aNextId);

            aParent.Add(item);
        }