class RemiAudio::Xspf::Playlist
- RemiAudio::Xspf::Playlist
- Reference
- Object
Overview
The Playlist class contains general information about the playlist, as
well as a list of tracks. This also acts as the toplevel class for
XSPF/JSPF data, allowing you to read and write XSPF and JSPF files.
Reading an XSPF file:
playlist = File.open("/path/to/file.xspf", "r") do |file|
RemiAudio::Xspf::Playlist.read(file)
end
# Print the locations for every track
playlist.each do |trk|
puts trk.locations
end
Writing an XSPF file:
playlist = RemiAudio::Xspf::Playlist.new
playlist.title = "A Neat Playlist"
playlist.add(title: "Rabio", creator: "Partition 36", "/path/to/file/03 - Rabio.mp3")
playlist.add(title: "Searching for My Identity", creator: "Partition 36",
"/path/to/file/06 - Searching for My Identity.mp3")
puts playlist.write # Write XML to a String
playlist.write("/path/to/dest.xspf") # Write XSPF to a file
# Write JSPF to a file.
playlist.write("/path/to/dest.xspf", RemiAudio::Xspf::Playlist::Format::Json)
Included Modules
- JSON::Serializable
Defined in:
remiaudio/xspf/xspf.crConstant Summary
-
VERSION =
1 -
The version of the specification that we support. Note that version 1 is backwards compatible with version 0.
Constructors
- .new(pull : JSON::PullParser)
-
.new
Creates a new
Playlistinstance. -
.read(io : IO, *, format : Format = Format::Xml) : Playlist
Creates a new
Playlistinstance by reading data fromio. -
.read(str : String, *, format : Format = Format::Xml) : Playlist
Creates a new
Playlistinstance by reading data fromstr.
Instance Method Summary
-
#add(*locationURIs : URI, title : String | Nil = nil, album : String | Nil = nil, creator : String | Nil = nil, trackNumber : UInt64 | Nil = nil)
Adds a new track to this playlist.
- #annotate : String | Nil
- #annotate=(annotate : String | Nil)
- #attribution : Attribution | Nil
- #attribution=(attribution : Attribution | Nil)
-
#creator : String | Nil
The human-readable name of the creator of this playlist, if any.
-
#creator=(creator : String | Nil)
The human-readable name of the creator of this playlist, if any.
- #date : Time | Nil
- #date=(date : Time | Nil)
-
#each(& : Track -> ) : Nil
Loops through all of the tracks in this playlist, yielding a
Trackinstance for each one. -
#identifier : URI | Nil
A URI describing the canonical identifier of this playlist.
-
#identifier=(identifier : URI | Nil)
A URI describing the canonical identifier of this playlist.
-
#image : URI | Nil
A URI pointing to an image that can be displayed when a track has no artwork of its own.
-
#image=(image : URI | Nil)
A URI pointing to an image that can be displayed when a track has no artwork of its own.
-
#info : URI | Nil
A URI of a web page that provides more information about this playlist.
-
#info=(info : URI | Nil)
A URI of a web page that provides more information about this playlist.
-
#license : URI | Nil
A URI to a resource that provides information about the license this playlist is under.
-
#license=(license : URI | Nil)
A URI to a resource that provides information about the license this playlist is under.
- #links : Array(Link)
- #links=(links : Array(Link))
-
#location : URI | Nil
A URI of a web page that acts as the source for this playlist.
-
#location=(location : URI | Nil)
A URI of a web page that acts as the source for this playlist.
- #meta : Array(Meta)
- #meta=(meta : Array(Meta))
-
#title : String | Nil
The human-readable name title of this playlist, if any.
-
#title=(title : String | Nil)
The human-readable name title of this playlist, if any.
- #tracks : Array(Track)
-
#write(dest : String | Path, *, mode : String = "w", format : Format = Format::Xml) : Nil
Writes this
Playlistinstance to a file atdestin the givenformat. -
#write(io : IO, *, format : Format = Format::Xml) : Nil
Writes this
Playlistinstance toioin the givenformat. -
#write(*, format : Format = Format::Xml) : String
Writes this
Playlistinstance to a new String in the givenformat.
Constructor Detail
Creates a new Playlist instance. The new instance has no tracks
associated with it, and so at least one must be added before it can be
serialized.
Creates a new Playlist instance by reading data from io.
Creates a new Playlist instance by reading data from str.
Instance Method Detail
Adds a new track to this playlist.
The human-readable name of the creator of this playlist, if any. If this
is nil, then no <creator> element is emitted for the <playlist> element.
The human-readable name of the creator of this playlist, if any. If this
is nil, then no <creator> element is emitted for the <playlist> element.
Loops through all of the tracks in this playlist, yielding a Track
instance for each one.
A URI describing the canonical identifier of this playlist. If this is
nil, then no <identifier> element is emitted for the <playlist>
element.
A URI describing the canonical identifier of this playlist. If this is
nil, then no <identifier> element is emitted for the <playlist>
element.
A URI pointing to an image that can be displayed when a track has no
artwork of its own. If this is nil, then no <image> element is
emitted for the <playlist> element.
A URI pointing to an image that can be displayed when a track has no
artwork of its own. If this is nil, then no <image> element is
emitted for the <playlist> element.
A URI of a web page that provides more information about this playlist.
If this is nil, then no <info> element is emitted for the <playlist>
element.
A URI of a web page that provides more information about this playlist.
If this is nil, then no <info> element is emitted for the <playlist>
element.
A URI to a resource that provides information about the license this
playlist is under. If this is nil, then no <license> element is
emitted for the <playlist> element.
A URI to a resource that provides information about the license this
playlist is under. If this is nil, then no <license> element is
emitted for the <playlist> element.
A URI of a web page that acts as the source for this playlist.
If this is nil, then no <location> element is emitted for the <playlist>
element.
A URI of a web page that acts as the source for this playlist.
If this is nil, then no <location> element is emitted for the <playlist>
element.
The human-readable name title of this playlist, if any. If this is nil,
then no <title> element is emitted for the <playlist> element.
The human-readable name title of this playlist, if any. If this is nil,
then no <title> element is emitted for the <playlist> element.
Writes this Playlist instance to a file at dest in the given format.
The mode parameter is the same as for File#open. There must be at
least one track in this playlist, or this will raise an Error.
Writes this Playlist instance to io in the given format. There must
be at least one track in this playlist, or this will raise an Error.