/// <summary> /// Reloads the given song /// </summary> /// <param name="si">Path to the song file</param> public void ReloadSongItem(SongItem si) { if (si != null) { try { var song = si.Plugin.Load(si.Filename); si.Song = song; si.SearchText = SongSearchUtil.GetSearchableSongText(song); } catch (Exception e) { log.Error(@"Unable to load song file " + si.Filename + @" (" + e.Message + @")"); } } }
/// <summary> /// Reloads all songs from the song direcory /// specified in the application settings /// </summary> public void Reload() { // Find song files var songPaths = new List <string>(); foreach (var ext in SongFilePluginFactory.SupportedExtensions) { var songFilePaths = Directory.GetFiles(SongDirPath, "*" + ext, SearchOption.AllDirectories); songPaths.AddRange(songFilePaths); } var cnt = songPaths.Count; // Load songs into list var i = 0; SongList = new Dictionary <string, SongItem>(); foreach (var path in songPaths) { try { var plugin = SongFilePluginFactory.Create(path); var song = plugin.Load(path); var si = new SongItem { Plugin = plugin, Filename = path, Song = song, SearchText = SongSearchUtil.GetSearchableSongText(song) }; SongList.Add(path, si); if (i % 25 == 0) { var e = new SongLoadEventArgs(i, cnt); if (SongLoaded != null) { SongLoaded(e); } } i++; } catch (Exception e) { log.Error(@"Unable to load song file " + path + @" (" + e.Message + @")"); log.Error(e.StackTrace); } } }