Method: EmbeddedFile::Loader#load_audio

Defined in:
lib/asker/loader/embedded_file/loader.rb

#load_audio(value, localdir) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/asker/loader/embedded_file/loader.rb', line 42

def load_audio(value, localdir)
  filepath = File.join(localdir, value)
  output = {}
  output[:text] = '<audio controls><source src="@@PLUGINFILE@@/' + File.basename(filepath) \
                  + '">Your browser does not support the audio tag.</audio>'
  output[:file] = '<file name="' + File.basename(filepath) \
                  + '" path="/" encoding="base64">' \
                  + Base64.strict_encode64(File.open(filepath, "rb").read) \
                  + "</file>"
  output[:type] = :audio
  output[:url] = value
  output
end