The XSPF Playlist Format, version 0

Abstract

This document describes a playlist format named "XSPF", which stands for "XML Shareable Playlist Format". "XSPF" can be pronounced "spiff" or maybe "spliff."

Publication status and authorship

This is an informal document not associated with any standards body. It is intended to be clear and readable rather than conformant with existing standards for such documents.

This is the fourth draft of this document. It is a major rewrite, and there are a number of areas where the result is rough. This document assumes that your browser supports CSS reasonably well; versions of Internet Explorer older than version 6 don't. Items marked like [[fixme: this]] are markers for work yet to be done. See the todo list for more details about this document.

The home of our working group is http://xspf.org. On IRC, we use #playlist on irc.freenode.net. There are perhaps six regular contributors, with another six commenting from time to time. Contributors came from two major audio software vendors, a major weblog aggregator, the W3C, and two significant .org sites related to music. We worked in the skunkworks style and were not sponsored by any organization or standards body. Our purpose was to engineer a high-quality design rather than to create normative requirements for interoperability.

This document is maintained by Lucas Gonze.

Creation date of this document is Sunday, May 9, 2004. The most recent edit is July 11, 2004.

Table of Contents

  1. Abstract
  2. Publication status and authorship
  3. Introduction
  4. Example
  5. Element definitions
    1. xml
      1. version
      2. encoding
      1. playlist
        1. xmlns
        2. version
        1. title
        2. annotation
        3. creator
        4. info
        5. location
        6. identifier
        7. image
        8. date
        9. license
        10. attribution
        11. link
          1. rel
        12. meta
          1. rel
        13. trackList
          1. track
            1. location
            2. identifier
            3. info
            4. image
            5. annotation
            6. creator
            7. title
            8. album
            9. trackNum
            10. duration
            11. link
              1. rel
            12. meta
              1. rel
  6. Recipes
    1. How do I set relative paths in an XSPF playlist, for example if I want to use it as a file manifest?
    2. How to I convert XSPF to M3U?
    3. How to I convert XSPF to HTML?
    4. How to I convert XSPF to SMIL?
    5. How to I convert XSPF to Soundblox?
    6. How do I customize XSPF? Should I use namespaces?
  7. Design and architecture
    1. User agents
    1. Usecases
    2. Requirements
    3. Features
    4. Principles
      1. Catalogs vs. [[fixme: ??]]
      2. Fuzzy names
      3. Content resolvers
  8. Administrative
    1. Todo list
    2. Validate

Introduction

The genesis of this project came from the mutual recognition that the quality of playlist formats fell far below the normal standard for hypertext document types like HTML, RDF and Atom. Our goals were to create a playlist format that is all three of:

  1. Open -- existing formats are either ad-hoc standards with no owner, like M3U, or proprietary, like ASX.
  2. Portable -- you should be able to send a playlist sans content to your friend, or open the same playlist with different software on the same machine, and have it be usable. Existing formats lack a number of features needed to make this work well.
  3. Well made -- there is a glaring lack of craftsmanship to existing formats. For example, no dominant playlist format declares a namespace. And while there are independent efforts to write a format with a high level of craftsmanship, the Gnomoradio format for example, writing data formats is too hard to succeed without a team.

Over the course of our work we also realized that the format had to scale down well. The dominant playlist format is M3U, which is just a flat listing of song paths, and many developers are satisfied enough to stick with it. SMIL is all three of open, portable and well made, but is too complex for many needs; simple SMIL playlists are not simple to implement. Similarly, RDF offered well made solutions to many problems we faced, but RDF tools are never trivial (as of this writing). We went to great lengths to make trivial playlists trivial to implement.

The most pressing question for software developers is why should I support this XML playlist format instead of or in addition to ASX, SMIL, Gnomoradio RDF, iTunes XML, or RSS? Why does the world need yet another XML playlist format? The answer is XSPF is by far the most carefully crafted XML playlist format.

Example

A very simple document looks like this:

