blob: 86201903958b18b290a57dfa42d1e1d8270e6cf7 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include "audioplayer.h"
#include <phonon/AudioOutput>
#include <phonon/MediaObject>
#include <QFile>
#include <QDebug>
// the universe's only audio player
AudioPlayer *AudioPlayer::m_instance = 0;
AudioPlayer::AudioPlayer()
{
m_player = new Phonon::MediaObject(this);
connect(m_player, SIGNAL(finished()), this, SLOT(finished_p()));
connect(m_player, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged_p(Phonon::State, Phonon::State)));
m_output = new Phonon::AudioOutput(Phonon::MusicCategory, this);
Phonon::createPath(m_player, m_output);
}
AudioPlayer *AudioPlayer::self()
{
if (!m_instance)
m_instance = new AudioPlayer();
return m_instance;
}
void AudioPlayer::stop()
{
m_player->stop();
}
void AudioPlayer::setMuted(bool mute)
{
m_output->setMuted(mute);
}
void AudioPlayer::playIntro()
{
m_player->stop();
m_player->setCurrentSource(new QFile(":/sound/intro"));
m_player->play();
}
void AudioPlayer::finished_p()
{
qDebug() << "finished";
emit finished();
}
void AudioPlayer::stateChanged_p(Phonon::State newstate, Phonon::State oldstate)
{
qDebug() << "old=" << oldstate << "new=" << newstate;
}
|