Class: M3u8::Playlist
- Inherits:
-
Object
- Object
- M3u8::Playlist
- Defined in:
- lib/m3u8/playlist.rb
Overview
Playlist represents an m3u8 playlist, it can be a master playlist or a set of media segments
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#iframes_only ⇒ Object
Returns the value of attribute iframes_only.
-
#items ⇒ Object
Returns the value of attribute items.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(options = {}) ⇒ Playlist
constructor
A new instance of Playlist.
- #master? ⇒ Boolean
- #to_s ⇒ Object
- #valid? ⇒ Boolean
- #write(output) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Playlist
Returns a new instance of Playlist.
8 9 10 11 |
# File 'lib/m3u8/playlist.rb', line 8 def initialize( = {}) self.items = [] end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
5 6 7 |
# File 'lib/m3u8/playlist.rb', line 5 def cache @cache end |
#iframes_only ⇒ Object
Returns the value of attribute iframes_only.
5 6 7 |
# File 'lib/m3u8/playlist.rb', line 5 def iframes_only @iframes_only end |
#items ⇒ Object
Returns the value of attribute items.
5 6 7 |
# File 'lib/m3u8/playlist.rb', line 5 def items @items end |
#sequence ⇒ Object
Returns the value of attribute sequence.
5 6 7 |
# File 'lib/m3u8/playlist.rb', line 5 def sequence @sequence end |
#target ⇒ Object
Returns the value of attribute target.
5 6 7 |
# File 'lib/m3u8/playlist.rb', line 5 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/m3u8/playlist.rb', line 5 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/m3u8/playlist.rb', line 5 def version @version end |
Class Method Details
.codecs(options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/m3u8/playlist.rb', line 13 def self.codecs( = {}) item = PlaylistItem.new item.codecs end |
.read(input) ⇒ Object
18 19 20 21 |
# File 'lib/m3u8/playlist.rb', line 18 def self.read(input) reader = Reader.new reader.read input end |
Instance Method Details
#duration ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/m3u8/playlist.rb', line 44 def duration duration = 0.0 items.each do |item| duration += item.duration if item.is_a?(M3u8::SegmentItem) end duration end |
#master? ⇒ Boolean
28 29 30 31 |
# File 'lib/m3u8/playlist.rb', line 28 def master? return false if playlist_size == 0 && segment_size == 0 playlist_size > 0 end |
#to_s ⇒ Object
33 34 35 36 37 |
# File 'lib/m3u8/playlist.rb', line 33 def to_s output = StringIO.open write output output.string end |
#valid? ⇒ Boolean
39 40 41 42 |
# File 'lib/m3u8/playlist.rb', line 39 def valid? return false if playlist_size > 0 && segment_size > 0 true end |
#write(output) ⇒ Object
23 24 25 26 |
# File 'lib/m3u8/playlist.rb', line 23 def write(output) writer = Writer.new output writer.write self end |