示例#1
0
        /// <summary>
        /// The internal scrobble function, scrobbles pure request parameters.
        /// Could be for more than one track, as specified by Last.fm, but they recommend that
        /// only one track should be submitted at a time.
        /// </summary>
        /// <param name="parameters">
        /// A <see cref="RequestParameters"/>
        /// </param>
        internal void Scrobble(RequestParameters parameters)
        {
            parameters["method"]  = "track.scrobble";
            parameters["api_sig"] = Utilities.MD5(parameters.ToStringForSig(ApiSecret));
            Request request = new Request(new Uri(this.ApiURL), parameters);

            // A BadSessionException occurs when another client has made a handshake
            // with this user's credentials, should redo a handshake and pass this
            // exception quietly.
            try
            {
                request.executeThreaded();
            } catch (BadSessionException) {
                this.Scrobble(parameters);
            }
        }
示例#2
0
        /// <summary>
        /// Send the now playing notification.
        /// </summary>
        /// <param name="track">
        /// A <see cref="NowplayingTrack"/>
        /// </param>
        public void ReportNowplaying(NowplayingTrack track)
        {
            RequestParameters p = new RequestParameters(parameters);

            p.Append(track.getParameters());
            p["method"]  = "track.updateNowPlaying";
            p["api_sig"] = Utilities.MD5(p.ToStringForSig(ApiSecret));

            Request request = new Request(new Uri(this.ApiURL), p);

            // A BadSessionException occurs when another client has made a handshake
            // with this user's credentials, should redo a handshake and pass this
            // exception quietly.
            try
            {
                request.executeThreaded();
            }
            catch (BadSessionException)
            {
                this.ReportNowplaying(track);
            }
        }