Beispiel #1
0
		public async Task<JukeBoxStatut> jukeboxControl(action_type action, string index = null, string offset = null, string id = null, string gain = null)
		{
			Dictionary<string, string> parameters = new Dictionary<string, string>();

			parameters.Add("action", action.ToString());
			if (!string.IsNullOrEmpty(index))
				parameters.Add("index", index);
			if (!string.IsNullOrEmpty(id))
				parameters.Add("id", id);
			if (!string.IsNullOrEmpty(gain))
				parameters.Add("gain", gain);
			
			Stream theStream = await this.MakeGenericRequest("jukeboxControl", parameters);
			

			StreamReader sr = new StreamReader(theStream);

			string result = sr.ReadToEnd();
			result = result.Replace(responseHead, "").Replace(responseFoot, "");
			XElement Xel = XElement.Parse(result);
			JukeBoxStatut jbs = new JukeBoxStatut();
			
			jbs.CurrentIndex = (string)Xel.Attribute("currentIndex");
			jbs.Playing = (string)Xel.Attribute("playing");
			jbs.gain = (string)Xel.Attribute("gain");
			jbs.position = (string)Xel.Attribute("position");
			jbs.Entry.AddRange((from nm in Xel.Elements("entry")
								select new Song 
								{
									Id = (string)nm.Attribute("id"),
									Name = (string)nm.Attribute("title"),
									Album = (string)nm.Attribute("album"),
									Artist = (string)nm.Attribute("artist"),
									Parent = (string)nm.Attribute("parent"),
									CoverArt = (string)nm.Attribute("coverArt"),
									Created = (string)nm.Attribute("created"),
									Duration = (string)nm.Attribute("duration"),
									BitRate = (string)nm.Attribute("bitRate"),
									Track = (string)nm.Attribute("track"),
									Year = (string)nm.Attribute("year"),
									Genre = (string)nm.Attribute("genre"),
									Size = (string)nm.Attribute("size"),
									Suffix = (string)nm.Attribute("suffix"),
									ContentType = (string)nm.Attribute("contentType"),
									AlbumId = (string)nm.Attribute("albumId"),
									ArtistId = (string)nm.Attribute("artistId")
								}).ToList());

			return jbs;
		}