blob: 5dd3db3c18b20ea190683ffd28d0383a948c1895 (
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
|
#include "QtSoundPlayer.h"
#include <phonon/MediaObject>
#include <phonon/AudioOutput>
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();
}
}
|