.pro 添加
QT += phonon
.cpp 添加
#include <Phonon/AudioOutput>
#include <Phonon/MediaObject>
Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
mediaObject->setCurrentSource(Phonon::MediaSource("D:\down\1.mp3"));
Phonon::AudioOutput *audioOutput =
new Phonon::AudioOutput(Phonon::MusicCategory, this);
Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
mediaObject->play();