public CurrentlyPlayingObject(int progressMs, bool isPlaying, ISpotifyTrack track, SpotifyTrackType type) { this.ProgressMs = progressMs; this.IsPlaying = isPlaying; this.Track = track; this.Type = type; }
// ReSharper disable ConstantConditionalAccessQualifier // ReSharper disable once ConstantNullCoalescingCondition public CurrentlyPlayingObject([NotNull] PlaybackContext playbackContext) : this(playbackContext?.ProgressMs ?? 0, playbackContext?.IsPlaying ?? false, null, SpotifyTrackType.Unknown) { if (playbackContext == null) { throw new ArgumentNullException(nameof(playbackContext)); } switch (playbackContext.CurrentlyPlayingType) { case TrackType.Track: if (playbackContext.Item != null) { this.Track = new Song(playbackContext.Item); } break; case TrackType.Episode: this.Track = new SpotifyTrack(SpotifyTrackType.Episode, playbackContext.Item?.Name, (playbackContext.Item?.DurationMs ?? 0) / 1000); break; case TrackType.Ad: this.Track = new SpotifyTrack(SpotifyTrackType.Ad); break; case TrackType.Unknown: this.Track = new SpotifyTrack(SpotifyTrackType.Unknown, playbackContext.Item?.Name, (playbackContext.Item?.DurationMs ?? 0) / 1000); break; default: throw new ArgumentOutOfRangeException(); } this.Type = this.Track?.Type ?? SpotifyTrackType.Unknown; }
public SpotifyTrack(SpotifyTrackType type, string title, int length) { this.Type = type; this.Title = title; this.Length = length; }
public SpotifyTrack(SpotifyTrackType type, string title) : this(type, title, 0) { }
public SpotifyTrack(SpotifyTrackType type) : this(type, null, 0) { }