我正在尝试使用QAudioDecoder类来解码.wav文件。尽管我已将QtMultimedia模块包含到我的.pro文件中,但添加了 QT += multimedia
我收到错误消息,未找到QAudioDecoder的服务。我无法看到问题所在。QAudioDecoder - 未找到服务
我使用Qt 5.1.0与MingGW 4.8 32位的Windows 7
错误消息:
defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.audiodecode"
的.pro文件:
QT += core
QT += multimedia
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
主要文件:
#include <QCoreApplication>
#include <QAudioDecoder>
#include <QAudioBuffer>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString pathToFile = "C:/Users/Mateusz/Documents/Szkola/Sound Processing/Lab1/artificial/easy/506Hz.wav";
QAudioDecoder decoder;
decoder.setSourceFilename(pathToFile);
decoder.start();
while(decoder.bufferAvailable()) {
QAudioBuffer buffer = decoder.read();
qDebug() << "Buffer size: " << buffer.byteCount();
}
return a.exec();
}