From dd99879ab004dd1d81b5942ad35d5ea6c1476c10 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 7 Apr 2011 19:35:53 +0200 Subject: fixing app icon on windows add audio player --- pacman-c++/audioplayer.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 pacman-c++/audioplayer.cpp (limited to 'pacman-c++/audioplayer.cpp') diff --git a/pacman-c++/audioplayer.cpp b/pacman-c++/audioplayer.cpp new file mode 100644 index 0000000..8620190 --- /dev/null +++ b/pacman-c++/audioplayer.cpp @@ -0,0 +1,55 @@ +#include "audioplayer.h" +#include +#include +#include +#include + +// 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; +} + -- cgit v1.2.3