<?xml version="1.0" encoding="UTF-8"?> <playlist version="0" xmlns = "http://xspf.org/ns/0/"> <trackList> <track><location>file:///mp3s/Yo%20La%20Tengo/Nuclear%20War/1_Nuclear%20War%20Version%201.mp3</location></track> <track><location>file:///mp3s/Yo%20La%20Tengo/Nuclear%20War/2_Nuclear%20War%20Version%202.mp3</location></track> <track><location>file:///mp3s/Yo%20La%20Tengo/Nuclear%20War/3_Nuclear%20War%20Version%203.mp3</location></track> <track><location>file:///mp3s/Yo%20La%20Tengo/Nuclear%20War/4_Nuclear%20War%20Version%204</location></track> <track><location>file:///mp3s/Yo%20La%20Tengo/Nuclear%20War/5_Nuclear%20War%20Version%204%20(Mike%20Ladd%20Remix).mp3</location></track> </trackList> </playlist>

Element definitions

xml
version
1.0
encoding
utf-8 recommended to allow unicode characters in text fields
playlist
xmlns
http://xspf.org/ns/0/
version
0
title
A human-readable title for the playlist. xspf:playlist elements MAY contain exactly one.
annotation
A human-readable comment on the playlist in text/plain format. xspf:playlist elements MAY contain exactly one.
creator
Human-readable name of the entity (author, authors, group, company, etc) that authored the playlist. xspf:playlist elements MAY contain exactly one.
info
URI of a web page to find out more about this playlist. Likely to be homepage of the author, and would be used to find out more about the author and to find more playlists by the author. xspf:playlist elements MAY contain exactly one.
location
Source URI for this playlist. xspf:playlist elements MAY contain zero or more location elements.
identifier
Canonical ID for this playlist. Likely to be a hash or other location-independent name. MUST be a legal URI. xspf:playlist elements MAY contain zero or more identifier elements.
image
URI of an image to display in the absence of a //playlist/trackList/image element. xspf:playlist elements MAY contain exactly one.
date
ISO8601 creation date (not last-modified date) of the playlist. xspf:playlist elements MAY contain exactly one.
license
URI of a resource that describes the license under which this playlist was released.
attribution

An ordered list of URIs. The purpose is to satisfy licenses allowing modification but requiring attribution. If you modify such a playlist, move its //playlist/location element or //playlist/identifier to the top of the items in the //playlist/attribution element. xspf:playlist elements MAY contain exactly one xspf:attribution element.

<attribution> <location>http://snafu.com/modified_version_of_modified_version_of_original_playlist.xspf</location> <location>http://bar.com/modified_version_of_original_playlist.xspf</location> <location>http://foo.com/original_playlist.xspf</location> </attribution>

link

The link element allows non-XSPF web resources to be included in XSPF documents without breaking XSPF validation.

<link rel="http://foaf.org/namespace/version1">http://socialnetwork.org/foaf/mary.rdfs</link>

rel
URI of a resource type.

URI of a resource.

meta

The meta element allows non-XSPF metadata to be included in XSPF documents without breaking XSPF validation.

<meta rel="http://example.org/key">value</meta>

rel
URI of a resource defining the metadata.

Value of the metadata element. MUST be valid text/plain, not XML.

trackList

Ordered list of xspf:track elements to be rendered. xspf:track elements MUST be rendered in the order in which they appear, from top to bottom, unless a different ordering is otherwise indicated. If an xspf:track element cannot be rendered, a user-agent MUST skip to the next xspf:track element and MUST NOT interrupt the sequence.

track
location
URI of resource to be rendered. Probably an audio resource, but MAY be any type of resource with a well-known duration, such as video, a SMIL document, or an XSPF document. The duration of the resource defined in this element defines the duration of rendering. xspf:track elements MAY contain zero or more location elements, but a user-agent MUST NOT render more than one of the named resources.
identifier
Canonical ID for this resource. Likely to be a hash or other location-independent name, such as a MusicBrainz identifier or isbn URN (if there existed isbn numbers for audio). MUST be a legal URI. xspf:playlist elements MAY contain zero or more identifier elements.
info
URI of a place where this resource can be bought or more info can be found.
image
URI of an image to display for the duration of the track. xspf:track elements MAY contain exactly one.
annotation
A human-readable comment on the track in text/plain format. xspf:track elements MAY contain exactly one.
creator
Human-readable name of the entity (author, authors, group, company, etc) that authored the resource which defines the duration of track rendering. This value is primarily for fuzzy lookups, though a user-agent may display it. xspf:track elements MAY contain exactly one.
title
Human-readable name of the track that authored the resource which defines the duration of track rendering. This value is primarily for fuzzy lookups, though a user-agent may display it. xspf:track elements MAY contain exactly one.
album
Human-readable name of the collection from which the resource which defines the duration of track rendering comes. For a song originally published as a part of a CD or LP, this would be the title of the original release. This value is primarily for fuzzy lookups, though a user-agent may display it. xspf:track elements MAY contain exactly one.
trackNum
Integer with value greater than zero giving the ordinal position of the media on the xspf:album. This value is primarily for fuzzy lookups, though a user-agent may display it. xspf:track elements MAY contain exactly one.
duration
Number giving the length of the media. This value is primarily for fuzzy lookups, though a user-agent may display it. A user-agent MUST NOT use this value to determine the rendering duration, since the data will likely be low quality. The exact format of this value is still under discussion. xspf:track elements MAY contain exactly one.
link

