class Qwik::Media
Public Class Methods
new(site, name)
click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 241 def initialize(site, name) @site = site @table = [] @msg = nil @name = name @param = {} @param[:url] = nil @param[:width] = 320 # default @param[:height] = 240 @hash_delim = [':'] @table_delim = ['|', ','] end
Public Instance Methods
generate_file()
click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 281 def generate_file smil = make_smil.format_xml.page_to_xml @site.attach.put(@name+'.smil', smil, true) end
make_smil()
click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 286 def make_smil g = Generator.new time = 0 par = [] @table.each {|tab| dur = (tab[:cend] - tab[:cbegin]).to_i ar = [{'region'=>'v'}, {'begin'=>"#{time}s"}, {'src'=>tab[:url]}] ar << {'clip-begin'=>tab[:cbegin]} if tab[:cbegin] ar << {'clip-end'=>tab[:cend]} if tab[:cend] par << g.video(ar) time += dur } g.smil(:xmlns=>'http://www.w3.org/2001/SMIL20/Language', 'xmlns:rn'=>'http://features.real.com/2001/SMIL20/Extensions'){[ g.head{ g.layout{[ g.make('root-layout', {'width'=>@param[:width]}, {'height'=>@param[:height]}), g.region({'id'=>'v'}, {'fit'=>'meet'}), ]} }, g.body{ g.par{par} } ]} end
parse(msg)
click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 254 def parse(msg) @msg = msg lines = msg.split(/\n/) lines.each {|line| firstchar = line[0, 1] if @table_delim.include?(firstchar) ar = line.split(firstchar) ar.shift # null cbegin = cend = msg = nil cbegin = VideoTime.new(ar.shift) if ! ar.empty? cend = VideoTime.new(ar.shift) if ! ar.empty? msg = ar.shift if ! ar.empty? if @param[:url] && cbegin && cend @table << {:url=>@param[:url], :cbegin=>cbegin, :cend=>cend, :msg=>msg} end next end if @hash_delim.include?(firstchar) ar = line.split(firstchar, 3) ar.shift # null name = ar.shift if ! ar.empty? @param[name.intern] = ar.shift if ! ar.empty? end } end
to_xml()
click to toggle source
# File vendor/qwik/lib/qwik/act-media.rb, line 315 def to_xml table = [] table << [:tr, [:td, 'IN'], [:td, 'OUT'], [:td, 'MSG'] ] @table.each {|tab| tr = [] tr << [:td, tab[:cbegin].to_s] tr << [:td, tab[:cend].to_s] tr << [:td, tab[:msg].to_s] if tab[:msg] table << [:tr, *tr] } [:div, {:class=>'box'}, [:table, *table], [:p, [:a, {:href=>".attach/#{@name}.smil"}, @name]]] end