/// <summary> /// Let Last.fm know when a user has started listening to a track /// </summary> private async void PlaybackStart(object sender, PlaybackProgressEventArgs e) { //We only care about audio if (!(e.Item is Audio)) { return; } var user = e.Users.FirstOrDefault(); if (user == null) { Plugin.Logger.Debug("No user"); return; } var lastfmUser = UserHelpers.GetUser(user); if (lastfmUser == null) { Plugin.Logger.Debug("Could not find last.fm user"); return; } //User doesn't want to scrobble if (!lastfmUser.Scrobble) { Plugin.Logger.Debug("{0} ({1}) does not want to scrobble", user.Name, lastfmUser.Username); return; } if (string.IsNullOrWhiteSpace(lastfmUser.SessionKey)) { Plugin.Logger.Info("No session key present, aborting"); return; } var item = (Audio)e.Item; await _lastfmApi.TrackNowPlaying(item, lastfmUser); }