コード例 #1
0
        public MenuFlyout GetPlaylistMenuFlyout(IMenuFlyoutItemClickListener listener = null, MenuFlyoutOption option = null)
        {
            if (option == null)
            {
                option = new MenuFlyoutOption()
                {
                    ShowSelect = false
                }
            }
            ;
            var flyout      = new MenuFlyout();
            var shuffleItem = new MenuFlyoutItem()
            {
                Icon = new SymbolIcon(Symbol.Shuffle),
                Text = Helper.Localize("Shuffle"),
                Name = PlaylistMenuName
            };

            shuffleItem.SetToolTip("Shuffle and Play");
            shuffleItem.Click += (s, args) =>
            {
                MediaHelper.ShuffleAndPlay(Data as IEnumerable <Music>);
            };
            flyout.Items.Add(shuffleItem);
            flyout.Items.Add(GetAddToMenuFlyoutSubItem(listener));
            if (option.ShowMultiSelect)
            {
                flyout.Items.Add(GetMultiSelectItem(listener, option.MultiSelectOption));
            }
            else if (option.ShowSelect)
            {
                flyout.Items.Add(GetSelectItem(listener, option.MultiSelectOption));
            }
            return(flyout);
        }
コード例 #2
0
        private void PlayAllButton_Click(object sender, RoutedEventArgs e)
        {
            var data = (sender as Button).DataContext as AlbumView;

            MediaHelper.ShuffleAndPlay(data.Songs);
        }
コード例 #3
0
        private void LocalShuffleItem_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var tree = History.Peek();

            MediaHelper.ShuffleAndPlay(LocalFrame.SourcePageType == typeof(LocalMusicPage) ? tree.Files : tree.Flatten());
        }
コード例 #4
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);
        }