You seem to be looking for the duration
property.
This would be the QML solution:
This property holds the duration of the media in milliseconds.
If the media doesn't have a fixed duration (a live stream for example) this will be 0.
This would be the C++ solution:
qint64 QAudioBuffer::duration() const
Returns the duration of audio in this buffer, in microseconds.
This depends on the /l format(), and the frameCount().