Esempio n. 1
0
        private void LocalFoldersTreeView_ItemInvoked(TreeView sender, TreeViewItemInvokedEventArgs args)
        {
            var node = args.InvokedItem as TreeViewNode;

            if (node.Content is FolderTree)
            {
                node.IsExpanded = !node.IsExpanded;
            }
            else if (node.Content is Music music)
            {
                MediaHelper.SetMusicAndPlay((node.Parent.Content as FolderTree).Files, music);
            }
        }
Esempio n. 2
0
        protected override async void OnFileActivated(FileActivatedEventArgs args)
        {
            base.OnFileActivated(args);
            Music music = await Music.GetMusicAsync(args.Files[0].Path);

            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                MediaHelper.SetMusicAndPlay(music);
            }
            else
            {
                OnLaunched(null, music);
            }
        }
Esempio n. 3
0
 void IMultiSelectListener.Play(MultiSelectCommandBar commandBar)
 {
     MediaHelper.SetMusicAndPlay(GetSelectItems());
 }
Esempio n. 4
0
 void IMultiSelectListener.Play(MultiSelectCommandBar commandBar)
 {
     MediaHelper.SetMusicAndPlay(SelectedSongs);
 }
Esempio n. 5
0
        public static MenuFlyout GetShuffleMenu(int limit = 100)
        {
            var flyout     = new MenuFlyout();
            var nowPlaying = new MenuFlyoutItem()
            {
                Text = Helper.Localize("NowPlaying")
            };

            nowPlaying.Click += (sender, args) =>
            {
                MediaHelper.ShuffleAndPlay();
            };
            flyout.Items.Add(nowPlaying);
            flyout.Items.Add(new MenuFlyoutSeparator());
            var musicLibrary = new MenuFlyoutItem()
            {
                Text = Helper.Localize("Music Library")
            };

            musicLibrary.Click += (sender, args) =>
            {
                MediaHelper.SetPlaylistAndPlay(MusicLibraryPage.AllSongs.RandItems(limit));
            };
            flyout.Items.Add(musicLibrary);
            var artist = new MenuFlyoutItem()
            {
                Text = Helper.Localize("Artist")
            };

            artist.Click += (sender, args) =>
            {
                var rArtist = MusicLibraryPage.AllSongs.GroupBy(m => m.Artist).RandItem();
                MediaHelper.SetPlaylistAndPlay(rArtist.Shuffle());
                Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("PlayRandomArtist", rArtist.Key));
            };
            flyout.Items.Add(artist);
            var album = new MenuFlyoutItem()
            {
                Text = Helper.Localize("Album")
            };

            album.Click += (sender, args) =>
            {
                var rAlbum = MusicLibraryPage.AllSongs.GroupBy(m => m.Album).RandItem();
                MediaHelper.SetPlaylistAndPlay(rAlbum.Shuffle());
                Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("PlayRandomAlbum", rAlbum.Key));
            };
            flyout.Items.Add(album);
            if (Settings.settings.Playlists.Count > 0)
            {
                var playlist = new MenuFlyoutItem()
                {
                    Text = Helper.Localize("Playlist")
                };
                playlist.Click += (sender, args) =>
                {
                    var rPlaylist = Settings.settings.Playlists.RandItem();
                    MediaHelper.SetPlaylistAndPlay(rPlaylist.Songs.RandItems(limit));
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("PlayRandomPlaylist", rPlaylist.Name));
                };
                flyout.Items.Add(playlist);
            }
            if (!string.IsNullOrEmpty(Settings.settings.RootPath))
            {
                var localFolder = new MenuFlyoutItem()
                {
                    Text = Helper.Localize("Local Folder")
                };
                localFolder.Click += (sender, args) =>
                {
                    var rLocalFolder = Settings.settings.Tree.GetAllTrees().Where(tree => tree.Files.Count > 0).RandItem();
                    MediaHelper.SetMusicAndPlay(rLocalFolder.Files.RandItems(limit));
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("PlayRandomLocalFolder", rLocalFolder.Directory));
                };
                flyout.Items.Add(localFolder);
            }
            if (RecentPage.RecentAdded?.Count > 0)
            {
                var recentAdded = new MenuFlyoutItem()
                {
                    Text = Helper.Localize("Recent Added")
                };
                recentAdded.Click += (sender, args) =>
                {
                    MediaHelper.SetMusicAndPlay(RecentPage.RecentAdded.TimeLine.RandItems(limit));
                };
                flyout.Items.Add(recentAdded);
            }
            if (Settings.settings.RecentPlayed.Count > 0)
            {
                var recentPlayed = new MenuFlyoutItem()
                {
                    Text = Helper.Localize("Recent Played")
                };
                recentPlayed.Click += (sender, args) =>
                {
                    MediaHelper.SetMusicAndPlay(Settings.settings.RecentPlayed.ToMusicList());
                };
                flyout.Items.Add(recentPlayed);
            }
            if (MusicLibraryPage.SongCount > limit)
            {
                flyout.Items.Add(new MenuFlyoutSeparator());
                var mostPlayed = new MenuFlyoutItem()
                {
                    Text = Helper.Localize("Most Played")
                };
                mostPlayed.Click += (sender, args) =>
                {
                    List <Music> list = new List <Music>();
                    foreach (var group in MusicLibraryPage.AllSongs.GroupBy(m => m.PlayCount).OrderByDescending(g => g.Key))
                    {
                        if (list.Count > limit)
                        {
                            break;
                        }
                        list.AddRange(group);
                    }
                    MediaHelper.SetPlaylistAndPlay(list.Shuffle().Take(limit));
                };
                flyout.Items.Add(mostPlayed);
                var leastPlayed = new MenuFlyoutItem()
                {
                    Text = Helper.Localize("Least Played")
                };
                leastPlayed.Click += (sender, args) =>
                {
                    List <Music> list = new List <Music>();
                    foreach (var group in MusicLibraryPage.AllSongs.GroupBy(m => m.PlayCount).OrderBy(g => g.Key))
                    {
                        if (list.Count > limit)
                        {
                            break;
                        }
                        list.AddRange(group);
                    }
                    MediaHelper.SetPlaylistAndPlay(list.Shuffle().Take(limit));
                };
                flyout.Items.Add(leastPlayed);
            }
            return(flyout);
        }
