class M3U8::MapItem
- M3U8::MapItem
- Reference
- Object
Overview
MapItem represents an EXT-X-MAP tag in an HLS playlist.
The EXT-X-MAP tag (defined in RFC 8216, Section 4.3.2.5)
specifies how to obtain the Media Initialization Section, which is required to parse the Media Segments.
For example, a valid EXT-X-MAP tag might look like:
#EXT-X-MAP:URI="frelo/prog_index.m3u8",BYTERANGE="4500@600"
The MapItem class stores the following properties:
#uri(String): the URI for the Media Initialization Section.#byterange(ByteRange): the byte range indicating which part of the resource to use.
Included Modules
- M3U8::Concern
Extended Modules
- M3U8::Concern
Defined in:
m3u8/map_item.crConstructors
-
.new(params : NamedTuple = NamedTuple.new)
Constructs a new
MapIteminstance from a NamedTuple of parameters. -
.new(uri : String, byterange = nil)
Initializes a new
MapIteminstance.
Class Method Summary
-
.parse(text)
Parses a string representing an
EXT-X-MAPtag and returns a newMapIteminstance.
Instance Method Summary
-
#byterange : ByteRange
The byte range indicating which part of the resource to use.
-
#byterange=(byterange : ByteRange)
The byte range indicating which part of the resource to use.
-
#to_s
Returns the string representation of the
EXT-X-MAPtag. -
#uri : String
The URI for the Media Initialization Section.
-
#uri=(uri : String)
The URI for the Media Initialization Section.
Constructor Detail
Constructs a new MapItem instance from a NamedTuple of parameters.
The NamedTuple can include the following keys:
:uri(String): the URI for the initialization section.:byterange(can be a Hash, a NamedTuple, aByteRangeinstance, or a String like "4500@600").
Examples:
options = {
uri: "frelo/prog_index.m3u8",
byterange: {length: 4500, start: 600},
}
MapItem.new(options)
# => #<M3U8::MapItem:0x7adc917c08a0
# @byterange=#<M3U8::ByteRange:0x7adc91795d50 @length=4500, @start=600>,
# @uri="frelo/prog_index.m3u8">
options = {
uri: "frelo/prog_index.m3u8",
byterange: ByteRange.new(length: 4500, start: 600),
}
MapItem.new(options)
# => #<M3U8::MapItem:0x7adc917c01e0
# @byterange=#<M3U8::ByteRange:0x7adc91795c60 @length=4500, @start=600>,
# @uri="frelo/prog_index.m3u8">
options = {
uri: "frelo/prog_index.m3u8",
byterange: "4500@600",
}
MapItem.new(options)
# => #<M3U8::MapItem:0x7adc917c1ba0
# @byterange=#<M3U8::ByteRange:0x7adc91795b70 @length=4500, @start=600>,
# @uri="frelo/prog_index.m3u8">
Initializes a new MapItem instance.
Accepts a #uri as the first parameter and an optional #byterange parameter,
which is passed to ByteRange.parse.
Examples:
uri = "frelo/prog_index.m3u8"
byterange = "4500@600"
MapItem.new(uri)
MapItem.new(uri: uri)
# => #<M3U8::MapItem:0x789a5325c760
# @byterange=#<M3U8::ByteRange:0x789a5322e8a0 @length=nil, @start=nil>,
# @uri="frelo/prog_index.m3u8">
MapItem.new(uri, byterange)
MapItem.new(uri: uri, byterange: byterange)
# => #<M3U8::MapItem:0x789a5325c0a0
# @byterange=#<M3U8::ByteRange:0x789a5322e7b0 @length=4500, @start=600>,
# @uri="frelo/prog_index.m3u8">
Class Method Detail
Parses a string representing an EXT-X-MAP tag and returns a new MapItem instance.
The method extracts attributes from the tag line using parse_attributes and
converts the #byterange value using ByteRange.parse.
Example:
text = %(#EXT-X-MAP:URI="frelo/prog_index.m3u8",BYTERANGE="4500@600")
MapItem.parse(text)
# => #<M3U8::MapItem:0x79d016ab9f60
# @byterange=#<M3U8::ByteRange:0x79d016a8ee40 @length=4500, @start=600>,
# @uri="frelo/prog_index.m3u8">
Instance Method Detail
The byte range indicating which part of the resource to use.
Returns the string representation of the EXT-X-MAP tag.
It concatenates the formatted #uri and #byterange attributes, separated by commas,
and prefixes the result with #EXT-X-MAP:.
Example:
options = {
uri: "frelo/prog_index.m3u8",
byterange: "4500@600",
}
MapItem.new(options).to_s
# => #EXT-X-MAP:URI="frelo/prog_index.m3u8",BYTERANGE="4500@600"