如何获得使用Qt 5.1的一首歌的长度是多少? [英] How to get length of a song using Qt 5.1?
问题描述
我怎样才能得到一首歌曲的Qt中5.1 API的长度是多少?我想我可以使用长度
元数据读取它,但我不知道这是否将元数据可用于所有音频文件。
How can I get the length of a song in Qt 5.1 API? I think I can read it using Length
metadata but I'm not sure if this metadata will be available for all audio files.
推荐答案
您似乎在寻找持续时间
属性。
这将是QML的解决方案:
This would be the QML solution:
这个属性保存的是媒体的持续时间以毫秒为单位。
This property holds the duration of the media in milliseconds.
如果媒体不具有固定持续时间(例如实时流),这将是0
If the media doesn't have a fixed duration (a live stream for example) this will be 0.
这将是C ++的解决方案:
This would be the C++ solution:
qint64 QAudioBuffer ::时间()const的
返回音频的持续时间在此缓冲液中,以微秒
Returns the duration of audio in this buffer, in microseconds.
此取决于/升格式(),和frameCount()
This depends on the /l format(), and the frameCount().
这篇关于如何获得使用Qt 5.1的一首歌的长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!