Sha256: ca4353876d68791a2d2e975bb98ae7f0f2c3bfc37b04efb877ea7b2a4853c8e9
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
module M3u8 # Playlist represents an m3u8 playlist, it can be a master playlist or a set # of media segments class Playlist attr_accessor :items, :version, :cache, :target, :sequence, :type def initialize(options = {}) assign_options options self.items = [] end def self.codecs(options = {}) item = PlaylistItem.new options item.codecs end def self.read(input) reader = Reader.new reader.read input end def write(output) writer = Writer.new output writer.write self end def master? return false if playlist_size == 0 && segment_size == 0 playlist_size > 0 end def to_s output = StringIO.open write output output.string end def valid? return false if playlist_size > 0 && segment_size > 0 true end def duration duration = 0.0 items.each do |item| duration += item.duration if item.is_a?(M3u8::SegmentItem) end duration end private def assign_options(options) options = { version: 3, sequence: 0, cache: true, target: 10 }.merge options self.version = options[:version] self.sequence = options[:sequence] self.cache = options[:cache] self.target = options[:target] self.type = options[:type] end def playlist_size items.select { |item| item.is_a?(PlaylistItem) }.size end def segment_size items.select { |item| item.is_a?(SegmentItem) }.size end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
m3u8-0.4.0 | lib/m3u8/playlist.rb |