class M3U8::DateRangeItem
- M3U8::DateRangeItem
- Reference
- Object
Overview
DateRangeItem
encapsulates an EXT-X-DATERANGE
tag in an HLS playlist.
As defined in RFC 8216, Section 4.3.2.7,
the XT-X-DATERANGE
tag is used to associate a specific date range with a collection of
attribute/value pairs. It is typically used for signaling events
such as ad insertion, content segmentation, or SCTE-35 splice points.
Example tag format:
#EXT-X-DATERANGE:ID="...",CLASS="...",START-DATE="...",END-DATE="...",...
The EXT-X-DATERANGE
tag stores the following attributes:
- ID (required): A unique identifier for the date range.
- CLASS (optional): A client-defined category for the date range.
- START-DATE (required): The starting date/time in ISO-8601 format.
- END-DATE (optional): The ending date/time in ISO-8601 format.
- DURATION (optional): The duration of the date range, in seconds.
- PLANNED-DURATION (optional): The expected duration, in seconds.
- SCTE35-CMD, SCTE35-OUT, SCTE35-IN (optional): Attributes carrying SCTE-35 splice data.
- END-ON-NEXT (optional): A boolean flag that, if true, outputs
"END-ON-NEXT=YES"
. - Client-specific attributes (optional): Any additional attributes with keys starting with
X-
.
Included Modules
- M3U8::Concern
Extended Modules
- M3U8::Concern
Defined in:
m3u8/date_range_item.crConstructors
-
.new(params : NamedTuple = NamedTuple.new)
Creates a new
DateRangeItem
from a NamedTuple of parameters. -
.new(id : Nil | String = nil, start_date : Nil | String = nil, class_name : Nil | String = nil, end_date : Nil | String = nil, duration : Float64 | Nil = nil, planned_duration : Float64 | Nil = nil, scte35_cmd : Nil | String = nil, scte35_out : Nil | String = nil, scte35_in : Nil | String = nil, end_on_next : Bool | Nil = nil, client_attributes = nil)
Initializes a new
DateRangeItem
instance.
Class Method Summary
-
.parse(text : String)
Parses a complete
EXT-X-DATERANGE
tag line and returns a newDateRangeItem
.
Instance Method Summary
-
#class_name : String | Nil
A client-defined category for the date range.
-
#class_name=(class_name : String | Nil)
A client-defined category for the date range.
-
#client_attributes : ClientAttributeType
Client-specific attributes (those whose keys start with
X-
). -
#client_attributes=(client_attributes : ClientAttributeType)
Client-specific attributes (those whose keys start with
X-
). -
#duration : Float64 | Nil
The duration in seconds.
-
#duration=(duration : Float64 | Nil)
The duration in seconds.
-
#end_date : String | Nil
The end date/time in ISO-8601 format.
-
#end_date=(end_date : String | Nil)
The end date/time in ISO-8601 format.
-
#end_on_next : Bool | Nil
A boolean flag; if true, outputs
"END-ON-NEXT=YES"
. -
#end_on_next=(end_on_next : Bool | Nil)
A boolean flag; if true, outputs
"END-ON-NEXT=YES"
. -
#id : String | Nil
A unique identifier for the date range.
-
#id=(id : String | Nil)
A unique identifier for the date range.
-
#planned_duration : Float64 | Nil
The expected duration in seconds.
-
#planned_duration=(planned_duration : Float64 | Nil)
The expected duration in seconds.
-
#scte35_cmd : String | Nil
SCTE-35 splice information.
-
#scte35_cmd=(scte35_cmd : String | Nil)
SCTE-35 splice information.
-
#scte35_in : String | Nil
SCTE-35 splice information.
-
#scte35_in=(scte35_in : String | Nil)
SCTE-35 splice information.
-
#scte35_out : String | Nil
SCTE-35 splice information.
-
#scte35_out=(scte35_out : String | Nil)
SCTE-35 splice information.
-
#start_date : String | Nil
The start date/time in ISO-8601 format.
-
#start_date=(start_date : String | Nil)
The start date/time in ISO-8601 format.
-
#to_s
Returns the string representation of the
EXT-X-DATERANGE
tag.
Constructor Detail
Creates a new DateRangeItem
from a NamedTuple of parameters.
The NamedTuple keys should match the attribute names (using symbols):
#id
#start_date
#class_name
#end_date
#duration
#planned_duration
,#scte35_cmd
#scte35_out
#scte35_in
#end_on_next
#client_attributes
.
Examples:
options = {
id: "test_id",
start_date: "2014-03-05T11:15:00Z",
class_name: "test_class",
end_date: "2014-03-05T11:16:00Z",
duration: 60.1,
planned_duration: 59.993,
scte35_out: "0xFC002F0000000000FF0",
scte35_in: "0xFC002F0000000000FF1",
scte35_cmd: "0xFC002F0000000000FF2",
end_on_next: true,
client_attributes: {"X-CUSTOM" => 45.3},
}
DateRangeItem.new(options)
# => #<M3U8::DateRangeItem:0x7d6bff706f00
# @class_name="test_class",
# @client_attributes={"X-CUSTOM" => 45.3},
# @duration=60.1,
# @end_date="2014-03-05T11:16:00Z",
# @end_on_next=true,
# @id="test_id",
# @planned_duration=59.993,
# @scte35_cmd="0xFC002F0000000000FF2",
# @scte35_in="0xFC002F0000000000FF1",
# @scte35_out="0xFC002F0000000000FF0",
# @start_date="2014-03-05T11:15:00Z">
Initializes a new DateRangeItem
instance.
The instance variables are directly set from the constructor arguments.
Example:
DateRangeItem.new
Class Method Detail
Parses a complete EXT-X-DATERANGE
tag line and returns a new DateRangeItem
.
The tag line is expected to follow the format defined in RFC 8216:
#EXT-X-DATERANGE:ID="...",CLASS="...",START-DATE="...",END-DATE="...",...
Examples:
text = %(#EXT-X-DATERANGE:ID="test_id",CLASS="test_class",\
START-DATE="2014-03-05T11:15:00Z",END-DATE="2014-03-05T11:16:00Z",\
DURATION=60.1,PLANNED-DURATION=59.993,X-CUSTOM=45.3,\
SCTE35-CMD=0xFC002F0000000000FF2,SCTE35-OUT=0xFC002F0000000000FF0,\
SCTE35-IN=0xFC002F0000000000FF1,END-ON-NEXT=YES)
DateRangeItem.parse(text)
# => #<M3U8::DateRangeItem:0x7d6bff706f00
# @class_name="test_class",
# @client_attributes={"X-CUSTOM" => 45.3},
# @duration=60.1,
# @end_date="2014-03-05T11:16:00Z",
# @end_on_next=true,
# @id="test_id",
# @planned_duration=59.993,
# @scte35_cmd="0xFC002F0000000000FF2",
# @scte35_in="0xFC002F0000000000FF1",
# @scte35_out="0xFC002F0000000000FF0",
# @start_date="2014-03-05T11:15:00Z">
Instance Method Detail
Client-specific attributes (those whose keys start with X-
).
Client-specific attributes (those whose keys start with X-
).
Returns the string representation of the EXT-X-DATERANGE
tag.
The output is constructed by concatenating all formatted attribute strings
(e.g. ID, CLASS, START-DATE, etc.) separated by commas, and prefixed with
#EXT-X-DATERANGE:
.
Example:
options = {
id: "test_id",
start_date: "2014-03-05T11:15:00Z",
class_name: "test_class",
end_date: "2014-03-05T11:16:00Z",
duration: 60.1,
planned_duration: 59.993,
scte35_out: "0xFC002F0000000000FF0",
scte35_in: "0xFC002F0000000000FF1",
scte35_cmd: "0xFC002F0000000000FF2",
end_on_next: true,
client_attributes: {"X-CUSTOM" => 45.3},
}
DateRangeItem.new(options).to_s
# => #(EXT-X-DATERANGE:ID="test_id",CLASS="test_class",START-DATE="2014-03-05T11:15:00Z",
# END-DATE="2014-03-05T11:16:00Z",DURATION=60.1,PLANNED-DURATION=59.993,
# X-CUSTOM="45.3",SCTE35-CMD=0xFC002F0000000000FF2,
# SCTE35-OUT=0xFC002F0000000000FF0,SCTE35-IN=0xFC002F0000000000FF1,
# END-ON-NEXT=YES)