示例#1
0
        public void UpdateContext([NotNull] List <ContextPage> updatedPages)
        {
            var updatedTracks = updatedPages
                                .SelectMany(x => x.Tracks).ToList();

            foreach (var track in updatedTracks)
            {
                var index = Tracks.FindIndex(x => x.Uri == track.Uri);
                if (index == -1)
                {
                    continue;
                }

                var b = new ContextTrack(Tracks[index]);
                ProtoUtils.CopyOverMetadata(track, b);
                Tracks[index] = b;

                if (index != GetCurrentTrackIndex())
                {
                    continue;
                }
                ProtoUtils.CopyOverMetadata(track, _state.ConnectState.Track);
                UpdateLikeDislike();
            }
        }
示例#2
0
        private string SetContext([NotNull] Context ctx)
        {
            var uri = ctx.Uri;

            Context = AbsSpotifyContext.From(uri);
            ConnectState.ContextUri = uri;

            if (!Context.IsFinite())
            {
                SetRepeatingContext(false);
                SetShufflingContext(false);
            }

            if (ctx.HasUrl)
            {
                this.ConnectState.ContextUrl = ctx.Url;
            }
            else
            {
                this.ConnectState.ContextUrl = String.Empty;
            }

            ConnectState.ContextMetadata.Clear();
            ProtoUtils.CopyOverMetadata(ctx, ConnectState);

            this.Pages        = PagesLoader.From(Session, ctx);
            this.TracksKeeper = new TracksKeeper(this);

            this.SpotifyDevice.SetIsActive(true);

            return(RenewSessionId());
        }