2014-04-01 55 views
2

我正在尝试使用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(); 
} 

回答

0

我在Qt5.5 Linux下运行同样的问题。 使用其MaintenanceTool升级到Qt5.5.1后,问题消失。

0

我也在努力解决这个问题,并最终通过在QT Creator中使用MS visual studio编译器来工作,就像Fernando Pelliccioni建议的那样。

步骤是:

- 使用Qt的MaintenanceTool添加支持msvc2013

-Install的Visual Studio 2013

- 在Qt Creator中去项目 - >管理工具包,并添加msvc2013

- 建立并运行。现在QAudioDecoder工作。