Class: DragonflyAudio::Analysers::AudioProperties
- Inherits:
-
Object
- Object
- DragonflyAudio::Analysers::AudioProperties
- Defined in:
- lib/dragonfly_audio/analysers/audio_properties.rb
Constant Summary collapse
- TAGS =
%w[title artist album year track genre comment].freeze
- AUDIO_PROPS =
%w[length_in_seconds length_in_milliseconds bitrate channels sample_rate].freeze
Instance Method Summary collapse
Instance Method Details
#call(content) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dragonfly_audio/analysers/audio_properties.rb', line 11 def call(content) return {} unless content.ext return {} unless SUPPORTED_FORMATS.include?(content.ext.downcase) res = {} TagLib::FileRef.open(content.path) do |fileref| return if fileref.null? TAGS.each { |n| res[n] = fileref.tag.send(n) } AUDIO_PROPS.each { |n| res[n] = fileref.audio_properties.send(n) } end res["length"] = res["length_in_seconds"] res end |