The link element allows non-XSPF web resources to be included in xspf:track elements without breaking XSPF validation.

<link rel="http://foaf.org/namespace/version1">http://socialnetwork.org/foaf/mary.rdfs</link>

rel
URI of a resource type.

URI of a resource.

meta

The meta element allows non-XSPF metadata to be included in xspf:track elements without breaking XSPF validation.

<meta rel="http://example.org/key">value</meta>

rel
URI of a resource defining the metadata.

Value of the metadata element. MUST be valid text/plain, not XML.

Recipes

How do I set relative paths in an XSPF playlist, for example if I want to use it as a file manifest?

See the XML Base specification or IETF RFC 2396:

The rules for determining the base URI can be summarized as follows (highest priority to lowest):
  1. The base URI is embedded in the document's content.
  2. The base URI is that of the encapsulating entity (message, document, or none).
  3. The base URI is the URI used to retrieve the entity.
  4. The base URI is defined by the context of the application.
How to I convert XSPF to M3U?
Use the xspf2m3u.xsl stylesheet.
How to I convert XSPF to HTML?
Use the xspf2html.xsl stylesheet.
How to I convert XSPF to SMIL?
Use the xspf2smil.xsl stylesheet.
How to I convert XSPF to Soundblox?
Use the xspf2sblx.xsl stylesheet.
How do I customize XSPF? Should I use namespaces?
Use the meta or link elements. Use meta if the element contains a single value, like "blue" or "rock"; use link if the element contents are a URL. Try to avoid using namespaces to add fields, because namespaced items cannot be validated by an XSPF validator.

Design and architecture

User agents

On a surface level you can use XSPF like any other playlist format. Drop a bunch of filenames into an XSPF document, prepend "file://" to each, and you're ready to go. Under the surface there is much more.

The guiding design principle was to separate the functionality of a catalog of files from the functionality of a list of songs. Most MP3 players have some sort of cache for file information. This cache stores a list, or catalog, of available files and metadata from ID3 tags and other sources. XSPF is not a catalog format. XSPF exists only to say which songs to play. Almost everything in XSPF is for the purpose of answering the question which resource, rather than the question what is this resource.

If XSPF is not a catalog format, what is it? XSPF is an intermediate format. We expected a new kind of software called a content resolver to do the job of converting XSPF to a plain old list of files or URLs. A content resolver would be smart enough to keep your playlists from breaking when you move your MP3s from /mp3s to /music/mp3. It would be able to figure out that a playlist entry by the artist "Hank Williams" with the title "Your Cheating Heart" could be satisfied by the file /mp3s/hankwilliams/yourcheatingheart.mp3. It might even know how to query the iTunes music store or another online provider to locate and download a missing song.

The content resolver maintains the catalog of your songs in whatever format it prefers. It might use a flatfile, a file in the Berkeley DB format, or a SQL database. It might use only ID3 metadata, but it might also know how to query MusicBrainz or another metadata service.

Usecases
Requirements
[[fixme: clean up and incorporate the requirements list from the wiki]]
Features
Principles
Catalogs vs. [[fixme: ??]]
Fuzzy names
Content resolvers

Administrative

Todo list
  1. Table of contents is still whacky.
  2. Need to get the one big normative requirement in somewhere: if a resource is not playable, a player must not stop processing; graceful recovery from failure.
  3. Architectural notes on fuzzy search, catalogs, and content resolvers.
  4. Bug and issue list for XSPF.
  5. Contact address for bugs in this document and in XSPF.
  6. Spell check.
  7. Solicit feedback on formatting of this document.
  8. Section to tell developers why they should support XSPF.
  9. Names of WG contributors.
Validate
  1. HTML
  2. CSS