예제 #1
0
        /// <summary>
        /// Called when the connection state of the session is updated.
        /// If the session is logged in, all present playlists are added and
        /// listeners are attached to the playlist collection list.
        /// </summary>
        async void ConnectionstateUpdated(Session sender, SessionEventArgs e) {

            switch (sender.ConnectionState) {

                // Logged out
                case ConnectionState.LoggedOut:

                    if (_previousConnectionState == ConnectionState.LoggedIn) {
                        
                        // Remove all playlists
                        MasterPlaylist.Instance.Dispose();
                        var playlists = Touchee.Medium.Local.Containers.OfType<Spotify.Media.Playlist>();
                        lock (playlists) {
                            foreach (var playlist in playlists)
                                playlist.Dispose();
                        }
                    }

                    break;

                // Offline state (when logged in, but not completely yet)
                case ConnectionState.Offline:
                    break;

                // User has logged in
                case ConnectionState.LoggedIn:

                    // Save the master playlist
                    MasterPlaylist.Instance.Save();

                    // Wait for the playlist container
                    await _session.PlaylistContainer;

                    // Track initial set of playlists and starred list
                    Log("PL: " + _session.PlaylistContainer.Playlists.Count);
                    this.AddPlaylists(_session.PlaylistContainer.Playlists);
                    this.AddPlaylist(_session.Starred);

                    // Add event handler for removal/adding of playlists
                    _session.PlaylistContainer.Playlists.CollectionChanged += Playlists_CollectionChanged;

                    break;
                    
                // User has been disconnected after having been logged in
                case ConnectionState.Disconnected:
                    break;

                // No clue
                case ConnectionState.Undefined:
                    break;

            }

            _previousConnectionState = sender.ConnectionState;

        }
예제 #2
0
        /// <summary>
        /// Called when the Session connection status is updated
        /// </summary>
        async void ConnectionstateUpdated(Session sender, SessionEventArgs e) {
            Log("Spotify: Connection state: " + sender.ConnectionState.ToString());
            this.OnStateUpdated();

            switch (sender.ConnectionState) {
                
                // Logged out
                case ConnectionState.LoggedOut:
                    break;

                // Offline state (when logged in, but not completely yet)
                case ConnectionState.Offline:
                    break;

                // User has logged in
                case ConnectionState.LoggedIn:
                    break;

                // User has been disconnected after having been logged in
                case ConnectionState.Disconnected:
                    break;

                // No clue
                case ConnectionState.Undefined:
                    throw new NotImplementedException();

            }

        }
예제 #3
0
 /// <summary>
 /// Called when the credentials blob has been updated from the Spotify session.
 /// Stores the username and these credentials into the Spotify plugin config.
 /// </summary>
 void Session_CredentialsBlobUpdated(Session sender, SessionEventArgs e) {
     Plugin.Config.Set("username", sender.UserName);
     Plugin.Config.Set("credentials", e.Message);
     Plugin.Config.Save();
 }
예제 #4
0
		static void HandleOnPlaylistContainerLoaded(Session sender, SessionEventArgs e)
		{
			Console.WriteLine("PlaylistContainer loaded, {0} lists", sender.PlaylistContainer.CurrentLists.Length);

            // Here you attach event handlers to PlaylistContainer and all the current lists in it
		}	
예제 #5
0
 void HandleOnLoginComplete(Session sender, SessionEventArgs e)
 {
     #if DEBUG
     if (Log.IsDebugEnabled) Log.Debug("HandleOnLoginComplete");
     #endif
     try
     {
     #if DEBUG
         if (Log.IsDebugEnabled) Log.Debug("Login result: " + e.Status);
     #endif
         _loginOk = Session.ConnectionState == sp_connectionstate.LOGGED_IN;
         _loggedIn.Set();
     }
     catch (Exception ex)
     {
     #if DEBUG
         if (Log.IsErrorEnabled)
             Log.Error("Exception", ex);
     #endif
     }
 }
예제 #6
0
 void HandleOnEndOfTrack(Session sender, SessionEventArgs e)
 {
     #if DEBUG
     if (Log.IsDebugEnabled)
         Log.Debug("End of music delivery.");
     #endif
     try
     {
         LameEncoder.Close();
         LameEncoder = null;
         _playbackDone.Set();
     }
     catch (Exception ex)
     {
     #if DEBUG
         if (Log.IsErrorEnabled)
             Log.Error("Exception", ex);
     #endif
     }
 }
예제 #7
0
 static void HandleOnConnectionError(Session sender, SessionEventArgs e)
 {
     #if DEBUG
     if (Log.IsErrorEnabled)
         Log.Error("Connection error: " + e.Status);
     #endif
 }
예제 #8
0
        void SpotifySession_OnEndOfTrack(Session sender, SessionEventArgs e)
        {
            //Console.WriteLine("End of music delivery. Flushing player buffer...");
            Thread.Sleep(1500); // Samples left in player buffer. Player lags 500 ms

            playbackDone.Set();

            try
            {

                NextTrack();
            }
            catch
            {

            }
            //	Console.WriteLine("Playback complete");
        }
