Всё, разобрался! Поток не правильно создавал.
Сейчас всё норм.
#include "music.h"
#include <phonon/audiooutput.h>
#include <phonon/private/factory_p.h>
#include <QtPlugin>
using namespace Phonon;
Music::Music(QObject *parent) :
QThread(parent)
{
}
void Music::PlayOpen(){
player->setCurrentSource(*open);
player->play();
}
void Music::mOpen(){
emit pOpen();
}
void Music::mClose(){
emit pClose();
}
void Music::PlayClose(){
player->setCurrentSource(*close);
player->play();
}
void Music::init(){
player = new MediaObject;
player->setTransitionTime(1);
out = new AudioOutput(NotificationCategory,0);
createPath(player, out);
out->setVolume(0.5);
open=new MediaSource("sound/open.mp3");
close=new MediaSource("sound/close.mp3");
connect(player,SIGNAL(finished()),player,SLOT(stop()));
connect(this,SIGNAL(pOpen()),this,SLOT(PlayOpen()));
connect(this,SIGNAL(pClose()),this,SLOT(PlayClose()));
}
void Music::run(){
Q_IMPORT_PLUGIN(phonon_ds9)
Factory::setBackend(qt_plugin_instance_phonon_ds9());
qRegisterMetaType<State>();
qRegisterMetaType<MediaSource>("MediaSource");
init();
exec();
}