summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/qmediaplayer/main.cpp52
-rw-r--r--demos/qmediaplayer/mediaplayer.cpp22
-rw-r--r--demos/qmediaplayer/mediaplayer.h7
-rw-r--r--src/3rdparty/phonon/mmf/abstractvideooutput.cpp14
4 files changed, 46 insertions, 49 deletions
diff --git a/demos/qmediaplayer/main.cpp b/demos/qmediaplayer/main.cpp
index 02c579b..9f15e43 100644
--- a/demos/qmediaplayer/main.cpp
+++ b/demos/qmediaplayer/main.cpp
@@ -42,6 +42,8 @@
#include <QtGui>
#include "mediaplayer.h"
+const qreal DefaultVolume = -1.0;
+
int main (int argc, char *argv[])
{
Q_INIT_RESOURCE(mediaplayer);
@@ -50,36 +52,38 @@ int main (int argc, char *argv[])
app.setOrganizationName("Qt");
app.setQuitOnLastWindowClosed(true);
- bool hasSmallScreen =
+ QString fileName;
+ qreal volume = DefaultVolume;
+ bool smallScreen = false;
#ifdef Q_OS_SYMBIAN
- /* On Symbian, we always want fullscreen. One reason is that it's not
- * possible to launch any demos from the fluidlauncher due to a
- * limitation in the emulator. */
- true
-#else
- false
+ smallScreen = true;
#endif
- ;
-
- QString fileString;
- const QStringList args(app.arguments());
- /* We have a minor problem here, we accept two arguments, both are
- * optional:
- * - A file name
- * - the option "-small-screen", so let's try to cope with that.
- */
- for (int i = 0; i < args.count(); ++i) {
- const QString &at = args.at(i);
- if (at == QLatin1String("-small-screen"))
- hasSmallScreen = true;
- else if (i > 0) // We don't want the app name.
- fileString = at;
+ QStringList args(app.arguments());
+ args.removeFirst(); // remove name of executable
+ while (!args.empty()) {
+ const QString &arg = args.first();
+ if (QLatin1String("-small-screen") == arg || QLatin1String("--small-screen") == arg) {
+ smallScreen = true;
+ } else if (QLatin1String("-volume") == arg || QLatin1String("--volume") == arg) {
+ if (!args.empty()) {
+ args.removeFirst();
+ volume = qMax(qMin(args.first().toFloat(), float(1.0)), float(0.0));
+ }
+ } else if (fileName.isNull()) {
+ fileName = arg;
+ }
+ args.removeFirst();
}
- MediaPlayer player(fileString, hasSmallScreen);
+ MediaPlayer player;
+ player.setSmallScreen(smallScreen);
+ if (DefaultVolume != volume)
+ player.setVolume(volume);
+ if (!fileName.isNull())
+ player.setFile(fileName);
- if (hasSmallScreen)
+ if (smallScreen)
player.showMaximized();
else
player.show();
diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp
index eb8279d..5bf7d6d 100644
--- a/demos/qmediaplayer/mediaplayer.cpp
+++ b/demos/qmediaplayer/mediaplayer.cpp
@@ -152,12 +152,10 @@ void MediaVideoWidget::dragEnterEvent(QDragEnterEvent *e) {
}
-MediaPlayer::MediaPlayer(const QString &filePath,
- const bool hasSmallScreen) :
+MediaPlayer::MediaPlayer() :
playButton(0), nextEffect(0), settingsDialog(0), ui(0),
m_AudioOutput(Phonon::VideoCategory),
- m_videoWidget(new MediaVideoWidget(this)),
- m_hasSmallScreen(hasSmallScreen)
+ m_videoWidget(new MediaVideoWidget(this))
{
setWindowTitle(tr("Media Player"));
setContextMenuPolicy(Qt::CustomContextMenu);
@@ -346,8 +344,6 @@ MediaPlayer::MediaPlayer(const QString &filePath,
m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput);
Phonon::createPath(&m_MediaObject, m_videoWidget);
- if (!filePath.isEmpty())
- setFile(filePath);
resize(minimumSizeHint());
}
@@ -358,7 +354,7 @@ void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate)
if (oldstate == Phonon::LoadingState) {
QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint());
QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect);
- if (!m_hasSmallScreen) {
+ if (!m_smallScreen) {
if (m_MediaObject.hasVideo()) {
// Flush event que so that sizeHint takes the
// recently shown/hidden m_videoWindow into account:
@@ -466,6 +462,16 @@ void MediaPlayer::initSettingsDialog()
}
+void MediaPlayer::setVolume(qreal volume)
+{
+ m_AudioOutput.setVolume(volume);
+}
+
+void MediaPlayer::setSmallScreen(bool smallScreen)
+{
+ m_smallScreen = smallScreen;
+}
+
void MediaPlayer::effectChanged()
{
int currentIndex = ui->audioEffectsCombo->currentIndex();
@@ -685,7 +691,7 @@ bool MediaPlayer::playPauseForDialog()
// If we're running on a small screen, we want to pause the video when
// popping up dialogs. We neither want to tamper with the state if the
// user has paused.
- if (m_hasSmallScreen && m_MediaObject.hasVideo()) {
+ if (m_smallScreen && m_MediaObject.hasVideo()) {
if (Phonon::PlayingState == m_MediaObject.state()) {
m_MediaObject.pause();
return true;
diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h
index d6ae58b..73450fe 100644
--- a/demos/qmediaplayer/mediaplayer.h
+++ b/demos/qmediaplayer/mediaplayer.h
@@ -104,8 +104,7 @@ class MediaPlayer :
{
Q_OBJECT
public:
- MediaPlayer(const QString &,
- const bool hasSmallScreen);
+ MediaPlayer();
void dragEnterEvent(QDragEnterEvent *e);
void dragMoveEvent(QDragMoveEvent *e);
@@ -115,6 +114,8 @@ public:
void setLocation(const QString &location);
void initVideoWindow();
void initSettingsDialog();
+ void setVolume(qreal volume);
+ void setSmallScreen(bool smallScreen);
public slots:
void openFile();
@@ -171,7 +172,7 @@ private:
Phonon::AudioOutput m_AudioOutput;
MediaVideoWidget *m_videoWidget;
Phonon::Path m_audioOutputPath;
- const bool m_hasSmallScreen;
+ bool m_smallScreen;
};
#endif //MEDIAPLAYER_H
diff --git a/src/3rdparty/phonon/mmf/abstractvideooutput.cpp b/src/3rdparty/phonon/mmf/abstractvideooutput.cpp
index 2d221ed..068118b 100644
--- a/src/3rdparty/phonon/mmf/abstractvideooutput.cpp
+++ b/src/3rdparty/phonon/mmf/abstractvideooutput.cpp
@@ -161,24 +161,10 @@ void MMF::AbstractVideoOutput::dump() const
{
#ifndef QT_NO_DEBUG
TRACE_CONTEXT(AbstractVideoOutput::dump, EVideoInternal);
-
QScopedPointer<ObjectDump::QVisitor> visitor(new ObjectDump::QVisitor);
visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs
ObjectDump::addDefaultAnnotators(*visitor);
-
- if (QWidget *window = QApplication::activeWindow()) {
- TRACE("Dumping from root window 0x%08x:", window);
- ObjectDump::dumpTreeFromLeaf(*window, *visitor);
- }
-
- TRACE("Dumping tree from leaf 0x%08x:", this);
ObjectDump::dumpTreeFromLeaf(*this, *visitor);
-
- QScopedPointer<ObjectDump::QDumper> dumper(new ObjectDump::QDumper);
- dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs
- ObjectDump::addDefaultAnnotators(*dumper);
- TRACE_0("Dumping AbstractVideoOutput:");
- dumper->dumpObject(*this);
#endif
}