Ejemplo n.º 1
0
        public LinkLibraryInfo RunAfterPlay(string title,
                                            string album,
                                            string artist,
                                            int trackNo,
                                            int duration,
                                            bool isLinkLibraryEnable
                                            )
        {
            LinkLibraryInfo lastFmInfo = new LinkLibraryInfo();

            if (_scrobbler == null)
            {
                return(lastFmInfo);
            }

            CurrentTrack = new Track
            {
                TrackName   = title,
                AlbumName   = album,
                ArtistName  = artist,
                TrackNumber = trackNo,
                Duration    = new TimeSpan(0, 0, 0, duration)
            };
            CurrentTrack.WhenStartedPlaying = DateTime.Now;

            _scrobbler.NowPlaying(CurrentTrack);

            if (isLinkLibraryEnable)
            {
                // トラック情報取得
                var trackInfo = _scrobbler.GetTrackInfo(CurrentTrack, false);

                if (trackInfo != null)
                {
                    lastFmInfo.Listener     = trackInfo.listeners;
                    lastFmInfo.AllPlaycount = trackInfo.playcount;
                    lastFmInfo.Url          = trackInfo.url;
                }

                trackInfo = _scrobbler.GetLibraryTrack(CurrentTrack, true);

                if (trackInfo != null)
                {
                    lastFmInfo.UserPlaycount = trackInfo.playcount;
                }
                else
                {
                    lastFmInfo.UserPlaycount = -1;
                }

                lastFmInfo.SimilarArtists = _scrobbler.GetSimilarArtist(CurrentTrack);
            }

            return(lastFmInfo);
        }