Esempio n. 1
0
        /// <summary>
        /// Send the now playing notification.
        /// </summary>
        /// <param name="track">
        /// A <see cref="NowplayingTrack"/>
        /// </param>
        public void ReportNowplaying(NowplayingTrack track)
        {
            Initialize();

            RequestParameters p = new RequestParameters();

            p["s"] = SessionID;
            p["a"] = track.Artist;
            p["t"] = track.Title;
            p["b"] = track.Album;

            if (track.Duration.TotalSeconds == 0)
            {
                p["l"] = "";
            }
            else
            {
                p["l"] = track.Duration.TotalSeconds.ToString();
            }

            if (track.Number == 0)
            {
                p["n"] = "";
            }
            else
            {
                p["n"] = track.Number.ToString();
            }

            p["m"] = track.MBID;

            Request request = new Request(this.NowplayingURL, 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.execute();
            } catch (BadSessionException) {
                this.doHandshake();
                this.ReportNowplaying(track);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Relays a Now Playing report to the underlying
 /// connection. For luxury purposes only.
 /// </summary>
 /// <param name="track">
 /// A <see cref="NowplayingTrack"/>
 /// </param>
 public void ReportNowplaying(NowplayingTrack track)
 {
     Connection.ReportNowplaying(track);
 }