예제 #9
0
		static void HandleOnConnectionError(Session sender, SessionEventArgs e)
		{
			Console.WriteLine("Connection error: " + e.Status);
		}
예제 #10
0
		static void HandleOnLoggedOut(Session sender, SessionEventArgs e)
		{	
			playbackDone.Set();
			loggedOut.Set();
		}
예제 #11
0
		static void HandleOnLogMessage(Session sender, SessionEventArgs e)
		{
			Console.WriteLine("Log: " + e.Message);
		}		
예제 #12
0
		static void HandleOnMessageToUser(Session sender, SessionEventArgs e)
		{			
			Console.WriteLine("Message: " + e.Message);
		}
예제 #13
0
		static void HandleOnPlayTokenLost(Session sender, SessionEventArgs e)
		{
			Console.Out.WriteLine("Play token lost");
			playbackDone.Set();
		}
예제 #14
0
		static void HandleOnEndOfTrack(Session sender, SessionEventArgs e)
		{
			Console.WriteLine("End of music delivery. Flushing player buffer...");
			Thread.Sleep(510); // Samples left in player buffer. Player lags 500 ms
			player.Stop();
			player = null;
			Console.WriteLine("Playback complete");
			playbackDone.Set();
		}
예제 #15
0
        void SpotifySession_OnPlaylistContainerLoaded(Session sender, SessionEventArgs e)
        {
            foreach(Spotify.Playlist PlsList in SpotifySession.PlaylistContainer.CurrentLists)
            {
                //toBeAdded.Enqueue(PlsList);

            }
        }
예제 #16
0
 void SpotifySession_OnConnectionError(Session sender, SessionEventArgs e)
 {
 }
예제 #17
0
 /// <summary>
 /// Called when a connection error occurs
 /// </summary>
 void ConnectionError(Session sender, SessionEventArgs e)
 {
     Log("Spotify: Connection Error: " + e.Error.ToString(), Logger.LogLevel.Error);
 }
예제 #18
0
        void SpotifySession_OnPlaylistContainerLoaded(Session sender, SessionEventArgs e)
        {
            if (playlists == null)
            {
                playlists = new List<MediaChrome.Views.Playlist>();
            }
                foreach (Spotify.Playlist _Playlist in SpotifySession.PlaylistContainer.CurrentLists)
                {
                    MediaChrome.Views.Playlist D = new MediaChrome.Views.Playlist(this, _Playlist.Name,_Playlist.LinkString, Host);
                    D.ID = _Playlist.LinkString;
                    D.Title = _Playlist.Name;

                    playlists.Add(D);
                }
                playlistLoaded = true;
        }
예제 #19
0
 /// <summary>
 /// Called when the credentials blob has been updated from the Spotify session.
 /// Stores the username and these credentials into the Spotify plugin config.
 /// </summary>
 void Session_CredentialsBlobUpdated(Session sender, SessionEventArgs e)
 {
     Plugin.Config.Set("username", sender.UserName);
     Plugin.Config.Set("credentials", e.Message);
     Plugin.Config.Save();
 }
예제 #20
0
 static void HandleOnMessageToUser(Session sender, SessionEventArgs e)
 {
     #if DEBUG
     if (Log.IsInfoEnabled)
         Log.Info("Spotify says: " + e.Message);
     #endif
 }
예제 #21
0
        void Program_SpotifySession_OnLoginComplete(Session sender, SessionEventArgs e)
        {
            if(e.Status == sp_error.OK)
            {
                this.DialogResult= DialogResult.OK;
                //this.Close();

            }
            else
            {
                //label6.Text = e.Status.ToString();
                panel1.Show();
            }
        }
예제 #22
0
 void HandleOnLoggedOut(Session sender, SessionEventArgs e)
 {
     #if DEBUG
     if (Log.IsDebugEnabled) Log.Debug("HandleOnLoggedOut");
     #endif
     try
     {
         _playbackDone.Set();
         _loggedOut.Set();
     }
     catch (Exception ex)
     {
     #if DEBUG
         if (Log.IsErrorEnabled)
             Log.Error("Exception", ex);
     #endif
     }
 }
예제 #23
0
 /// <summary>
 /// Called when a connection error occurs
 /// </summary>
 void ConnectionError(Session sender, SessionEventArgs e) {
     Log("Spotify: Connection Error: " + e.Error.ToString(), Logger.LogLevel.Error);
 }
예제 #24
0
 void HandleOnPlayTokenLost(Session sender, SessionEventArgs e)
 {
     #if DEBUG
     if (Log.IsWarnEnabled) Log.Warn("Play token lost");
     #endif
     _playbackDone.Set();
 }
예제 #25
0
		// Event callbacks
		
		static void HandleOnLoginComplete(Session sender, SessionEventArgs e)
		{
			Console.WriteLine("Login result: " + e.Status);			
			Console.WriteLine("Searching for 'green day idiot'... ");
			
			
			// RequestId can be whatever. It's never used internally.
			// If several searches are active at the same time, it can be used
			// too tell them apart.
			sender.Search("green day idiot", 0, 500, 0, 500, 0, 500, null);
		}