diff --git a/app/uploaders/binda/audio/audio_uploader.rb b/app/uploaders/binda/audio/audio_uploader.rb index b3a2a231..ce73ceb8 100644 --- a/app/uploaders/binda/audio/audio_uploader.rb +++ b/app/uploaders/binda/audio/audio_uploader.rb @@ -20,6 +20,9 @@ def register_details if file && model model.content_type = file.content_type if file.content_type model.file_size = file.size + TagLib::FileRef.open(file.file.path) do |file| + model.duration = file.audio_properties.length + end end end diff --git a/binda.gemspec b/binda.gemspec index 0cb91238..60b82828 100644 --- a/binda.gemspec +++ b/binda.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |s| s.add_dependency "kaminari", "~> 1.0" s.add_dependency "friendly_id", ">= 5.1", "< 5.4" s.add_dependency "bourbon", "4.3.4" + s.add_dependency "taglib-ruby" ">=1.1.0" # DEVELOPMENT GEMS