summaryrefslogtreecommitdiffstats
path: root/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-08 23:39:57 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-08 23:39:57 (GMT)
commitdb0c932bf816b76547798ec62336e25b453d29b8 (patch)
tree5f662f9318fd144e17146e2733ba7857473ec89c /src/multimedia/effects/qsoundeffect_qmedia_p.cpp
parentd4abbfdd1959a65ecfb997c962aa8ea132c77eaf (diff)
parent5f0912e71b6f10c2987eccbc62ea36ab5928f9b8 (diff)
downloadQt-db0c932bf816b76547798ec62336e25b453d29b8.zip
Qt-db0c932bf816b76547798ec62336e25b453d29b8.tar.gz
Qt-db0c932bf816b76547798ec62336e25b453d29b8.tar.bz2
Merge branch '4.7' of git@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