Class: Pageflow::AudioFile

Inherits:
ApplicationRecord show all
Includes:
MediaEncodingStateMachine, UploadableFile
Defined in:
app/models/pageflow/audio_file.rb

Instance Method Summary collapse

Methods included from MediaEncodingStateMachine

#failed?, #ready?, #retry!, #retryable?

Methods included from UploadableFile

#attachment, #attachment=, #attachment_default_url, #attachment_styles, #attachments_for_export, #basename, #can_upload?, #direct_upload_config, #extension, #failed?, #file_name, #publish!, #ready?, #retryable?, #url

Methods included from ReusableFile

#attachments_for_export, #basename, #cache_key, #can_upload?, #extension, #failed?, #file_name, #file_type, #nested_files, #original_url, #parent_allows_type_for_nesting, #parent_belongs_to_same_entry, #publish!, #ready?, #retry!, #retryable?, #url

Instance Method Details

#attachment_s3_urlObject



19
20
21
# File 'app/models/pageflow/audio_file.rb', line 19

def attachment_s3_url
  "s3://#{File.join(attachment.bucket_name, attachment.path)}"
end

#m4aObject



23
24
25
# File 'app/models/pageflow/audio_file.rb', line 23

def m4a
  ZencoderAttachment.new(self, "audio.m4a")
end

#meta_data_attributes=(attributes) ⇒ Object



39
40
41
# File 'app/models/pageflow/audio_file.rb', line 39

def (attributes)
  self.attributes = attributes.symbolize_keys.slice(:format, :duration_in_ms)
end

#mp3Object



27
28
29
# File 'app/models/pageflow/audio_file.rb', line 27

def mp3
  ZencoderAttachment.new(self, "audio.mp3")
end

#oggObject



31
32
33
# File 'app/models/pageflow/audio_file.rb', line 31

def ogg
  ZencoderAttachment.new(self, "audio.ogg")
end

#output_definitionObject



35
36
37
# File 'app/models/pageflow/audio_file.rb', line 35

def output_definition
  ZencoderAudioOutputDefinition.new(self)
end

#post_process_encoded_filesObject



43
44
45
46
47
# File 'app/models/pageflow/audio_file.rb', line 43

def post_process_encoded_files
  self.peak_data = URI.parse(ogg.url(default_protocol: 'https'))
rescue OpenURI::HTTPError
  throw(:halt, :pending)
end