Пример #1
0
        public async Task<bool> Scrobble(HistoryEntry item, TimeSpan position)
        {
            var result =
                await
                    _service.ScrobbleAsync(item.Song.Name, item.Song.Artist.Name,
                        item.DatePlayed.ToUniversalTime(), item.Song.Duration);

            return result == LastResponseStatus.Successful || result == LastResponseStatus.Failure;
        }
Пример #2
0
        private async void OnTrackChanged()
        {
            var played = DateTime.Now;
            var historyItem = new HistoryEntry
            {
                DatePlayed = played,
                SongId = CurrentTrack.SongId
            };

            using (var historySql = CreateHistorySqlService())
            {
                await historySql.InsertAsync(historyItem);
            }

            if (CurrentTrack.Song.Duration.Ticks != _mediaPlayer.NaturalDuration.Ticks)
            {
                CurrentTrack.Song.Duration = _mediaPlayer.NaturalDuration;

                using (var sql = CreateCollectionSqlService())
                {
                    await sql.UpdateItemAsync(CurrentTrack.Song);
                }
            }

            if (_scrobbler.IsScrobblingEnabled())
                await _scrobbler.UpdateNowPlaying(CurrentTrack);
        }