summaryrefslogtreecommitdiffstats
path: root/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-03-09 00:38:03 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-03-09 00:38:03 (GMT)
commitc04a6e34b3d4da24d3cc26e192bebff2d3b79d19 (patch)
treee2a5299daa1e53668e7f9adeac002f8fdd286f8a /src/multimedia/effects/qsoundeffect_qmedia_p.cpp
parent51900441b77df5cb4755aaf2cba8351bbfe15e71 (diff)
parentdb0c932bf816b76547798ec62336e25b453d29b8 (diff)
downloadQt-c04a6e34b3d4da24d3cc26e192bebff2d3b79d19.zip
Qt-c04a6e34b3d4da24d3cc26e192bebff2d3b79d19.tar.gz
Qt-c04a6e34b3d4da24d3cc26e192bebff2d3b79d19.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/multimedia/effects/qsoundeffect_qmedia_p.cpp')
-rw-r--r--src/multimedia/effects/qsoundeffect_qmedia_p.cpp99
1 files changed, 33 insertions, 66 deletions
diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
index 48fb257..43ba22f 100644
--- a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
+++ b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
@@ -50,117 +50,84 @@
// We mean it.
//
-#include <QtCore/qcoreapplication.h>
+#include "qsoundeffect_qmedia_p.h"
-#include "qmediacontent.h"
-#include "qmediaplayer.h"
+#include <QtCore/qcoreapplication.h>
-#include "qsoundeffect_p.h"
-#include "qsoundeffect_qmedia_p.h"
+#include <QtMultimedia/qmediacontent.h>
+#include <QtMultimedia/qmediaplayer.h>
QT_BEGIN_NAMESPACE
QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QObject(parent),
- m_muted(false),
- m_vol(100),
+ m_loopCount(1),
+ m_runningCount(0),
m_player(0)
{
+ m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency);
+ connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged()));
+ connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged()));
+ connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State)));
}
QSoundEffectPrivate::~QSoundEffectPrivate()
{
- if (m_player) delete m_player;
}
-qint64 QSoundEffectPrivate::duration() const
+QUrl QSoundEffectPrivate::source() const
{
- if (m_player) return m_player->duration();
-
- return 0;
+ return m_player->media().canonicalUrl();
}
-int QSoundEffectPrivate::volume() const
+void QSoundEffectPrivate::setSource(const QUrl &url)
{
- if (m_player) return m_player->volume();
-
- return m_vol;
+ m_player->setMedia(url);
}
-bool QSoundEffectPrivate::isMuted() const
-{
- if (m_player) return m_player->isMuted();
-
- return m_muted;
-}
-
-QMediaContent QSoundEffectPrivate::media() const
+int QSoundEffectPrivate::loopCount() const
{
- if (m_player) return m_player->media();
-
- return QMediaContent();
+ return m_loopCount;
}
-QMediaPlayer::State QSoundEffectPrivate::state() const
+void QSoundEffectPrivate::setLoopCount(int loopCount)
{
- if (m_player) return m_player->state();
-
- return QMediaPlayer::StoppedState;
+ m_loopCount = loopCount;
}
-QMediaPlayer::MediaStatus QSoundEffectPrivate::mediaStatus() const
+int QSoundEffectPrivate::volume() const
{
- if (m_player) return m_player->mediaStatus();
-
- return QMediaPlayer::UnknownMediaStatus;
+ return m_player->volume();
}
-void QSoundEffectPrivate::play()
+void QSoundEffectPrivate::setVolume(int volume)
{
- if (m_player && !m_player->isMuted())
- m_player->play();
+ m_player->setVolume(volume);
}
-void QSoundEffectPrivate::stop()
+bool QSoundEffectPrivate::isMuted() const
{
- if (m_player)
- m_player->stop();
+ return m_player->isMuted();
}
-void QSoundEffectPrivate::setVolume(int volume)
+void QSoundEffectPrivate::setMuted(bool muted)
{
- m_vol = volume;
-
- if (m_player)
- m_player->setVolume(volume);
+ m_player->setMuted(muted);
}
-void QSoundEffectPrivate::setMuted(bool muted)
+void QSoundEffectPrivate::play()
{
- m_muted = muted;
-
- if (m_player)
- m_player->setMuted(muted);
+ m_runningCount += m_loopCount;
+ m_player->play();
}
-void QSoundEffectPrivate::setMedia(const QMediaContent &media)
+void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state)
{
- if (media.isNull())
- return;
-
- if (m_player == 0) {
- m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency);
- m_player->setVolume(m_vol);
- m_player->setMuted(m_muted);
-
- connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int)));
- connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool)));
- connect(m_player, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64)));
- connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SIGNAL(stateChanged(QMediaPlayer::State)));
+ if (state == QMediaPlayer::StoppedState) {
+ if (--m_runningCount > 0)
+ m_player->play();
}
-
- m_player->setMedia(media.canonicalUrl());
}
QT_END_NAMESPACE