<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>User Tune</title>
  <abstract>This specification defines a payload format for communicating information about music to which a user is listening, including the title, track number, collection, performer, composer, length, and user rating. The payload format is typically transported using the personal eventing protocol, a profile of XMPP publish-subscribe specified in XEP-0163.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0118</number>
  <status>Draft</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0163</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>tune</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/tune.xsd</url>
  </schemaloc>
  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  <revision>
    <version>1.3.0</version>
    <date>2020-10-20</date>
    <initials>mwb</initials>
    <remark><p>Add further tags for non-pop music</p></remark>
  </revision>
  <revision>
    <version>1.2</version>
    <date>2008-01-30</date>
    <initials>psa</initials>
    <remark><p>Added rating element.</p></remark>
  </revision>
  <revision>
    <version>1.1</version>
    <date>2007-06-04</date>
    <initials>psa</initials>
    <remark><p>Removed non-PEP examples; added uri element.</p></remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2004-11-12</date>
    <initials>psa</initials>
    <remark><p>Per a vote of the Jabber Council, advanced status to Draft.</p></remark>
  </revision>
  <revision>
    <version>0.10</version>
    <date>2004-10-29</date>
    <initials>psa</initials>
    <remark><p>Added example with URL.</p></remark>
  </revision>
  <revision>
    <version>0.9</version>
    <date>2004-10-27</date>
    <initials>psa</initials>
    <remark><p>Changed recommendation to not include the &lt;length/&gt; element if the track time is unknown.</p></remark>
  </revision>
  <revision>
    <version>0.8</version>
    <date>2004-10-26</date>
    <initials>psa</initials>
    <remark><p>Added implementation notes; clarified nature of &lt;source/&gt; and &lt;track/&gt; elements; if length is unknown, set to zero.</p></remark>
  </revision>
  <revision>
    <version>0.7</version>
    <date>2004-05-20</date>
    <initials>psa</initials>
    <remark><p>Changed &lt;length/&gt; datatype from xs:duration to xs:unsignedShort.</p></remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2004-04-25</date>
    <initials>psa</initials>
    <remark><p>Corrected several errors; added reference to XEP-0033.</p></remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2004-02-19</date>
    <initials>psa</initials>
    <remark><p>Reverted from infobits to tune elements.</p></remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2003-12-14</date>
    <initials>psa</initials>
    <remark><p>Slight modifications to track changes to infobits specifications.</p></remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2003-10-23</date>
    <initials>psa</initials>
    <remark><p>Replaced tune elements with infobits.</p></remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2003-09-10</date>
    <initials>psa</initials>
    <remark><p>Added "stop" function via empty &lt;tune/&gt; element.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2003-09-08</date>
    <initials>psa</initials>
    <remark><p>Initial version.</p></remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>This document defines a protocol for communicating information about the music to which a user is listening. Such information may be seen as a kind of "extended presence", and users may want to communicate such information to their contacts on the network as a fun add-on to traditional IM applications or to provide integration with common music-player applications.</p>
