public LyricsViewModel() { var playerViewModel = IoC.Get<PlayerViewModel>(); GetLyricsCommand = new ReactiveCommand(); GetLyricsCommand.Subscribe(x => { var current = playerViewModel.CurrentlyPlaying; if (current != null && SelectedLyricsProvider != null) { var finder = new LyricsFinder(current.Model.ArtistName, current.Model.TrackTitle); finder.ClearProviders(); finder.AddProvider(SelectedLyricsProvider); finder.ResultAvailable += (sender, e) => LyricsText = e.Result.Text; finder.ProviderError += (sender, e) => LyricsText = e.ProviderName + ": " + e.Exception.Message; finder.Start(); } }); }
static void Main(string[] args) { AutoResetEvent autoEvent = new AutoResetEvent(false); LyricsFinder finder = new LyricsFinder("Supertramp", "It Doesn't Matter"); finder.ClearProviders(); finder.AddProvider(new WikiaLyricsProvider()); finder.ResultAvailable += (sender, e) => { Console.WriteLine(e.Result.Artist + " " + e.Result.TrackTitle + " : " + e.Result.Text.Substring(0, 40).Replace("\r\n", "")); }; finder.ProviderError += (sender, e) => { Console.WriteLine(e.ProviderName + ": " + e.Exception.Message); }; finder.QueryCompleted += (sender, e) => autoEvent.Set(); finder.Start(); autoEvent.WaitOne(); }