private async void OnShuffleAllClick(object sender, RoutedEventArgs e) { if (GlobalLibraryCache.CachedDbMediaFile == null) { await GlobalLibraryCache.LoadMediaAsync(); } var s = from x in Shuffle(GlobalLibraryCache.CachedDbMediaFile, new Random()) select MusicPlaybackItem.CreateFromMediaFile(x); Core.PlaybackControl.Instance.Clear(); await Core.PlaybackControl.Instance.AddAndSetIndexAt(s, 0); }
public static async Task LoadLibraryCacheAsync() { if (GlobalLibraryCache.CachedDbAlbum == null) { await GlobalLibraryCache.LoadAlbumAsync(); } if (GlobalLibraryCache.CachedDbArtist == null) { await GlobalLibraryCache.LoadArtistAsync(); } if (GlobalLibraryCache.CachedDbMediaFile == null) { await GlobalLibraryCache.LoadMediaAsync(); } }
/// <summary> /// Load file data from database. /// </summary> /// <param name="cancellationToken">Cancellation token.</param> /// <returns>Processed files.</returns> public async Task <IEnumerable <CommonViewItemModel> > LoadSongData(CancellationToken cancellationToken) { if (GlobalLibraryCache.CachedDbMediaFile == null) { await GlobalLibraryCache.LoadMediaAsync(); } var result = new List <CommonViewItemModel>(GlobalLibraryCache.CachedDbMediaFile.Length); foreach (var item in GlobalLibraryCache.CachedDbMediaFile) { var e = new CommonViewItemModel(item); GroupedItems.Add(e); result.Add(e); } return(result); }