Ejemplo n.º 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>
        void onTune(Jid jid, XmlElement item)
        {
            if (item == null || item["tune"] == null)
            {
                return;
            }
            var tune = item["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["length"] != null)
            {
                length = Int32.Parse(tune["length"].InnerText);
            }
            int rating = 0;

            if (tune["rating"] != null)
            {
                rating = Int32.Parse(tune["rating"].InnerText);
            }
            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));
        }
Ejemplo n.º 2
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));
        }