</section1>
<section1 topic="Protocol" anchor="protocol">
  <section2 topic="Container Element and Child Elements" anchor="protocol-elements">
    <p>Information about tunes is provided by the user and propagated on the network by the user's client. The information container for tune data is a &lt;tune/&gt; element that is qualified by the 'http://jabber.org/protocol/tune' namespace. The tune information itself is provided as the XML character data of the following children of the &lt;tune/&gt; element:</p>
    <table caption="Child Elements">
      <tr>
        <th>Element</th>
        <th>Description</th>
        <th>Example</th>
        <th>Datatype</th>
      </tr>
      <tr>
        <td>artist</td>
        <td>The artist of the song or piece</td>
        <td>Yes</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>composer</td>
        <td>The composer of the song or piece</td>
        <td>Дмитрий Дмитриевич Шостакович (Dmitri Shostakovich)</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>date</td>
        <td>The recording or publication date of the song or piece</td>
        <td>2003-02-15</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>genre</td>
        <td>The genre of the song or piece</td>
        <td>Opera</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>language</td>
        <td>The language of the song or piece, SHOULD be an ISO-639 three letter code</td>
        <td>rus</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>length</td>
        <td>The duration of the song or piece in seconds</td>
        <td>686</td>
        <td>xs:unsignedShort</td>
      </tr>
      <tr>
        <td>lyricist</td>
        <td>The lyricist of the song or piece</td>
        <td>William Shakespeare</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>rating</td>
        <td>The user's rating of the song or piece, from 1 (lowest) to 10 (highest).</td>
        <td>8</td>
        <td>xs:positiveInteger</td>
      </tr>
      <tr>
        <td>performer</td>
        <td>The performer of the song or piece</td>
        <td>Елена Жидкова (Elena Zhidkova)</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>source</td>
        <td>The collection (e.g., album) or other source (e.g., a band website that hosts streams or audio files)</td>
        <td>Yessongs</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>title</td>
        <td>The title of the song or piece</td>
        <td>Heart of the Sunrise</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>track</td>
        <td>A unique identifier for the tune; e.g., the track number within a collection or the specific URI for the object (e.g., a stream or audio file)</td>
        <td>3</td>
        <td>xs:string</td>
      </tr>
      <tr>
        <td>uri</td>
        <td>A URI or URL pointing to information about the song, collection, or artist</td>
        <td>http://www.yesworld.com/lyrics/Fragile.html#9</td>
        <td>xs:anyURI</td>
      </tr>
    </table>
    <p>NOTE: The datatypes specified above are defined in <span class="ref"><link url="http://www.w3.org/TR/xmlschema11-2/">XML Schema Part 2</link></span> <note>XML Schema Part 2: Datatypes &lt;<link url="http://www.w3.org/TR/xmlschema11-2/">http://www.w3.org/TR/xmlschema11-2/</link>&gt;.</note>.</p>
  </section2>
  <section2 topic="Transport Mechanism" anchor="protocol-transport">
    <p>Tune information SHOULD be communicated and transported by means of the <span class="ref"><link url="https://xmpp.org/extensions/xep-0060.html">Publish-Subscribe (XEP-0060)</link></span> <note>XEP-0060: Publish-Subscribe &lt;<link url="https://xmpp.org/extensions/xep-0060.html">https://xmpp.org/extensions/xep-0060.html</link>&gt;.</note> subset specified in <span class="ref"><link url="https://xmpp.org/extensions/xep-0163.html">Personal Eventing Protocol (XEP-0163)</link></span> <note>XEP-0163: Personal Eventing Protocol &lt;<link url="https://xmpp.org/extensions/xep-0163.html">https://xmpp.org/extensions/xep-0163.html</link>&gt;.</note>. Because tune information is not pure presence information and can change independently of the user's availability, it SHOULD NOT be provided as an extension to &lt;presence/&gt;.</p>
    <example caption="User Publishes Tune Information"><![CDATA[
<iq type='set'
    from='stpeter@jabber.org/14793c64-0f94-11dc-9430-000bcd821bfb'
    id='tunes123'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish node='http://jabber.org/protocol/tune'>
      <item>
        <tune xmlns='http://jabber.org/protocol/tune'>
          <artist>Yes</artist>
          <length>686</length>
          <rating>8</rating>
          <source>Yessongs</source>
          <title>Heart of the Sunrise</title>
          <track>3</track>
          <uri>http://www.yesworld.com/lyrics/Fragile.html#9</uri>
        </tune>
      </item>
    </publish>
  </pubsub>
</iq>
]]></example>
    <p>The tune information is then delivered to all subscribers:</p>
    <example caption="Tune Information is Delivered to All Subscribers"><![CDATA[
<message
    from='stpeter@jabber.org'
    to='maineboy@jabber.org'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='http://jabber.org/protocol/tune'>
      <item id='bffe6584-0f9c-11dc-84ba-001143d5d5db'>
        <tune xmlns='http://jabber.org/protocol/tune'>
          <artist>Yes</artist>
          <length>686</length>
          <rating>8</rating>
          <source>Yessongs</source>
          <title>Heart of the Sunrise</title>
          <track>3</track>
          <uri>http://www.yesworld.com/lyrics/Fragile.html#9</uri>
        </tune>
      </item>
    </items>
  </event>
</message>
]]></example>
    <p>In order to indicate that the user is no longer listening to any tunes (or has simply disabled publication), the user's client shall send an empty &lt;tune/&gt; element, which can be considered a "stop command" for user tunes:</p>
    <example caption="User Disables Publishing"><![CDATA[
<iq type='set'
    from='stpeter@jabber.org/14793c64-0f94-11dc-9430-000bcd821bfb'
    id='tunes345'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish node='http://jabber.org/protocol/tune'>
      <item>
        <tune xmlns='http://jabber.org/protocol/tune'/>
      </item>
    </publish>
  </pubsub>
</iq>
]]></example>
    <example caption="Empty Tune Information is Delivered to All Subscribers"><![CDATA[
<message
    from='stpeter@jabber.org'
    to='maineboy@jabber.org'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='http://jabber.org/protocol/tune'>
      <item id='cbbb3f5a-0f9c-11dc-afe0-001143d5d5db'>
        <tune xmlns='http://jabber.org/protocol/tune'/>
      </item>
    </items>
  </event>
</message>
]]></example>
  </section2>
