blob: 4aa6b8ea48900a15882398faedff2c9a1d8a8ba9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include "QtSoundPlayer.h"
#ifdef Q_WS_X11
#include "mediaobject.h"
#include "audiooutput.h"
#else
#include <phonon/MediaObject>
#include <phonon/AudioOutput>
#endif
namespace Swift{
QtSoundPlayer::QtSoundPlayer() {
audioOutput_ = new Phonon::AudioOutput(Phonon::NotificationCategory);
messageReceived_ = new Phonon::MediaObject();
messageReceived_->setCurrentSource(Phonon::MediaSource(":/sounds/message-received.wav"));
Phonon::createPath(messageReceived_, audioOutput_);
connect(messageReceived_, SIGNAL(finished()), this, SLOT(handleFinished()));
}
QtSoundPlayer::~QtSoundPlayer() {
delete messageReceived_;
delete audioOutput_;
}
void QtSoundPlayer::playSound(SoundEffect sound) {
switch (sound) {
case MessageReceived:
//messageReceived_->stop();
messageReceived_->play();
break;
}
}
void QtSoundPlayer::handleFinished() {
messageReceived_->stop();
}
}
|