public static void ReportTrack(Track? track) { // ReSharper disable once SuspiciousTypeConversion.Global if (!(AppState.Instance.ActivePlugin is IPushyReporter)) { throw new InvalidOperationException("Plugin tried to report track but was not pushy. This is not allowed. If you are the plugin's developer, please change your plugin class to implement IPushyReporter."); } AppState.Instance.SaveReport(track); }
private void SpotifyOnOnTrackChange(TrackChangeEventArgs trackChangeEventArgs) { var result = new Track(); var newTrack = trackChangeEventArgs.NewTrack; result.artist = newTrack.ArtistResource.Name; result.album = newTrack.AlbumResource.Name; result.title = newTrack.IsAd() ? "ADVERT" : newTrack.TrackResource.Name; lastTrack = result; SnapApi.ReportTrack(result); }
public static void SaveTrack(Track track) { var output = AppState.Instance.Settings.OutputFormat; output = output.Replace("$artist", track.artist); output = output.Replace("$album", track.album); output = output.Replace("$title", track.title); using (var stream = new StreamWriter(FolderPathPlusSep + "Snap.txt", false)) { stream.WriteLine(output); } }
public override void Activate() { timer.Elapsed += (sender, args) => { var track = new Track { artist = "The WinSnap Team", album = "WiNSnap Dummy", title = "I work!" }; if (new Random().NextDouble() > 0.5) { SnapApi.ReportTrack(track); } else { SnapApi.ReportTrack(null); } }; timer.Start(); }
internal void SaveReport(Track? report) { if (report == null) { TextHandler.SaveNoTrack(); MainWindow.Instance.SetNothingPlaying(); } else { TextHandler.SaveTrack((Track) report); MainWindow.Instance.SetNowPlaying((Track) report); } }