Esempio n. 6
0
        public MenuFlyout GetMusicMenuFlyout(IMenuFlyoutItemClickListener listener = null, MenuFlyoutOption option = null)
        {
            if (option == null)
            {
                option = new MenuFlyoutOption();
            }
            Music music         = (Data as IMusicable).ToMusic();
            var   flyout        = new MenuFlyout();
            var   localizedPlay = Helper.Localize("Play");
            var   playItem      = new MenuFlyoutItem()
            {
                Icon = new SymbolIcon(Symbol.Play),
                Text = localizedPlay,
                Name = MusicMenuName
            };

            playItem.SetToolTip(localizedPlay + Helper.LocalizeMessage("MusicName", music.Name));
            playItem.Click += (s, args) =>
            {
                MediaHelper.SetMusicAndPlay(music);
            };
            flyout.Items.Add(playItem);
            if (MediaHelper.CurrentMusic != null && music != MediaHelper.CurrentMusic)
            {
                var playNextItem = new MenuFlyoutItem()
                {
                    Text = Helper.LocalizeText("PlayNext"),
                    Icon = new SymbolIcon(Symbol.Upload)
                };
                playNextItem.Click += (s, args) =>
                {
                    int index = MediaHelper.CurrentMusic.Index + 1;
                    if (music.Index >= 0)
                    {
                        MediaHelper.MoveMusic(music.Index, index);
                    }
                    else
                    {
                        MediaHelper.AddMusic(music, index);
                        listener?.AddTo(music, MediaHelper.CurrentPlaylist, index, AddToCollectionType.NowPlaying);
                        foreach (var clickListener in ClickListeners)
                        {
                            clickListener.AddTo(music, MediaHelper.CurrentPlaylist, index, AddToCollectionType.NowPlaying);
                        }
                    }
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("SetPlayNext", music.Name));
                };
                flyout.Items.Add(playNextItem);
            }
            flyout.Items.Add(GetAddToMenuFlyoutSubItem(listener));
            if (option.ShowRemove)
            {
                flyout.Items.Add(GetRemovableMenuFlyoutItem(music, listener));
            }
            if (option.ShowSelect || option.MultiSelectOption != null)
            {
                flyout.Items.Add(GetSelectItem(listener, option.MultiSelectOption));
            }
            flyout.Items.Add(GetShowInExplorerItem(music.Path, StorageItemTypes.File));
            var deleteItem = new MenuFlyoutItem()
            {
                Icon = new SymbolIcon(Symbol.Delete),
                Text = Helper.Localize("Delete From Disk")
            };

            deleteItem.Click += async(s, args) =>
            {
                await new RemoveDialog()
                {
                    Message = Helper.LocalizeMessage("DeleteMusicMessage", music.Name),
                    Confirm = async() =>
                    {
                        MainPage.Instance?.Loader.ShowIndeterminant("ProcessRequest");
                        MusicLibraryPage.AllSongs.Remove(music);
                        Settings.settings.RemoveMusic(music);
                        MediaHelper.DeleteMusic(music);
                        listener?.Delete(music);
                        if (!await Helper.FileNotExist(music.Path))
                        {
                            StorageFile file = await StorageFile.GetFileFromPathAsync(music.Path);

                            await file.DeleteAsync();
                        }
                        MainPage.Instance?.Loader.Hide();
                        Helper.ShowNotification(Helper.LocalizeMessage("MusicDeleted", music.Name));
                    }
                }.ShowAsync();
            };
            deleteItem.SetToolTip(Helper.LocalizeMessage("DeleteMusic", music.Name), false);
            flyout.Items.Add(deleteItem);
            foreach (var item in GetMusicPropertiesMenuFlyout(option.ShowSeeArtistsAndSeeAlbum).Items)
            {
                flyout.Items.Add(item);
            }
            return(flyout);
        }