private async void Mylist_ItemClick(object sender, ItemClickEventArgs e) { //Get Selected Item MusicLibrary song = (MusicLibrary)e.ClickedItem; StorageFile file = await StorageFile.GetFileFromPathAsync(song.Path); //code to play song from song.MusicPath IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read); //set media player controls mediaPlayer.AutoPlay = true; }
public async static Task <IEnumerable <MusicLibrary> > GetAlbumList() { List <string> AlbumList = new List <string>(); ObservableCollection <MusicLibrary> MusicList = new ObservableCollection <MusicLibrary>(); var files = await GetSongFiles(); foreach (var file in files) { StorageItemThumbnail currentThumb = await file.GetThumbnailAsync(ThumbnailMode.MusicView, 200, ThumbnailOptions.UseCurrentScale); var albumCover = new BitmapImage(); albumCover.SetSource(currentThumb); //get file/song property var musicProperties = await file.Properties.GetMusicPropertiesAsync(); var album = musicProperties.Album; if (album is null || album.Equals("")) { album = "Unknown"; } if (!AlbumList.Contains(album)) { AlbumList.Add(album); MusicLibrary ml = new MusicLibrary() { Album = album, AlbumCover = albumCover }; MusicList.Add(ml); } } IEnumerable <MusicLibrary> sortedAlbum = MusicList.OrderBy(o => o.Album); return(sortedAlbum); }
public MainWindow() { InitializeComponent(); player = new SoundPlayer(); musicLibrary = new MusicLibrary(); musicLibrary.LoadLibrary(); // default selection currentSelectedButton = albumButton; albumButton.Style = FindResource("sideButtonPressed") as Style; soundSlider.IsEnabled = false; ShowGrid(); // timer to update the value of the slider - set to 1 second intervals timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += Timer_Tick; isUserDragging = false; }