public override void Initialize (Track track) { base.Initialize (track); Progress.MinValue = 0; Progress.MaxValue = (track?.Duration).GetValueOrDefault (1); UpdateLabels (TimeSpan.Zero); }
public ReconnectingStream (ServerDetails server, INetworkChangedListener networkChangedListener, Track track) { ServerAddress = server.FullAddress; NetworkChangedListener = networkChangedListener; Track = track; NetworkChangedListener.NetworkChanged += () => { LoggingService.LogInfo ("The network route has changed, reconnecting..."); cts.Cancel (); }; }
public void ArtistSortOrder_The () { var tracks = new Track [] { BasicTrack (albumArtist: "A", trackArtist: "A"), BasicTrack (albumArtist: "The B", trackArtist: "The B"), BasicTrack (albumArtist: "C", trackArtist: "C"), }; var catalog = new Catalog (tracks); Assert.AreEqual ("A", catalog.Artists [0].Name); Assert.AreEqual ("The B", catalog.Artists [1].Name); Assert.AreEqual ("C", catalog.Artists [2].Name); }
public void MultiDisc () { var tracks = new Track[] { BasicTrack ("d1t1", 1, 1), BasicTrack ("d1t2", 1, 2), BasicTrack ("d2t1", 2, 1), BasicTrack ("d2t2", 2, 2), BasicTrack ("d3t6", 3, 6), }; foreach (var catalog in tracks.AllPermutations ().Select (p => new Catalog (p))) { Assert.AreEqual (1, catalog.Artists.Length, "#1"); Assert.AreEqual (1, catalog.Artists [0].Albums.Length, "#2"); var t = catalog.Artists.First ().Albums.First ().Tracks; Assert.That (tracks, Is.EqualTo (catalog.Artists.First ().Albums.First ().Tracks), "#track order"); } }
public async Task<bool> Scrobble (Track track) { if (!await Login ()) { LoggingService.LogInfo ("Last.FM login failed... caching scrobble"); SaveToCache (track); return false; } if (await ScrobbleFromCache ()) { Files.Delete (ScrobbleCache); } else { LoggingService.LogInfo ("Could not flush existing cache, appending to cache instead of scrobbling"); SaveToCache (track); return false; } if (!await Scrobble (new [] { track })) { LoggingService.LogInfo ("Failed to scrobble: {0}. Caching it.", track); SaveToCache (track); return false; } LoggingService.LogInfo ("Successfully scrobbled: {0}", track); return true; }
public override void Initialize (Track track) { base.Initialize(track); if (track == null) { SidebarView.Frame = SidebarView.Frame.Expand (0, 0, 0, StatusView.IntrinsicContentSize.Height); StatusView.RemoveFromSuperview (); } else { if (StatusView.Superview == null) { SidebarView.Frame = SidebarView.Frame.Expand (0, 0, 0, -StatusView.IntrinsicContentSize.Height); StatusView.Layer.ShadowOpacity = 0.5f; StatusView.Layer.ShadowColor = UIColor.Black.CGColor; StatusView.TranslatesAutoresizingMaskIntoConstraints = false; Superview.AddSubview (StatusView); Superview.AddConstraints (new [] { NSLayoutConstraint.Create (StatusView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, Superview, NSLayoutAttribute.Bottom, 1, 0), NSLayoutConstraint.Create (StatusView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, Superview, NSLayoutAttribute.Left, 1, 0), NSLayoutConstraint.Create (StatusView, NSLayoutAttribute.Right, NSLayoutRelation.Equal, Superview, NSLayoutAttribute.Right, 1, 0), }); } StatusView.Track = track.Name; StatusView.Artist = track.TrackArtist; } }
void SaveToCache (Track track) { try { Directory.CreateDirectory (Path.GetDirectoryName (ScrobbleCache)); File.AppendAllText (ScrobbleCache, JsonConvert.SerializeObject (track)); } catch (Exception ex) { LoggingService.LogError (ex, "Could not append to the scrobble cache. Data is lost!"); } }
public override void Initialize (Track track) { base.Initialize (track); Scrobbled = false; }