Esempio n. 1
0
		void SongListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			ListBox senderListBox = sender as ListBox;
			if (senderListBox == null)
				return;

			if (e.AddedItems.Count <= 0)
			{
				return;
			}

			_currentIndex = senderListBox.SelectedIndex;
			CurrentSong = e.AddedItems[0] as Song;

			_PlayMusicAsync();
		}
Esempio n. 2
0
		//-------------------------- ▶ EventHandlers
		async void OpenButton_Click(object sender, RoutedEventArgs e)
		{
			FolderPicker folderPicker = new FolderPicker()
			{
				ViewMode = PickerViewMode.Thumbnail,
				SuggestedStartLocation = PickerLocationId.MusicLibrary,
				CommitButtonText = "선택",
			};
			folderPicker.FileTypeFilter.Add(".mp3");
			folderPicker.FileTypeFilter.Add(".wmv");
			StorageFolder storageFolder = await folderPicker.PickSingleFolderAsync();

			if (storageFolder == null)
			{
				return;
			}

			IReadOnlyList<StorageFile> allItems = await storageFolder.GetFilesAsync();
			if (allItems.Count < 0)
			{
				return;
			}


			var onlyMusics = allItems.Where(c => c.ContentType == "audio/mpeg");
			if (onlyMusics.Count() <= 0)
			{
				return;
			}

			if (Songs == null)
			{
				Songs = new ObservableCollection<Song>();
			}
			else
			{
				Songs.Clear();
			}

			foreach (var music in onlyMusics)
			{
				Song song = new Song()
				{
					StorageFile = music,
					MusicProperties = await music.Properties.GetMusicPropertiesAsync()
				};

				Songs.Add(song);
			}
		}