Proof-of-concept Ruby/GStreamer application that could be used to query total duration of an audio file, current position and peform seeking.
Please note that in certain cases (e.g. some VBR encodings), total duration can change. In that case, GStreamer emits signal of type Gst::Message::Type::DURATION - this application doesn't handle that. In most (but not all!) cases, GStreamer would emit one at least once, but you cannot rely on that. Just perform querying after changing the state of the pipeline. Remember that you can query duration only after prerolling (in PAUSED or PLAYING state).
$ ruby duration.rb AUDIO_FILE_NAME