void airtunesServer_MetaDataChanged(object sender, MetaDataChangedEventArgs e) { invoke(delegate() { currentMeta = e.MetaData; setMetaData(); }, false); }
void airtunesServer_MetaDataChanged(object sender, MetaDataChangedEventArgs e) { lock (audioInfoSync) { currentMeta = e.MetaData; updateCurrentItem(); } }
public void SetMetaData(DmapData metaData) { Aspects[MediaAspect.ASPECT_ID].SetAttribute(MediaAspect.ATTR_TITLE, metaData.Track); MediaItemAspect audioAspect = Aspects[AudioAspect.ASPECT_ID]; audioAspect.SetAttribute(AudioAspect.ATTR_ALBUM, metaData.Album); audioAspect.SetCollectionAttribute(AudioAspect.ATTR_ARTISTS, new[] { metaData.Artist }); audioAspect.SetCollectionAttribute(AudioAspect.ATTR_GENRES, new[] { metaData.Genre }); }
public static DmapData ExtractMetaDataFromDidlLite(string metaData, out string coverUrl) { if (string.IsNullOrEmpty(metaData)) { coverUrl = string.Empty; return(null); } DmapData dmapData = new DmapData(); List <string> directors = new List <string>(); List <string> artists = new List <string>(); List <string> actors = new List <string>(); List <string> genres = new List <string>(); coverUrl = string.Empty; // there is a bug in the xmlreader when there is no newline in the xml document // https://social.msdn.microsoft.com/Forums/silverlight/en-US/04cd225d-6c09-427b-9586-f81848b22e08/xml-parsing-problem-xmlrearderreadtofollowing-causes-problem?forum=silverlightnet /* * Hi Steve, * * Thank you very much. I could solve my problem. * * The cause was that my xml did not contain any line breaks. * * When I rewrote the xml adding line breaks, the Xml.Reader.ReadToFollowing method could successfully find the all elements. * * Again, thank you very much for your help! */ using (XmlReader reader = XmlReader.Create(new StringReader(metaData))) { while (reader.Read()) { Logger.Debug("Name: {0} - Value: {1}", reader.Name, reader.Value); if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { // DIDL-Lite // DC: http://www.upnp.org/schemas/av/didl-lite-v2.xsd case "dc:title": reader.Read(); if (reader.Value != string.Empty) { dmapData.Title = reader.Value; Logger.Debug("Title value: {0}", dmapData.Title); } break; case "dc:description": reader.Read(); if (reader.Value != string.Empty) { dmapData.Description = reader.Value; Logger.Debug("Description value: {0}", dmapData.Description); } break; case "dc:creator": reader.Read(); if (reader.Value != string.Empty) { dmapData.Creator = reader.Value; Logger.Debug("Creator value: {0}", dmapData.Creator); } break; // UPnP: http://www.upnp.org/schemas/av/upnp.xsd // Contributor Related Properties case "upnp:director": reader.Read(); if (reader.Value != string.Empty) { directors.Add(reader.Value); Logger.Debug("Director value: {0}", directors.Last()); } break; case "upnp:artist": reader.Read(); if (reader.Value != string.Empty) { artists.Add(reader.Value); Logger.Debug("Artists value: {0}", artists.Last()); } break; case "upnp:actor": reader.Read(); if (reader.Value != string.Empty) { actors.Add(reader.Value); Logger.Debug("Actors value: {0}", actors.Last()); } break; // missing: author, producer //Affiliation Related Properties case "upnp:album": reader.Read(); if (reader.Value != string.Empty) { dmapData.Album = reader.Value; Logger.Debug("Album value: {0}", dmapData.Album); } break; case "upnp:genre": reader.Read(); if (reader.Value != string.Empty) { genres.Add(reader.Value); Logger.Debug("Genres value: {0}", genres.Last()); } break; // missing: playlist // Associated Resources Properties case "upnp:albumArtURI": reader.Read(); if (reader.Value != string.Empty) { coverUrl = reader.Value; Logger.Debug("CoverURL value: {0}", coverUrl); } break; // missing: artistDiscographyURI, lyricsURI // missing: Storage Related Properties, General Description Properties, Recorded Object Related Properties, User Channel and EPG Related Properties // Radio Broadcast Properties, Video Broadcast Properties, Physical Tuner Status-related Properties, Bookmark Related Properties // Foreign Metadata Related Properties, Miscellaneous Properties, Object Tracking Properties, Content Protection Properties // Base Properties, Contributor Related Properties, Affiliation Related Properties, User Channel and EPG Related Properties // Video Broadcast Properties, ... to the end case "upnp:originalTrackNumber": reader.Read(); if (reader.Value != string.Empty) { int number; dmapData.OriginalTrackNumber = int.TryParse(reader.Value, out number) ? number : 0; Logger.Debug("OriginalTrackNumber value: {0}", dmapData.OriginalTrackNumber); } break; case "upnp:originalDiscNumber": reader.Read(); if (reader.Value != string.Empty) { int number; dmapData.OriginalDiscNumber = int.TryParse(reader.Value, out number) ? number : 0; Logger.Debug("OriginalDiscNumber value: {0}", dmapData.OriginalDiscNumber); } break; case "upnp:originalDiscCount": reader.Read(); if (reader.Value != string.Empty) { int number; dmapData.OriginalDiscCount = int.TryParse(reader.Value, out number) ? number : 0; Logger.Debug("OriginalDiscCount value: {0}", dmapData.OriginalDiscCount); } break; } } } /*reader.ReadToFollowing("dc:title"); * dmapData.Title = reader.ReadElementContentAsString(); * * reader.ReadToFollowing("upnp:artist"); * dmapData.Artists = new[] { reader.ReadElementContentAsString() }; * * reader.ReadToFollowing("upnp:albumArtURI"); * coverUrl = reader.ReadElementContentAsString();*/ } dmapData.Directors = directors.ToArray(); dmapData.Artists = artists.ToArray(); dmapData.Actors = actors.ToArray(); dmapData.Genres = genres.ToArray(); return(dmapData); }
public static void LoadMaps() { int start = System.Environment.TickCount; //GameMap DMD = new GameMap("gamemap.dat"); GameMap DMD = new GameMap("gamemap.ini"); foreach (DMap _Map in DMD.Maps) { if (Enum.IsDefined(typeof(Struct.Maps), (int)_Map.MapId)) { string Path = "maps\\" + _Map.MapFile; if (File.Exists(Path)) { if (!MainGS.Maps.ContainsKey((int)_Map.MapId)) { DmapData NewMap = new DmapData(Path); MainGS.Maps.Add((int)_Map.MapId, NewMap); Console.WriteLine("[GameServer] Loaded Dmap " + _Map.MapFile + "[" + _Map.MapId + "]"); } } } else { //Console.WriteLine("[GameServer] Did not load DMap: " + _Map.MapFile + "[" + _Map.MapId + "]"); @TODO: show error again, maybe if a debug switch is flagged. } } Console.WriteLine("[GameServer] Looked at: " + DMD.MapCount + " Maps, Loaded: " + MainGS.Maps.Count + " DMaps in " + (System.Environment.TickCount - start) + "MS"); }