Class: Animoto::Manifests::Directing

Inherits:
Base
  • Object
show all
Defined in:
lib/animoto/manifests/directing.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#http_callback_format, #http_callback_url, #partner_metadata

Instance Method Summary collapse

Methods inherited from Base

#associated_job_class, associated_job_class, infer_content_type

Methods included from Support::ContentType

included

Constructor Details

#initialize(options = {}) ⇒ Manifests::Directing

Creates a new directing manifest.

Parameters:

  • options (Hash{Symbol=>Object}) (defaults to: {})

Options Hash (options):

  • :title (String)

    the title of this project

  • :pacing (String) — default: 'auto'

    the pacing for this project

  • :postroll (String, Animoto::Postroll)

    the postroll for this project

  • :http_callback_url (String)

    a URL to receive a callback when this job is done

  • :http_callback_format (String)

    the format of the callback



53
54
55
56
57
58
59
60
61
62
# File 'lib/animoto/manifests/directing.rb', line 53

def initialize options = {}
  super
  @title      = options[:title]
  @pacing     = options[:pacing]  || 'auto'
  @max_duration = options[:max_duration]
  @style      = options[:style]   || Animoto::Styles::ANIMOTO_ORIGINAL
  @postroll   = Animoto::Postroll.new(options[:postroll] || Animoto::Postroll::POWERED_BY_ANIMOTO)
  @visuals    = []
  @song       = nil
end

Instance Attribute Details

#max_durationObject

The maximum duration in seconds. Optional. #return [String]



24
25
26
# File 'lib/animoto/manifests/directing.rb', line 24

def max_duration
  @max_duration
end

#pacingString

The pacing, representing how quickly the visuals elements will be cycled. Valid values are ‘very_slow’, ‘slow’, ‘moderate’, ‘fast’, ‘very_fast’ and ‘auto’. Faster songs will naturally cycle through images faster than slower songs. The ‘moderate’ pacing is about 4 beats per image. With ‘auto’, Animoto’s cinematic artificial intelligence will decide what pacing will be best. The default pacing is ‘auto’.

Returns:

  • (String)


20
21
22
# File 'lib/animoto/manifests/directing.rb', line 20

def pacing
  @pacing
end

#postrollAnimoto::Postroll

The ‘postroll’ for this video. Postrolls are the short video ‘outro’ segements that play when the main video is finished.

Returns:



42
43
44
# File 'lib/animoto/manifests/directing.rb', line 42

def postroll
  @postroll
end

#songAssets::Song (readonly)

The song for this video.

Returns:



32
33
34
# File 'lib/animoto/manifests/directing.rb', line 32

def song
  @song
end

#styleString

The ‘style’ for this video. Available styles are listed in Styles. Your partner account might have different styles available from those listed.

Returns:

  • (String)


37
38
39
# File 'lib/animoto/manifests/directing.rb', line 37

def style
  @style
end

#titleString

The title of the video project.

Returns:

  • (String)


11
12
13
# File 'lib/animoto/manifests/directing.rb', line 11

def title
  @title
end

#visualsArray<Assets::Base,Assets::TitleCard> (readonly)

The array of visual objects in this manifest.

Returns:



28
29
30
# File 'lib/animoto/manifests/directing.rb', line 28

def visuals
  @visuals
end

Instance Method Details

#<<(asset) ⇒ self

Adds a visual/song to this manifest.

Parameters:

Returns:

  • (self)


127
128
129
130
# File 'lib/animoto/manifests/directing.rb', line 127

def << asset
  add_visual asset
  self
end

#add_footage(*args) ⇒ Assets::Footage

Adds Footage to this manifest.

Parameters:

  • args (Array<Object>)

    arguments sent to the initializer for the Footage

Returns:

See Also:



91
92
93
94
95
# File 'lib/animoto/manifests/directing.rb', line 91

def add_footage *args
  footage = Assets::Footage.new(*args)
  @visuals << footage
  footage
end

#add_image(*args) ⇒ Assets::Image

Adds an Image to this manifest.

Parameters:

  • args (Array<Object>)

    arguments sent to the initializer for the Image

Returns:

See Also:



80
81
82
83
84
# File 'lib/animoto/manifests/directing.rb', line 80

def add_image *args
  image = Assets::Image.new(*args)
  @visuals << image
  image
end

#add_song(*args) ⇒ Assets::Song

Adds a Song to this manifest. Right now, a manifest can only have one song. Adding a second replaces the first.

Parameters:

  • args (Array<Object>)

    arguments sent to the initializer for the Song

Returns:

See Also:



103
104
105
# File 'lib/animoto/manifests/directing.rb', line 103

def add_song *args
  @song = Assets::Song.new(*args)
end

#add_title_card(*args) ⇒ Assets::TitleCard

Adds a TitleCard to this manifest.

Parameters:

  • args (Array<Object>)

    arguments sent to the initializer for the TitleCard

Returns:

See Also:



69
70
71
72
73
# File 'lib/animoto/manifests/directing.rb', line 69

def add_title_card *args
  card = Assets::TitleCard.new(*args)
  @visuals << card
  card
end

#add_visual(asset) ⇒ void

This method returns an undefined value.

Adds a visual/song to this manifest.

Parameters:

Raises:

  • (ArgumentError)

    if the asset isn’t a Song, Image, Footage, or TitleCard



112
113
114
115
116
117
118
119
120
121
# File 'lib/animoto/manifests/directing.rb', line 112

def add_visual asset
  case asset
  when Animoto::Assets::Song
    @song = asset
  when Animoto::Assets::Base, Animoto::Assets::TitleCard
    @visuals << asset
  else
    raise ArgumentError
  end      
end

#to_hash(options = {}) ⇒ Hash{String=>Object}

Returns a representation of this manifest as a Hash.

Returns:

  • (Hash{String=>Object})

    the manifest as a Hash

Raises:

  • (ArgumentError)

    if a callback URL is specified but not the format



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/animoto/manifests/directing.rb', line 144

def to_hash options = {}
  hash = { 'directing_job' => { 'directing_manifest' => {} } }
  job  = hash['directing_job']
  add_callback_information job
   job
  manifest              = job['directing_manifest']
  manifest['style']     = style
  manifest['pacing']    = pacing if pacing
  manifest['fitting']   = {'type' => 'best_fit', 'max_duration' => @max_duration} if @max_duration
  manifest['postroll']  = postroll.to_hash if postroll
  manifest['title']     = title if title
  manifest['visuals']   = []
  visuals.each do |visual|
    manifest['visuals'] << visual.to_hash
  end
  manifest['song'] = song.to_hash if song
  hash
end