Class: Editframe::VideoBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/editframe/video/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ VideoBuilder

Returns a new instance of VideoBuilder.



6
7
8
9
10
# File 'lib/editframe/video/builder.rb', line 6

def initialize(options = {})
  @form = {}
  @layers = []
  @options = options || { background_color: 'black', resolution: '700x700', duration: 10 }
end

Instance Attribute Details

#layersObject (readonly)

Returns the value of attribute layers.



4
5
6
# File 'lib/editframe/video/builder.rb', line 4

def layers
  @layers
end

Instance Method Details

#add_audio(source, options = {}) ⇒ Object



12
13
14
15
16
# File 'lib/editframe/video/builder.rb', line 12

def add_audio(source, options = {})
  layer = add_layer({ :type => 'audio', **options })
  add_asset(layer[:id], source)
  layer
end

#add_image(source, options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/editframe/video/builder.rb', line 18

def add_image(source, options = {})
  layer = add_layer({ :type => 'image', **options })
  add_asset(layer[:id], source)
  layer
end

#add_text(text, options = {}) ⇒ Object



24
25
26
27
# File 'lib/editframe/video/builder.rb', line 24

def add_text(text, options = {})
  layer = add_layer({ :type => 'waveform', :text => text, **options })
  layer
end

#add_video(source, options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/editframe/video/builder.rb', line 29

def add_video(source, options = {})
  layer = add_layer({ :type => 'video', **options })
  add_asset(layer[:id], source)
  layer
end

#add_waveform(options = {}) ⇒ Object



35
36
37
38
# File 'lib/editframe/video/builder.rb', line 35

def add_waveform(options = {})
  layer = add_layer({ :type => 'waveform', **options })
  layer
end

#encodeObject



40
41
42
43
# File 'lib/editframe/video/builder.rb', line 40

def encode
  @form[:config] = Faraday::ParamPart.new(generate_config, 'application/json')
  Editframe::Video.encode(@form)
end