public CurrentlyPlayingObject(int progressMs, bool isPlaying, ISpotifyTrack track, SpotifyTrackType type)
 {
     this.ProgressMs = progressMs;
     this.IsPlaying  = isPlaying;
     this.Track      = track;
     this.Type       = type;
 }
예제 #2
0
        // 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;
        }
예제 #3
0
 public SpotifyTrack(SpotifyTrackType type, string title, int length)
 {
     this.Type   = type;
     this.Title  = title;
     this.Length = length;
 }
예제 #4
0
 public SpotifyTrack(SpotifyTrackType type, string title) : this(type, title, 0)
 {
 }
예제 #5
0
 public SpotifyTrack(SpotifyTrackType type) : this(type, null, 0)
 {
 }