</section1>
<section1 topic="Implementation Notes" anchor="impl">
  <p>To prevent a large number of updates when a user is skipping through tracks, an implementation SHOULD wait several seconds before publishing new tune information.</p>
  <p>If the length is unknown (e.g., the user is listening to a stream), the &lt;length/&gt; element SHOULD NOT be included.</p>
  <p>A typical interface for user ratings is to show one to five star icons such as ★★★★. If this interface is used, the numbers 2, 4, 6, 8, and 10 should be mapped to one, two, three, four, and five stars respectively, and odd numbers should be mapped to half stars (e.g., the number 9 would be mapped to four-and-a-half stars).</p>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>The publication of user tune information is not known to introduce any new security considerations above and beyond those defined in <cite>XEP-0060: Publish-Subscribe</cite>.</p>
</section1>
<section1 topic="IANA Considerations" anchor="iana">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <section2 topic="Protocol Namespaces" anchor="registrar-ns">
    <p>The <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> includes 'http://jabber.org/protocol/tune' in its registry of protocol namespaces.</p>
  </section2>
</section1>
<section1 topic="XML Schema" anchor="schema">
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/tune'
    xmlns='http://jabber.org/protocol/tune'
    elementFormDefault='qualified'>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0118: http://www.xmpp.org/extensions/xep-0118.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='tune'>
    <xs:complexType>
      <xs:sequence minOccurs='0'>
        <xs:element name='artist' type='xs:string' minOccurs='0'/>
        <xs:element name='composer' type='xs:string' minOccurs='0'/>
        <xs:element name='date' type='xs:string' minOccurs='0'/>
        <xs:element name='genre' type='xs:string' minOccurs='0'/>
        <xs:element name='language' type='xs:string' minOccurs='0'/>
        <xs:element name='length' type='xs:unsignedShort' minOccurs='0'/>
        <xs:element name='lyricist' type='xs:string' minOccurs='0'/>
        <xs:element name='performer' type='xs:string' minOccurs='0'/>
        <xs:element name='rating' minOccurs='0'>
          <xs:simpleType>
            <xs:restriction base='xs:positiveInteger'>
              <xs:maxInclusive value='10'/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name='source' type='xs:string' minOccurs='0'/>
        <xs:element name='title' type='xs:string' minOccurs='0'/>
        <xs:element name='track' type='xs:string' minOccurs='0'/>
        <xs:element name='uri' type='xs:anyURI' minOccurs='0'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
]]></code>
</section1>
</xep>
