Class: M3u8::MediaItem
Overview
MediaItem represents a set of EXT-X-MEDIA attributes
Constant Summary
Constants included
from M3u8
VERSION
Instance Attribute Summary collapse
-
#assoc_language ⇒ String, ...
-
#autoselect ⇒ String, ...
-
#bit_depth ⇒ String, ...
-
#channels ⇒ String, ...
-
#characteristics ⇒ String, ...
-
#default ⇒ String, ...
-
#forced ⇒ String, ...
-
#group_id ⇒ String, ...
-
#instream_id ⇒ String, ...
-
#language ⇒ String, ...
-
#name ⇒ String, ...
-
#sample_rate ⇒ String, ...
-
#stable_rendition_id ⇒ String, ...
-
#type ⇒ String, ...
-
#uri ⇒ String, ...
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from M3u8
initialize_with_byterange, parse_attributes, parse_float, parse_int, parse_yes_no, to_yes_no
#boolean_format, #decimal_format, #quoted_format, #unquoted_format
#as_json, serialize, #to_h, #to_json
Constructor Details
#initialize(params = {}) ⇒ MediaItem
Returns a new instance of MediaItem.
31
32
33
34
35
|
# File 'lib/m3u8/media_item.rb', line 31
def initialize(params = {})
params.each do |key, value|
instance_variable_set("@#{key}", value)
end
end
|
Instance Attribute Details
#assoc_language ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def assoc_language
@assoc_language
end
|
#autoselect ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def autoselect
@autoselect
end
|
#bit_depth ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def bit_depth
@bit_depth
end
|
#channels ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def channels
@channels
end
|
#characteristics ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def characteristics
@characteristics
end
|
#default ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def default
@default
end
|
#forced ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def forced
@forced
end
|
#group_id ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def group_id
@group_id
end
|
#instream_id ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def instream_id
@instream_id
end
|
#language ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def language
@language
end
|
#name ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def name
@name
end
|
#sample_rate ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def sample_rate
@sample_rate
end
|
#stable_rendition_id ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def stable_rendition_id
@stable_rendition_id
end
|
#type ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def type
@type
end
|
#uri ⇒ String, ...
25
26
27
|
# File 'lib/m3u8/media_item.rb', line 25
def uri
@uri
end
|
Class Method Details
Parse an EXT-X-MEDIA tag.
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/m3u8/media_item.rb', line 40
def self.parse(text)
attributes = parse_attributes(text)
options = { type: attributes['TYPE'],
group_id: attributes['GROUP-ID'],
language: attributes['LANGUAGE'],
assoc_language: attributes['ASSOC-LANGUAGE'],
name: attributes['NAME'],
autoselect: parse_yes_no(attributes['AUTOSELECT']),
default: parse_yes_no(attributes['DEFAULT']),
forced: parse_yes_no(attributes['FORCED']),
uri: attributes['URI'],
instream_id: attributes['INSTREAM-ID'],
characteristics: attributes['CHARACTERISTICS'],
channels: attributes['CHANNELS'],
stable_rendition_id:
attributes['STABLE-RENDITION-ID'],
bit_depth: parse_int(attributes['BIT-DEPTH']),
sample_rate: parse_int(attributes['SAMPLE-RATE']) }
MediaItem.new(options)
end
|
Instance Method Details
#to_s ⇒ String
Render as an m3u8 EXT-X-MEDIA tag.
63
64
65
|
# File 'lib/m3u8/media_item.rb', line 63
def to_s
"#EXT-X-MEDIA:#{formatted_attributes.join(',')}"
end
|