Method: Pageflow::FilesHelper#file_duration

Defined in:
app/helpers/pageflow/files_helper.rb

#file_duration(file) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/pageflow/files_helper.rb', line 18

def file_duration(file)
  if file.duration_in_ms
    total_seconds = file.duration_in_ms / 1000
    seconds = total_seconds % 60
    minutes = (total_seconds / 60) % 60
    hours = total_seconds / (60 * 60)

    format("%02d:%02d:%02d", hours, minutes, seconds)
  else
    "-"
  end
end