#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; }