Ejemplo n.º 1
0
        /// <summary>
        /// Attach User Currently Playing Item Commands
        /// </summary>
        /// <param name="client">Spotify Sdk Client</param>
        /// <param name="response">Currently Playing Item Response</param>
        /// <param name="overrideIsAttach">Override Is Attach?</param>
        public static void AttachUserCurrentlyPlayingItemCommands(
            this ISpotifySdkClient client,
            CurrentlyPlayingItemResponse response,
            bool?overrideIsAttach = null)
        {
            var isAttach = GetConfig(client.Config.IsAttachGetUserCurrentlyPlayingItemCommands, overrideIsAttach);

            if (isAttach && response != null)
            {
                switch (response.PlayItemType)
                {
                case PlayItemType.Track:
                    // Track Commands
                    client.AttachGetTrackCommands(response.Track, isAttach);
                    break;

                case PlayItemType.Episode:
                    // Episode Commands
                    client.AttachGetEpisodeCommands(response.Episode, isAttach);
                    break;
                }
                // Pause a User's Playback
                response.UserPlaybackPauseCommand = new GenericCommand <CurrentlyPlayingResponse>(
                    client.UserPlaybackPauseHandler);
                // Resume a User's Playback
                response.UserPlaybackResumeCommand = new GenericCommand <CurrentlyPlayingResponse>(
                    client.UserPlaybackResumeHandler);
                // Skip User’s Playback To Next Track
                response.UserPlaybackNextCommand = new GenericCommand <CurrentlyPlayingResponse>(
                    client.UserPlaybackNextHandler);
                // Skip User’s Playback To Previous Track
                response.UserPlaybackPreviousCommand = new GenericCommand <CurrentlyPlayingResponse>(
                    client.UserPlaybackPreviousHandler);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attach Get Playlist Item Commands
        /// </summary>
        /// <param name="client">Spotify Sdk Client</param>
        /// <param name="response">Playlist Item Response</param>
        /// <param name="isAttach">Is Attach?</param>
        public static void AttachGetPlaylistItemCommands(
            this ISpotifySdkClient client,
            PlaylistItemResponse response,
            bool isAttach)
        {
            if (response != null)
            {
                switch (response.PlayItemType)
                {
                case PlayItemType.Track:
                    // Track Commands
                    client.AttachGetTrackCommands(response.Track, isAttach);
                    break;

                case PlayItemType.Episode:
                    // Episode Commands
                    client.AttachGetEpisodeCommands(response.Episode, isAttach);
                    break;
                }
                // Remove Playlist Item Command
                if (client.CommandActions.RemovePlaylistItem != null)
                {
                    response.RemovePlaylistItemCommand = new GenericCommand <PlaylistItemResponse>(
                        client.CommandActions.RemovePlaylistItem);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Attach Get Album Commands
        /// </summary>
        /// <param name="client">Spotify Sdk Client</param>
        /// <param name="response">Album Response</param>
        /// <param name="overrideIsAttach">Override Is Attach?</param>
        public static void AttachGetAlbumCommands(
            this ISpotifySdkClient client,
            AlbumResponse response,
            bool?overrideIsAttach = null)
        {
            var isAttach = GetConfig(client.Config.IsAttachGetAlbumCommands, overrideIsAttach);

            if (isAttach && response != null)
            {
                // Album Command
                if (client.CommandActions.Album != null)
                {
                    response.Command = new GenericCommand <AlbumResponse>(
                        client.CommandActions.Album);
                }
                // Add User Playback Command
                response.AddUserPlaybackCommand = new GenericCommand <IPlaybackResponse>(
                    client.AddUserPlaybackHandler);
                // Artist Commands
                if (response?.Artists != null)
                {
                    response.Artists.ForEach(item => client.AttachGetArtistCommands(item, isAttach));
                }
                if (response?.Artist != null)
                {
                    client.AttachGetArtistCommands(response?.Artist, isAttach);
                }
                // Track Commands
                if (response?.Tracks?.Items != null)
                {
                    response.Tracks.Items.ForEach(item => client.AttachGetTrackCommands(item, isAttach));
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Attach List Tracks Commands
 /// </summary>
 /// <param name="client">Spotify Sdk Client</param>
 /// <param name="responses">Track Responses</param>
 public static void AttachListTracksCommands(
     this ISpotifySdkClient client,
     NavigationResponse <TrackResponse> responses)
 {
     if (client.Config.IsAttachListTracksCommands && responses?.Items != null)
     {
         responses.Items.ForEach(item => client.AttachGetTrackCommands(item, client.Config.IsAttachListTracksCommands));
     }
 }