Beispiel #1
0
 /// <summary>
 /// Called to handle the command.
 /// Determine the subject of this, either the Now Playing playlist or a user playlist
 /// </summary>
 /// <param name="_"></param>
 public override void HandleCommand(int _)
 {
     // If this is a Now Playing command then the parent of the first selected song will have the NowPlayingPlaylistName
     if ((selectedObjects.ParentPlaylist != null) && (selectedObjects.ParentPlaylist.Name == Playlists.NowPlayingPlaylistName))
     {
         // Process this Now Playing command
         NowPlayingController.DeleteNowPlayingItems(selectedObjects.PlaylistItems);
         commandCallback.PerformAction();
     }
     else
     {
         if (selectedObjects.PlaylistItems.Count > 0)
         {
             if (selectedObjects.Playlists.Count == 1)
             {
                 // Deletion of songs and playlist - confirm first
                 ConfirmationDialogFragment.ShowFragment(CommandRouter.Manager, PlaylistDeleteSelected, "Do you want to delete the Playlist?");
             }
             else
             {
                 // Deletion of items from a playlist
                 PlaylistsController.DeletePlaylistItems(selectedObjects.ParentPlaylist, selectedObjects.PlaylistItems);
                 commandCallback.PerformAction();
             }
         }
         else if (selectedObjects.Playlists.Count == 1)
         {
             // Deletion of a playlist with no songs
             PlaylistsController.DeletePlaylist(selectedObjects.Playlists[0]);
             commandCallback.PerformAction();
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Duplciate the next playlist in the list
        /// </summary>
        private void DuplicateNextPlaylist()
        {
            if (++playlistIndex < playlistsBeingDuplicated.Count)
            {
                Playlist nextPlaylist = playlistsBeingDuplicated[playlistIndex];

                // If the playlist already exists in other libraries then prompt for deletion
                if (PlaylistsController.CheckForOtherPlaylists(nextPlaylist.Name, ConnectionDetailsModel.LibraryId) == true)
                {
                    ConfirmationDialogFragment.ShowFragment(CommandRouter.Manager, DuplicationConfirmed,
                                                            $"Playlist [{nextPlaylist.Name}] already exists in other libraries. Are you sure you want to duplicate it?");
                }
                else
                {
                    // Duplicate the playlist in the other libraries
                    PlaylistsController.DuplicatePlaylist(nextPlaylist);

                    DuplicateNextPlaylist();
                }
            }
            else
            {
                playlistsBeingDuplicated = null;
                playlistIndex            = -1;

                commandCallback.PerformAction();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Called to handle the command.
        /// </summary>
        /// <param name="commandIdentity"></param>
        public override void HandleCommand(int commandIdentity)
        {
            // If PlaylistItems are selected then get the songs from them
            if (selectedObjects.PlaylistItems.Count > 0)
            {
                // If all of the PlaylistItems are from a single Playlist, and all that Playlist's items have been selected then
                // check if playback of the playlist is in progress, i.e. not at the start and not at the end. If so, prompt
                // the user about progress and check if playback is to be resumed
                if ((selectedObjects.Playlists.Count == 1) && (selectedObjects.PlaylistItems.Count == selectedObjects.Playlists[0].PlaylistItems.Count) &&
                    (selectedObjects.ParentPlaylist.InProgress == true) && (Playback.ShufflePlayOn == false))
                {
                    // Keep a local reference to the parent playlist to be accessed by the confirmation callback
                    Playlist parentPlaylist = selectedObjects.ParentPlaylist;

                    Song   currentSong = parentPlaylist.InProgressSong;
                    string artistName  = (parentPlaylist as AlbumPlaylist)?.InProgressAlbum.ArtistName ?? currentSong.Artist.Name;

                    ConfirmationDialogFragment.ShowFragment(CommandRouter.Manager,
                                                            ( bool resume ) =>
                    {
                        NowPlayingController.AddPlaylistToNowPlayingList(parentPlaylist, commandIdentity == Resource.Id.play_now, resume);
                    },
                                                            string.Format("This playlist is currently playing '{0}' by '{1}'. Do you want to continue or start from the beginning?", currentSong.Title,
                                                                          artistName),
                                                            "Continue", "Start");
                }
                else
                {
                    // This includes both SongPlaylistItem and AlbumPlaylistItem entries.
                    List <Song> selectedSongs = new List <Song>();
                    foreach (PlaylistItem basePlaylistItem in selectedObjects.PlaylistItems)
                    {
                        if (basePlaylistItem is AlbumPlaylistItem albumPlaylistItem)
                        {
                            selectedSongs.AddRange(albumPlaylistItem.Album.Songs);
                        }
                        else
                        {
                            selectedSongs.Add((( SongPlaylistItem )basePlaylistItem).Song);
                        }
                    }

                    NowPlayingController.AddSongsToNowPlayingList(selectedSongs, (commandIdentity == Resource.Id.play_now));
                }
            }
            // Otherwise just use the selected songs themselves
            else
            {
                NowPlayingController.AddSongsToNowPlayingList(selectedObjects.Songs, (commandIdentity == Resource.Id.play_now));
            }

            commandCallback.PerformAction();
        }
Beispiel #4
0
 /// <summary>
 /// Called when a library has been selected.
 /// Confirm the clearance
 /// </summary>
 /// <param name="selectedLibrary"></param>
 public void LibrarySelected(Library selectedLibrary)
 {
     libraryToClear = selectedLibrary;
     ConfirmationDialogFragment.ShowFragment(CommandRouter.Manager, ClearConfirmed,
                                             string.Format("Are you sure you want to clear the {0} library", libraryToClear.Name));
 }