Exemplo n.º 1
0
 public void SendRatingUpdate(QuerySong song, SongRating oldRating, SongRating newRating)
 {
     foreach (var obj in _pcqList)
     {
         obj.RatingUpdateReceiver(song, oldRating, newRating);
     }
 }
Exemplo n.º 2
0
 public void SendRatingUpdate(QuerySong song, SongRating oldRating, SongRating newRating)
 {
     foreach (var obj in _pcqList)
     {
         obj.RatingUpdateReceiver(song, oldRating, newRating);
     }
 }
Exemplo n.º 3
0
 private Track QuerySongToTrack(QuerySong song)
 {
     var track = new Track
     {
         TrackName = song.Title,
         AlbumName = song.Album,
         ArtistName = song.Artist,
     };
     return track;
 }
Exemplo n.º 4
0
 public void SongUpdateReceiver(QuerySong song)
 {
     //Nothing to do here
 }
Exemplo n.º 5
0
        public void RatingUpdateReceiver(QuerySong song, SongRating oldRating, SongRating newRating)
        {
            if (!IsEnabled || !_scrobbler.BaseScrobbler.HasSession) return;

            try
            {
                Log.O("LastFM, Rating: {0} - {1} - {2}", song.Artist, song.Title, newRating.ToString());
                Track track = null;

                //Get corrected track if there is one
                //Without getting the corrected track,
                //ratings will not work if there were corrections.
                if (song.Meta == null)
                {
                    track = QuerySongToTrack(song);
                }
                else
                    track = (Track)song.Meta;

                switch (newRating)
                {
                    case SongRating.love:
                        _scrobbler.UnBan(track);
                        _scrobbler.Love(track);
                        break;
                    case SongRating.ban:
                        _scrobbler.UnLove(track);
                        _scrobbler.Ban(track);
                        break;
                    case SongRating.none:
                        if(oldRating == SongRating.love)
                            _scrobbler.UnLove(track);
                        else if(oldRating == SongRating.ban)
                            _scrobbler.UnBan(track);
                        break;
                }

                if (_scrobbler.QueuedCount > 0) ProcessScrobbles();
            }
            catch (Exception ex)
            {
                Log.O("Last.FM Error!: " + ex.ToString());
            }
        }
Exemplo n.º 6
0
        public void ProgressUpdateReciever(QueryProgress progress)
        {
            if (!IsEnabled || !_scrobbler.BaseScrobbler.HasSession) return;

            try
            {
                if (progress.Progress.Percent < PercentNowPlaying && !_doneNowPlaying)
                {
                    _doneScrobble = false;
                    Log.O("LastFM, Now Playing: {0} - {1}", progress.Song.Artist, progress.Song.Title);
                    _currentSong = progress.Song;
                    _scrobbler.NowPlaying(QueryProgressToTrack(progress));
                    _doneNowPlaying = true;
                }

                //A track should only be scrobbled when the following conditions have been met:
                //The track must be longer than 30 seconds.
                //And the track has been played for at least half its duration,
                //or for 4 minutes (whichever occurs earlier).
                //See http://www.last.fm/api/scrobbling
                //This is enforced by LPFM so might as well enforce it here to avoid issues
                if (progress.Progress.TotalTime.TotalSeconds >= MinTrackLength &&
                    (progress.Progress.ElapsedTime.TotalSeconds >= SecondsBeforeScrobble || progress.Progress.Percent > PercentBeforeScrobble) &&
                    !_doneScrobble)
                {
                    _doneNowPlaying = false;
                    Log.O("LastFM, Scrobbling: {0} - {1}", progress.Song.Artist, progress.Song.Title);
                    _scrobbler.Scrobble(QueryProgressToTrack(progress));
                    _doneScrobble = true;
                }

                if (_scrobbler.QueuedCount > 0) ProcessScrobbles();
            }
            catch (Exception ex)
            {
                Log.O("Last.FM Error!: " + ex.ToString());
            }
        }
Exemplo n.º 7
0
 public void SongUpdateReceiver(QuerySong song)
 {
 }
Exemplo n.º 8
0
 public void RatingUpdateReceiver(QuerySong song, SongRating oldRating, SongRating newRating)
 {
 }