Module: Livelist::HLS
- Defined in:
- lib/livelist/hls/hls.rb,
lib/livelist/hls/pipeline.rb
Overview
Livelist::HLS
Defined Under Namespace
Classes: Pipeline
Class Method Summary collapse
- .current_time(playlist, seconds = 2) ⇒ Object
-
.finish(playlist) ⇒ Object
Finish the playlist with a endlist tag.
Class Method Details
.current_time(playlist, seconds = 2) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/livelist/hls/hls.rb', line 6 def self.current_time(playlist, seconds = 2) lines = File .readlines(playlist) .select { |line| line =~ /EXTINF:[0-9]/ } lines.length * seconds end |
.finish(playlist) ⇒ Object
Finish the playlist with a endlist tag
16 17 18 19 20 21 22 23 |
# File 'lib/livelist/hls/hls.rb', line 16 def self.finish(playlist) file = File.read(playlist) content = file.gsub(/#EXT-X-PLAYLIST-TYPE:EVENT/, '#EXT-X-PLAYLIST-TYPE:VOD') File.open(playlist, 'w') { |f| f.puts content} File.open(playlist, 'a') do |file| file.puts '#EXT-X-ENDLIST' end end |