Class: M3u8::PlaylistItem
- Inherits:
-
Object
- Object
- M3u8::PlaylistItem
- Extended by:
- M3u8
- Defined in:
- lib/m3u8/playlist_item.rb
Overview
PlaylistItem represents a set of EXT-X-STREAM-INF or EXT-X-I-FRAME-STREAM-INF attributes
Constant Summary collapse
- MISSING_CODEC_MESSAGE =
'Audio or video codec info should be provided.'
Constants included from M3u8
Instance Attribute Summary collapse
-
#audio ⇒ Object
Returns the value of attribute audio.
-
#audio_codec ⇒ Object
writeonly
Sets the attribute audio_codec.
-
#average_bandwidth ⇒ Object
Returns the value of attribute average_bandwidth.
-
#bandwidth ⇒ Object
Returns the value of attribute bandwidth.
-
#closed_captions ⇒ Object
Returns the value of attribute closed_captions.
-
#codecs ⇒ Object
Returns the value of attribute codecs.
-
#height ⇒ Object
Returns the value of attribute height.
-
#iframe ⇒ Object
Returns the value of attribute iframe.
-
#level ⇒ Object
Returns the value of attribute level.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#program_id ⇒ Object
Returns the value of attribute program_id.
-
#subtitles ⇒ Object
Returns the value of attribute subtitles.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#video ⇒ Object
Returns the value of attribute video.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ PlaylistItem
constructor
A new instance of PlaylistItem.
- #resolution ⇒ Object
- #to_s ⇒ Object
Methods included from M3u8
intialize_with_byterange, parse_attributes, parse_yes_no
Constructor Details
#initialize(params = {}) ⇒ PlaylistItem
Returns a new instance of PlaylistItem.
11 12 13 14 15 16 |
# File 'lib/m3u8/playlist_item.rb', line 11 def initialize(params = {}) self.iframe = false params.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#audio ⇒ Object
Returns the value of attribute audio.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def audio @audio end |
#audio_codec=(value) ⇒ Object
Sets the attribute audio_codec
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def audio_codec=(value) @audio_codec = value end |
#average_bandwidth ⇒ Object
Returns the value of attribute average_bandwidth.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def average_bandwidth @average_bandwidth end |
#bandwidth ⇒ Object
Returns the value of attribute bandwidth.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def bandwidth @bandwidth end |
#closed_captions ⇒ Object
Returns the value of attribute closed_captions.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def closed_captions @closed_captions end |
#codecs ⇒ Object
Returns the value of attribute codecs.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def codecs @codecs end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def height @height end |
#iframe ⇒ Object
Returns the value of attribute iframe.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def iframe @iframe end |
#level ⇒ Object
Returns the value of attribute level.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def level @level end |
#profile ⇒ Object
Returns the value of attribute profile.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def profile @profile end |
#program_id ⇒ Object
Returns the value of attribute program_id.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def program_id @program_id end |
#subtitles ⇒ Object
Returns the value of attribute subtitles.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def subtitles @subtitles end |
#uri ⇒ Object
Returns the value of attribute uri.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def uri @uri end |
#video ⇒ Object
Returns the value of attribute video.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def video @video end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/m3u8/playlist_item.rb', line 6 def width @width end |
Class Method Details
.parse(text) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/m3u8/playlist_item.rb', line 18 def self.parse(text) attributes = parse_attributes text resolution = parse_resolution attributes['RESOLUTION'] average = parse_average_bandwidth attributes['AVERAGE-BANDWIDTH'] = { program_id: attributes['PROGRAM-ID'], codecs: attributes['CODECS'], width: resolution[:width], height: resolution[:height], bandwidth: attributes['BANDWIDTH'].to_i, average_bandwidth: average, video: attributes['VIDEO'], audio: attributes['AUDIO'], uri: attributes['URI'], subtitles: attributes['SUBTITLES'], closed_captions: attributes['CLOSED-CAPTIONS'] } PlaylistItem.new end |
Instance Method Details
#resolution ⇒ Object
34 35 36 37 |
# File 'lib/m3u8/playlist_item.rb', line 34 def resolution return if width.nil? "#{width}x#{height}" end |
#to_s ⇒ Object
55 56 57 58 59 |
# File 'lib/m3u8/playlist_item.rb', line 55 def to_s validate m3u8_format end |