/// <summary> /// Parses the windows media player database. /// </summary> private async void ParseWMPDatabase() { EnableControls = false; try { await Task.Run(() => { OnStatusUpdated("Parsing Windows Media Player library..."); using (WMP wmp = new WMP()) { // todo: this can be better var scrobbles = wmp.GetMusicLibrary(); var scrobbleVMs = new List <MediaDBScrobbleViewModel>(); foreach (var scrobble in scrobbles) { var vm = new MediaDBScrobbleViewModel(scrobble); vm.ToScrobbleChanged += ToScrobbleChanged; scrobbleVMs.Add(vm); } ParsedScrobbles = new ObservableCollection <MediaDBScrobbleViewModel>(scrobbleVMs); } OnStatusUpdated("Successfully parsed Windows Media Player library"); }); } catch (Exception ex) { OnStatusUpdated("Fatal error while parsing Windows Media Player library. Error: " + ex.Message); } finally { EnableControls = true; } }
/// <summary> /// Parses the windows media player database. /// </summary> private async void ParseWMPDatabase() { EnableControls = false; await Task.Run(() => { OnStatusUpdated("Parsing Windows Media Player library..."); using (WMP wmp = new WMP()) { // todo: this can be better var scrobbles = wmp.GetMusicLibrary(); var scrobbleVMs = new List<MediaDBScrobbleViewModel>(); foreach (var scrobble in scrobbles) { var vm = new MediaDBScrobbleViewModel(scrobble); vm.ToScrobbleChanged += ToScrobbleChanged; scrobbleVMs.Add(vm); } ParsedScrobbles = new ObservableCollection<MediaDBScrobbleViewModel>(scrobbleVMs); } OnStatusUpdated("Successfully parsed Windows Media Player library"); }); EnableControls = true; }