Class: Video

Inherits:
Document
  • Object
show all
Defined in:
app/models/video.rb

Instance Method Summary collapse

Methods inherited from Document

#format, lookup_subtype_class, #mime_type, #mime_type_type_sym, new

Instance Method Details

#as_json(options = nil) ⇒ Object

JSON, special edition for video files



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/video.rb', line 18

def as_json(options = nil)
  {
    :id => id,
    :title => title,
    :description => description,
    :author => author.name,
    :poster => URI.join(options[:helper].root_url, file.url(:poster)).to_s,
    :sources => [
      { type: Mime::WEBM.to_s, src: URI.join(options[:helper].root_url, file.url(:webm)).to_s },
      { type: Mime::MP4.to_s,  src: URI.join(options[:helper].root_url, file.url(:mp4)).to_s },
      { type: Mime::FLV.to_s,  src: URI.join(options[:helper].root_url, file.url(:flv)).to_s }
    ]
  }
end