Example #1
0
 public void Playing(ZuneTrack track)
 {
     _currentTrack = track;
     _timeStarted = DateTime.Now;
     _timer.Start();
     TrackHasStartedPlaying.Invoke(track);
 }
Example #2
0
        public ZuneManager(Scrobbler scrobbler)
        {
            _currentTrack = new ZuneTrack();
            _trackWatcher = new TrackWatcher();
            var scrobbleManager = new ScrobbleManager(scrobbler);

            _trackWatcher.TrackIsReadyToBeScrobbled += scrobbleManager.Scrobble;
            _trackWatcher.TrackHasStartedPlaying += scrobbleManager.SubmitNowPlaying;
        }
Example #3
0
 public void Stopped(ZuneTrack track)
 {
     _timer.Stop();
 }
Example #4
0
 public void Paused(ZuneTrack track)
 {
     _timer.Stop();
 }
Example #5
0
        public static ZuneTrack GetFromCurrentTrack()
        {
            var t = TransportControls.Instance.CurrentTrack;

            if (t.MediaType == MediaType.Podcast || t.MediaType == MediaType.PodcastEpisode)
            {
                return null;
            }

            if (TransportControls.Instance.CurrentTrack is LibraryPlaybackTrack)
            {
                var track = (LibraryPlaybackTrack) TransportControls.Instance.CurrentTrack;

                if (track.IsVideo)
                    return null;

                AlbumMetadata album = FindAlbumInfoHelper.GetAlbumMetadata(track.AlbumLibraryId);

                var s = new ZuneTrack(track.Title, album.AlbumArtist, album.AlbumTitle);
                s.Length = TransportControls.Instance.CurrentTrackDuration;
                s.coverUrl = album.CoverUrl;

                return s;
            }
            else if (TransportControls.Instance.CurrentTrack is MarketplacePlaybackTrack)
            {
                var track = (MarketplacePlaybackTrack) TransportControls.Instance.CurrentTrack;

                var s = new ZuneTrack(track.Title, track.Artist, track.Album);
                s.Length = TransportControls.Instance.CurrentTrackDuration;

                return s;
            }
            else if (TransportControls.Instance.CurrentTrack is StreamingPlaybackTrack)
            {
            }
            else if (TransportControls.Instance.CurrentTrack is StreamingRadioPlaybackTrack)
            {
            }
            else if (TransportControls.Instance.CurrentTrack is VideoPlaybackTrack)
            {
            }

            return null;
        }
Example #6
0
        public void SubmitNowPlaying(ZuneTrack track)
        {
            if (CheckForSession())
            {
                try
                {
                    var scrobTrack = new Track
                    {
                        TrackName = track.Title,
                        ArtistName = track.Artist,
                        Duration = TimeSpan.FromSeconds(track.Length)
                    };

                    var resp = _scrobbler.NowPlaying(scrobTrack);
                    Debug.WriteLine("successfully sent now playing: " + resp.Track.TrackName);
                }
                catch (LastFmApiException exception)
                {
                    if (exception.ErrorCode == 9) // re-authenticate
                    {
                        Reauthenticate();
                        return;
                    }

                    //log unsuccessfull now playing
                    Logger.Send(LogLevel.Error, "Submit now playing was unsuccessful", exception);
                }
            }
        }