PDA

View Full Version : playing mp3 files via QT



kerim
20th April 2011, 19:36
hello,

i asking this question to everybody out there having experience in playing mp3 files via qt:
1) is this possible at all (what class does that?)
2) if yes, is it possible to change pitch and speed while playing ?

thnx.

squidge
20th April 2011, 22:14
Phonon::MediaObject *music =
Phonon::createPlayer(Phonon::MusicCategory,
Phonon::MediaSource("/path/mysong.mp3"));
music->play();


http://doc.qt.nokia.com/latest/phonon-overview.html

http://phonon.kde.org/

kerim
21st April 2011, 13:37
wow, thnx.
but unfortunately this seems to be not available for
mingw qt:

http://doc.qt.nokia.com/latest/phonon-overview.html#installing-phonon

Added after 24 minutes:

ok, my last posting might be wrong:
i can compile the following code within qt-creator with setting QT+= phonon to project file:


#include <QtGui/QApplication>
#include "mainwindow.h"

#include <QtGui/QApplication>
#include <Phonon/VideoPlayer>
using namespace Phonon;

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

MediaSource m("test.avi");
VideoPlayer *player = new VideoPlayer(Phonon::VideoCategory, 0);
QObject::connect(player, SIGNAL(finished()), player, SLOT(deleteLater()));
player->play(m);

return a.exec();
}

but nothing happens (file exists and is in right place) :confused: