Exposing track.isnowplaying property

Probably more reliable than testing if datetime is null
This commit is contained in:
Rikki Tooley 2013-07-24 22:28:42 +01:00
parent f342bd0757
commit ab9f873342

View File

@ -29,6 +29,7 @@ public class Track : ILastFmObject
public DateTime? TimePlayed { get; set; }
public bool? IsLoved { get; set; }
public bool? IsNowPlaying { get; set; }
#endregion
@ -85,6 +86,12 @@ internal static Track ParseJToken(JToken token)
t.IsLoved = Convert.ToBoolean(lovedToken.Value<int>());
}
var attrToken = token.SelectToken("@attr");
if (attrToken != null && attrToken.HasValues)
{
t.IsNowPlaying = attrToken.Value<bool>("nowplaying");
}
// api returns milliseconds when track.getInfo is called directly
var secs = token.Value<double>("duration");
if (Math.Abs(secs - default(double)) > double.Epsilon)