Esempio n. 1
0
		/// <summary>
		/// Queues a <see cref="PlayedTrack"/> for scrobbling, then
		/// scrobbles it on another thread. Or at least tries to.
		/// The <see cref="PlayedTrack"/> info is cached locally firt, so
		/// there's no fear of losing precious scrobbles.
		/// </summary>
		/// <param name="track">
		/// A <see cref="PlayedTrack"/>
		/// </param>
		public void Queue(Entry track)
		{
			// Append the scrobble line to the file
			StreamWriter writer = new StreamWriter(CacheDir + cacheFileName, true, Encoding.Unicode);
			writer.WriteLine(track.getParameters().serialize());
			writer.Flush();
			writer.Close();
			
			// Try and submit the whole file now, in another thread.
			Submit();
		}
Esempio n. 2
0
		/// <summary>
		/// Public scrobble function. Scrobbles a PlayedTrack object.
		/// </summary>
		/// <param name="track">
		/// A <see cref="PlayedTrack"/>
		/// </param>
		public void Scrobble(Entry track)
		{
			RequestParameters np = new RequestParameters();
			RequestParameters p = track.getParameters();
			
			foreach(string key in p.Keys)
				np[key + "[0]"] = p[key];
			
			// This scrobbles the collection of parameters no matter what they belong to.
			this.Scrobble(np);
		}