Exemplo n.º 1
0
        public static void ScrobbleNowPlaying()
        {
            if (!Settings.Default.Scrobble)
            {
                return;
            }
            Thread thr = new Thread(() =>
            {
                var doProcessScrobbles          = new ProcessScrobblesDelegate(ProcessScrobbles);
                CurrentTrack                    = new Track();
                CurrentTrack.WhenStartedPlaying = DateTime.Now;
                CurrentTrack.TrackName          = CoreMain.CurrentTrack.Title;
                CurrentTrack.AlbumName          = CoreMain.CurrentTrack.Album;
                CurrentTrack.ArtistName         = CoreMain.CurrentTrack.Artist;
                CurrentTrack.TrackNumber        = (int)CoreMain.CurrentTrack.TrackPosition;
                CurrentTrack.Duration           = new TimeSpan(0, 0, 0, (int)CoreMain.CurrentTrack.Duration);
                // we are using the Queuing scrobbler here so that we don't block the form while the scrobble request is being sent
                // to the Last.fm web service. The request will be sent when the Process() method is invoked
                if (_scrobbler != null)
                {
                    _scrobbler.NowPlaying(CurrentTrack);

                    // Begin invoke with no callback fires and forgets the scrobbler process. Processing runs asynchronously while
                    //  the form thread continues
                    _scrobbler.Process();
                }
            });

            thr.Start();
        }
Exemplo n.º 2
0
        public PandoraSharpScrobbler(string lastFMApiKey, string lastFMApiSecret, string lastFMSessionKey = null)
        {
            APIKey = lastFMApiKey;
            APISecret = lastFMApiSecret;
            SessionKey = lastFMSessionKey;
            AuthURL = string.Empty;

            InitScrobblers();

            _processScrobbleDelegate = new ProcessScrobblesDelegate(DoScrobbles);
        }
Exemplo n.º 3
0
        public PandoraSharpScrobbler(string lastFMApiKey, string lastFMApiSecret, string lastFMSessionKey = null)
        {
            APIKey     = lastFMApiKey;
            APISecret  = lastFMApiSecret;
            SessionKey = lastFMSessionKey;
            AuthURL    = string.Empty;

            InitScrobblers();

            _processScrobbleDelegate = new ProcessScrobblesDelegate(DoScrobbles);
        }
Exemplo n.º 4
0
        public void Scrobble()
        {
            if (_scrobbler != null)
            {
                var doProcessScrobbles = new ProcessScrobblesDelegate(ProcessScrobbles);

                // Scrobble the track that just finished
                _scrobbler.Scrobble(currentTrack);
                doProcessScrobbles.BeginInvoke(null, null);
            }
        }
Exemplo n.º 5
0
        public void NowPlaying(PlaylistItem hitbaseTrack)
        {
            if (_scrobbler != null)
            {
                var doProcessScrobbles = new ProcessScrobblesDelegate(ProcessScrobbles);

                currentTrack = HitbaseTrackToLastFmTrack(hitbaseTrack);

                currentTrack.WhenStartedPlaying = DateTime.Now;
                _scrobbler.NowPlaying(currentTrack);
                // we are using the Queuing scrobbler here so that we don't block the form while the scrobble request is being sent
                //  to the Last.fm web service. The request will be sent when the Process() method is invoked
                // Begin invoke with no callback fires and forgets the scrobbler process. Processing runs asynchronously while
                //  the form thread continues
                doProcessScrobbles.BeginInvoke(null, null);
            }
        }
Exemplo n.º 6
0
        public static void ScrobbleTrack(Track tr)
        {
            if (!Settings.Default.Scrobble)
            {
                return;
            }
            Thread thr = new Thread(() =>
            {
                var doProcessScrobbles = new ProcessScrobblesDelegate(ProcessScrobbles);
                // Scrobble the track that just finished
                if (_scrobbler != null)
                {
                    _scrobbler.Scrobble(tr);
                    _scrobbler.Process();
                }
            });

            thr.Start();
        }
        private void WindowsMediaPlayer_PlayStateChange(object sender, _WMPOCXEvents_PlayStateChangeEvent e)
        {
            try
            {
                var doProcessScrobbles = new ProcessScrobblesDelegate(ProcessScrobbles);

                switch (WindowsMediaPlayer.playState)
                {
                    case WMPPlayState.wmppsPlaying:
                        // Convert the media player media info to a Track. Store the track in a property so that is can be scrobbled 
                        //  when media ended. At that time WindowsMediaPlayer.currentMedia will be null. This is not fool-proof and
                        //  is demo code only
                        CurrentTrack = WmpMediaToTrack(WindowsMediaPlayer.currentMedia);
                        CurrentTrack.WhenStartedPlaying = DateTime.Now;

                        // we are using the Queuing scrobbler here so that we don't block the form while the scrobble request is being sent
                        //  to the Last.fm web service. The request will be sent when the Process() method is invoked
                        _scrobbler.NowPlaying(CurrentTrack);
                        // Begin invoke with no callback fires and forgets the scrobbler process. Processing runs asynchronously while 
                        //  the form thread continues
                        doProcessScrobbles.BeginInvoke(null, null);
                        break;

                    case WMPPlayState.wmppsMediaEnded:
                        // Scrobble the track that just finished
                        _scrobbler.Scrobble(CurrentTrack);
                        doProcessScrobbles.BeginInvoke(null, null);
                        break;
                }

            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }