Example #1
0
        /// <summary>
        /// Invoked when a contact has published music information.
        /// </summary>
        /// <param name="jid">The JID of the XMPP entity that published the tune
        /// information.</param>
        /// <param name="item">The 'item' Xml element of the pubsub publish
        /// event.</param>
        private void onTune(Jid jid, XElement item)
        {
            if (item == null || item.Element("tune") == null)
            {
                return;
            }
            var tune = item.Element("tune");

            if (tune.IsEmpty)
            {
                // Raise the 'Tune' event without information.
                Tune.Raise(this, new TuneEventArgs(jid));
                return;
            }
            // Parse 'tune' element.
            int length = 0;

            if (tune.Element("length") != null)
            {
                length = int.Parse(tune.Element("length").Value);
            }
            int rating = 0;

            if (tune.Element("rating") != null)
            {
                rating = int.Parse(tune.Element("rating").Value);
            }
            TuneInformation info = new TuneInformation(
                GetField(tune, "title"), GetField(tune, "artist"), GetField(tune, "track"),
                length, rating, GetField(tune, "source"), GetField(tune, "uri"));

            // Raise the 'Tune' event.
            Tune.Raise(this, new TuneEventArgs(jid, info));
        }
Example #2
0
 /// <summary>
 /// Publishes the specified music information to contacts on the user's
 /// roster.
 /// </summary>
 /// <param name="tune">The tune information to publish.</param>
 /// <exception cref="ArgumentNullException">The tune parameter is
 /// null.</exception>
 /// <exception cref="NotSupportedException">The server does not support the
 /// 'Personal Eventing Protocol' extension.</exception>
 /// <exception cref="XmppErrorException">The server returned an XMPP error code.
 /// Use the Error property of the XmppErrorException to obtain the specific
 /// error condition.</exception>
 /// <exception cref="XmppException">The server returned invalid data or another
 /// unspecified XMPP error occurred.</exception>
 /// <remarks>Publishing no information (i.e. calling Publish without any parameters
 /// is considered a "stop command" to disable publishing).</remarks>
 public void Publish(TuneInformation tune)
 {
     tune.ThrowIfNull("tune");
     Publish(tune.Title, tune.Artist, tune.Track, tune.Length,
             tune.Rating, tune.Source, tune.Uri);
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the TuneEventArgs class.
 /// </summary>
 /// <param name="jid">The JID of the XMPP entity that published the
 /// tune information.</param>
 /// <param name="information">The tune information to include as part of
 /// the event.</param>
 /// <exception cref="ArgumentNullException">The jid parameter is
 /// null.</exception>
 public TuneEventArgs(Jid jid, TuneInformation information = null)
 {
     jid.ThrowIfNull("jid");
     Jid         = jid;
     Information = information;
 }