Ejemplo n.º 1
0
        public LocalSongs()
        {
            this.InitializeComponent();

            localSongsVM = LocalSongsVM.GetLocalSongsVM();
            Current      = this;
        }
Ejemplo n.º 2
0
        private async void Addfolder_Click(object sender, RoutedEventArgs e)
        {
            FolderPicker openPicker = new FolderPicker();

            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
            List <string> fileTypeFilter = new List <string>();

            fileTypeFilter.Add(".mp3");
            openPicker.FileTypeFilter.Add(".mp3");
            StorageFolder folder = await openPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                Current.Frame.IsEnabled = false;
                var t = new MessageDialog("请等待...");
                await t.ShowAsync();

                var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, fileTypeFilter);
                var query        = folder.CreateFileQueryWithOptions(queryOptions);
                IReadOnlyList <StorageFile> fileList = await query.GetFilesAsync();

                LocalSongsVM.GetLocalSongsVM().ReadMusicFiles(fileList);

                Current.Frame.IsEnabled = true;

                new MessageDialog("歌曲导入完成。");
            }
        }
Ejemplo n.º 3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string searchContent = (string)e.Parameter;

            ResultSongs = LocalSongsVM.GetLocalSongsVM().SearchSongs(searchContent);
            if (ResultSongs.Count != 0)
            {
                NoResultTB.Visibility = Visibility.Collapsed;
                ResultsLV.Visibility  = Visibility.Visible;
            }
            else
            {
                NoResultTB.Visibility = Visibility.Visible;
                ResultsLV.Visibility  = Visibility.Collapsed;
            }
        }
Ejemplo n.º 4
0
        private async void AddSongBtn_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
            openPicker.FileTypeFilter.Add(".mp3");
            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                Play(file);
                MusicProperties musicProperties = await file.Properties.GetMusicPropertiesAsync();

                StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.MusicView);

                if (!LocalSongsVM.GetLocalSongsVM().HasSong(file.Path))
                {
                    Song song = new Song(file.Path, musicProperties, thumbnail);
                    LocalSongsVM.GetLocalSongsVM().Songs.Add(song);
                    DBManager.AddSong(song, "_Songs_");
                }
            }
        }