Esempio n. 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();
         }
     }
 }
 /// <summary>
 /// Called to handle the command.
 /// Pass the request on to the PlaylistsController having first worked out the parent playlist
 /// If the playlist is a NowPlaying playlist then pass the request on to the NowPlayingController
 /// </summary>
 /// <param name="commandIdentity"></param>
 public override void HandleCommand(int commandIdentity)
 {
     if (selectedObjects.ParentPlaylist != null)
     {
         if (selectedObjects.ParentPlaylist.Name == Playlists.NowPlayingPlaylistName)
         {
             if (commandIdentity == Resource.Id.move_up)
             {
                 NowPlayingController.MoveItemsUp(selectedObjects.PlaylistItems);
             }
             else
             {
                 NowPlayingController.MoveItemsDown(selectedObjects.PlaylistItems);
             }
         }
         else
         {
             if (commandIdentity == Resource.Id.move_up)
             {
                 PlaylistsController.MoveItemsUp(selectedObjects.ParentPlaylist, selectedObjects.PlaylistItems);
             }
             else
             {
                 PlaylistsController.MoveItemsDown(selectedObjects.ParentPlaylist, selectedObjects.PlaylistItems);
             }
         }
     }
 }
Esempio n. 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();
        }
Esempio n. 4
0
 /// <summary>
 /// Configure all the controllers
 /// </summary>
 private void ConfigureControllers()
 {
     AlbumsController.GetControllerData();
     ArtistsController.GetControllerData();
     PlaylistsController.GetControllerData();
     LibraryNameDisplayController.GetControllerData();
     FilterManagementController.GetControllerData();
     PlaybackSelectionController.GetControllerData();
     AutoplayController.GetControllerData();
     PlaybackModeController.GetControllerData();
     PlaybackManagementController.GetControllerData();
     MediaControllerController.GetControllerData();
     MediaNotificationController.GetControllerData();
     NowPlayingController.GetControllerData();
 }
Esempio n. 5
0
 /// <summary>
 /// Called when a song has been selected by the user
 /// Pass this change to the controller
 /// </summary>
 /// <param name="itemNo"></param>
 public void SongSelected(int itemNo) => NowPlayingController.UserSongSelected(itemNo);