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.
-
#independent_segments ⇒ Object
Returns the value of attribute independent_segments.
-
#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.
9 10 11 12 |
# File 'lib/m3u8/playlist.rb', line 9 def initialize( = {}) self.items = [] end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def cache @cache end |
#iframes_only ⇒ Object
Returns the value of attribute iframes_only.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def iframes_only @iframes_only end |
#independent_segments ⇒ Object
Returns the value of attribute independent_segments.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def independent_segments @independent_segments end |
#items ⇒ Object
Returns the value of attribute items.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def items @items end |
#sequence ⇒ Object
Returns the value of attribute sequence.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def sequence @sequence end |
#target ⇒ Object
Returns the value of attribute target.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/m3u8/playlist.rb', line 6 def version @version end |
Class Method Details
.codecs(options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/m3u8/playlist.rb', line 14 def self.codecs( = {}) item = PlaylistItem.new item.codecs end |
.read(input) ⇒ Object
19 20 21 22 |
# File 'lib/m3u8/playlist.rb', line 19 def self.read(input) reader = Reader.new reader.read input end |
Instance Method Details
#duration ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/m3u8/playlist.rb', line 45 def duration duration = 0.0 items.each do |item| duration += item.duration if item.is_a?(M3u8::SegmentItem) end duration end |
#master? ⇒ Boolean
29 30 31 32 |
# File 'lib/m3u8/playlist.rb', line 29 def master? return false if playlist_size == 0 && segment_size == 0 playlist_size > 0 end |
#to_s ⇒ Object
34 35 36 37 38 |
# File 'lib/m3u8/playlist.rb', line 34 def to_s output = StringIO.open write(output) output.string end |
#valid? ⇒ Boolean
40 41 42 43 |
# File 'lib/m3u8/playlist.rb', line 40 def valid? return false if playlist_size > 0 && segment_size > 0 true end |
#write(output) ⇒ Object
24 25 26 27 |
# File 'lib/m3u8/playlist.rb', line 24 def write(output) writer = Writer.new(output) writer.write(self) end |