From 459884f0edb3c3a0a1f0e2951bc0e3e16b0e087a Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Wed, 6 Jul 2011 13:41:54 +0200 Subject: Merge the demos and examples in qtphonon. Reviewed-By: David Boddie --- demos/qmediaplayer/images/screen.png | Bin 4358 -> 0 bytes demos/qmediaplayer/main.cpp | 93 --- demos/qmediaplayer/mediaplayer.cpp | 994 ------------------------- demos/qmediaplayer/mediaplayer.h | 184 ----- demos/qmediaplayer/mediaplayer.qrc | 5 - demos/qmediaplayer/qmediaplayer.pro | 39 - demos/qmediaplayer/settings.ui | 495 ------------ examples/phonon/phonon.pro | 3 +- examples/phonon/qmediaplayer/images/screen.png | Bin 0 -> 4358 bytes examples/phonon/qmediaplayer/main.cpp | 93 +++ examples/phonon/qmediaplayer/mediaplayer.cpp | 994 +++++++++++++++++++++++++ examples/phonon/qmediaplayer/mediaplayer.h | 184 +++++ examples/phonon/qmediaplayer/mediaplayer.qrc | 5 + examples/phonon/qmediaplayer/qmediaplayer.pro | 39 + examples/phonon/qmediaplayer/settings.ui | 495 ++++++++++++ 15 files changed, 1812 insertions(+), 1811 deletions(-) delete mode 100644 demos/qmediaplayer/images/screen.png delete mode 100644 demos/qmediaplayer/main.cpp delete mode 100644 demos/qmediaplayer/mediaplayer.cpp delete mode 100644 demos/qmediaplayer/mediaplayer.h delete mode 100644 demos/qmediaplayer/mediaplayer.qrc delete mode 100644 demos/qmediaplayer/qmediaplayer.pro delete mode 100644 demos/qmediaplayer/settings.ui create mode 100644 examples/phonon/qmediaplayer/images/screen.png create mode 100644 examples/phonon/qmediaplayer/main.cpp create mode 100644 examples/phonon/qmediaplayer/mediaplayer.cpp create mode 100644 examples/phonon/qmediaplayer/mediaplayer.h create mode 100644 examples/phonon/qmediaplayer/mediaplayer.qrc create mode 100644 examples/phonon/qmediaplayer/qmediaplayer.pro create mode 100644 examples/phonon/qmediaplayer/settings.ui diff --git a/demos/qmediaplayer/images/screen.png b/demos/qmediaplayer/images/screen.png deleted file mode 100644 index a15df92..0000000 Binary files a/demos/qmediaplayer/images/screen.png and /dev/null differ diff --git a/demos/qmediaplayer/main.cpp b/demos/qmediaplayer/main.cpp deleted file mode 100644 index aee7d2b..0000000 --- a/demos/qmediaplayer/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -***************************************************************************/ - -#include -#include "mediaplayer.h" - -const qreal DefaultVolume = -1.0; - -int main (int argc, char *argv[]) -{ - Q_INIT_RESOURCE(mediaplayer); - QApplication app(argc, argv); - app.setApplicationName("Media Player"); - app.setOrganizationName("Qt"); - app.setQuitOnLastWindowClosed(true); - - QString fileName; - qreal volume = DefaultVolume; - bool smallScreen = false; -#ifdef Q_OS_SYMBIAN - smallScreen = true; -#endif - - 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; - player.setSmallScreen(smallScreen); - if (DefaultVolume != volume) - player.setVolume(volume); - if (!fileName.isNull()) - player.setFile(fileName); - - if (smallScreen) - player.showMaximized(); - else - player.show(); - - return app.exec(); -} - diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp deleted file mode 100644 index 91f24b7..0000000 --- a/demos/qmediaplayer/mediaplayer.cpp +++ /dev/null @@ -1,994 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -***************************************************************************/ - -#include - -#define SLIDER_RANGE 8 - -#include "mediaplayer.h" -#include "ui_settings.h" - -#ifdef Q_OS_SYMBIAN -#include -#include -#include -#endif - -MediaVideoWidget::MediaVideoWidget(MediaPlayer *player, QWidget *parent) : - Phonon::VideoWidget(parent), m_player(player), m_action(this) -{ - m_action.setCheckable(true); - m_action.setChecked(false); - m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); - m_action.setShortcutContext(Qt::WindowShortcut); - connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); - addAction(&m_action); - setAcceptDrops(true); -} - -void MediaVideoWidget::setFullScreen(bool enabled) -{ - Phonon::VideoWidget::setFullScreen(enabled); - emit fullScreenChanged(enabled); -} - -void MediaVideoWidget::mouseDoubleClickEvent(QMouseEvent *e) -{ - Phonon::VideoWidget::mouseDoubleClickEvent(e); - setFullScreen(!isFullScreen()); -} - -void MediaVideoWidget::keyPressEvent(QKeyEvent *e) -{ - if(!e->modifiers()) { - // On non-QWERTY Symbian key-based devices, there is no space key. - // The zero key typically is marked with a space character. - if (e->key() == Qt::Key_Space || e->key() == Qt::Key_0) { - m_player->playPause(); - e->accept(); - return; - } - - // On Symbian devices, there is no key which maps to Qt::Key_Escape - // On devices which lack a backspace key (i.e. non-QWERTY devices), - // the 'C' key maps to Qt::Key_Backspace - else if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Backspace) { - setFullScreen(false); - e->accept(); - return; - } - } - Phonon::VideoWidget::keyPressEvent(e); -} - -bool MediaVideoWidget::event(QEvent *e) -{ - switch(e->type()) - { - case QEvent::Close: - //we just ignore the cose events on the video widget - //this prevents ALT+F4 from having an effect in fullscreen mode - e->ignore(); - return true; - case QEvent::MouseMove: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - //fall through - case QEvent::WindowStateChange: - { - //we just update the state of the checkbox, in case it wasn't already - m_action.setChecked(windowState() & Qt::WindowFullScreen); - const Qt::WindowFlags flags = m_player->windowFlags(); - if (windowState() & Qt::WindowFullScreen) { - m_timer.start(1000, this); - } else { - m_timer.stop(); -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - } - } - break; - default: - break; - } - - return Phonon::VideoWidget::event(e); -} - -void MediaVideoWidget::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == m_timer.timerId()) { - //let's store the cursor shape -#ifndef QT_NO_CURSOR - setCursor(Qt::BlankCursor); -#endif - } - Phonon::VideoWidget::timerEvent(e); -} - -void MediaVideoWidget::dropEvent(QDropEvent *e) -{ - m_player->handleDrop(e); -} - -void MediaVideoWidget::dragEnterEvent(QDragEnterEvent *e) { - if (e->mimeData()->hasUrls()) - e->acceptProposedAction(); -} - - -MediaPlayer::MediaPlayer() : - playButton(0), nextEffect(0), settingsDialog(0), ui(0), - m_AudioOutput(Phonon::VideoCategory), - m_videoWidget(new MediaVideoWidget(this)) -{ - setWindowTitle(tr("Media Player")); - setContextMenuPolicy(Qt::CustomContextMenu); - m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); - - QSize buttonSize(34, 28); - - QPushButton *openButton = new QPushButton(this); - - openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); - QPalette bpal; - QColor arrowcolor = bpal.buttonText().color(); - if (arrowcolor == Qt::black) - arrowcolor = QColor(80, 80, 80); - bpal.setBrush(QPalette::ButtonText, arrowcolor); - openButton->setPalette(bpal); - - rewindButton = new QPushButton(this); - rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); - - forwardButton = new QPushButton(this); - forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); - forwardButton->setEnabled(false); - - playButton = new QPushButton(this); - playIcon = style()->standardIcon(QStyle::SP_MediaPlay); - pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); - playButton->setIcon(playIcon); - - slider = new Phonon::SeekSlider(this); - slider->setMediaObject(&m_MediaObject); - volume = new Phonon::VolumeSlider(&m_AudioOutput); - - QVBoxLayout *vLayout = new QVBoxLayout(this); - vLayout->setContentsMargins(8, 8, 8, 8); - - QHBoxLayout *layout = new QHBoxLayout(); - - info = new QLabel(this); - info->setMinimumHeight(70); - info->setAcceptDrops(false); - info->setMargin(2); - info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - info->setLineWidth(2); - info->setAutoFillBackground(true); - - QPalette palette; - palette.setBrush(QPalette::WindowText, Qt::white); -#ifndef Q_WS_MAC - openButton->setMinimumSize(54, buttonSize.height()); - rewindButton->setMinimumSize(buttonSize); - forwardButton->setMinimumSize(buttonSize); - playButton->setMinimumSize(buttonSize); -#endif - info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px"); - info->setPalette(palette); - info->setText(tr("
No media
")); - - volume->setFixedWidth(120); - - layout->addWidget(openButton); - layout->addWidget(rewindButton); - layout->addWidget(playButton); - layout->addWidget(forwardButton); - - layout->addStretch(); - layout->addWidget(volume); - - vLayout->addWidget(info); - initVideoWindow(); - vLayout->addWidget(&m_videoWindow); - QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); - m_videoWindow.hide(); - buttonPanelLayout->addLayout(layout); - - timeLabel = new QLabel(this); - progressLabel = new QLabel(this); - QWidget *sliderPanel = new QWidget(this); - QHBoxLayout *sliderLayout = new QHBoxLayout(); - sliderLayout->addWidget(slider); - sliderLayout->addWidget(timeLabel); - sliderLayout->addWidget(progressLabel); - sliderLayout->setContentsMargins(0, 0, 0, 0); - sliderPanel->setLayout(sliderLayout); - - buttonPanelLayout->addWidget(sliderPanel); - buttonPanelLayout->setContentsMargins(0, 0, 0, 0); -#ifdef Q_OS_MAC - layout->setSpacing(4); - buttonPanelLayout->setSpacing(0); - info->setMinimumHeight(100); - info->setFont(QFont("verdana", 15)); - // QStyle *flatButtonStyle = new QWindowsStyle; - openButton->setFocusPolicy(Qt::NoFocus); - // openButton->setStyle(flatButtonStyle); - // playButton->setStyle(flatButtonStyle); - // rewindButton->setStyle(flatButtonStyle); - // forwardButton->setStyle(flatButtonStyle); - #endif - QWidget *buttonPanelWidget = new QWidget(this); - buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - buttonPanelWidget->setLayout(buttonPanelLayout); - vLayout->addWidget(buttonPanelWidget); - - QHBoxLayout *labelLayout = new QHBoxLayout(); - - vLayout->addLayout(labelLayout); - setLayout(vLayout); - - // Create menu bar: - fileMenu = new QMenu(this); - QAction *openFileAction = fileMenu->addAction(tr("Open &File...")); - QAction *openUrlAction = fileMenu->addAction(tr("Open &Location...")); -#ifdef Q_OS_SYMBIAN - QAction *selectIAPAction = fileMenu->addAction(tr("Select &IAP...")); - connect(selectIAPAction, SIGNAL(triggered(bool)), this, SLOT(selectIAP())); -#endif - QAction *const openLinkAction = fileMenu->addAction(tr("Open &RAM File...")); - - connect(openLinkAction, SIGNAL(triggered(bool)), this, SLOT(openRamFile())); - - fileMenu->addSeparator(); - QMenu *aspectMenu = fileMenu->addMenu(tr("&Aspect ratio")); - QActionGroup *aspectGroup = new QActionGroup(aspectMenu); - connect(aspectGroup, SIGNAL(triggered(QAction*)), this, SLOT(aspectChanged(QAction*))); - aspectGroup->setExclusive(true); - QAction *aspectActionAuto = aspectMenu->addAction(tr("Auto")); - aspectActionAuto->setCheckable(true); - aspectActionAuto->setChecked(true); - aspectGroup->addAction(aspectActionAuto); - QAction *aspectActionScale = aspectMenu->addAction(tr("Scale")); - aspectActionScale->setCheckable(true); - aspectGroup->addAction(aspectActionScale); - QAction *aspectAction16_9 = aspectMenu->addAction(tr("16/9")); - aspectAction16_9->setCheckable(true); - aspectGroup->addAction(aspectAction16_9); - QAction *aspectAction4_3 = aspectMenu->addAction(tr("4/3")); - aspectAction4_3->setCheckable(true); - aspectGroup->addAction(aspectAction4_3); - - QMenu *scaleMenu = fileMenu->addMenu(tr("&Scale mode")); - QActionGroup *scaleGroup = new QActionGroup(scaleMenu); - connect(scaleGroup, SIGNAL(triggered(QAction*)), this, SLOT(scaleChanged(QAction*))); - scaleGroup->setExclusive(true); - QAction *scaleActionFit = scaleMenu->addAction(tr("Fit in view")); - scaleActionFit->setCheckable(true); - scaleActionFit->setChecked(true); - scaleGroup->addAction(scaleActionFit); - QAction *scaleActionCrop = scaleMenu->addAction(tr("Scale and crop")); - scaleActionCrop->setCheckable(true); - scaleGroup->addAction(scaleActionCrop); - - m_fullScreenAction = fileMenu->addAction(tr("Full screen video")); - m_fullScreenAction->setCheckable(true); - m_fullScreenAction->setEnabled(false); // enabled by hasVideoChanged - bool b = connect(m_fullScreenAction, SIGNAL(toggled(bool)), m_videoWidget, SLOT(setFullScreen(bool))); - Q_ASSERT(b); - b = connect(m_videoWidget, SIGNAL(fullScreenChanged(bool)), m_fullScreenAction, SLOT(setChecked(bool))); - Q_ASSERT(b); - - fileMenu->addSeparator(); - QAction *settingsAction = fileMenu->addAction(tr("&Settings...")); - - // Setup signal connections: - connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind())); - //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); - openButton->setMenu(fileMenu); - - connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); - connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); - //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); - connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(showSettingsDialog())); - connect(openUrlAction, SIGNAL(triggered(bool)), this, SLOT(openUrl())); - connect(openFileAction, SIGNAL(triggered(bool)), this, SLOT(openFile())); - - connect(m_videoWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); - connect(&m_MediaObject, SIGNAL(metaDataChanged()), this, SLOT(updateInfo())); - connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); - connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime())); - connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); - connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); - connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); - connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); - - rewindButton->setEnabled(false); - playButton->setEnabled(false); - setAcceptDrops(true); - - m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); - Phonon::createPath(&m_MediaObject, m_videoWidget); - - resize(minimumSizeHint()); -} - -void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) -{ - Q_UNUSED(oldstate); - - if (oldstate == Phonon::LoadingState) { - QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); - QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); - if (!m_smallScreen) { - if (m_MediaObject.hasVideo()) { - // Flush event que so that sizeHint takes the - // recently shown/hidden m_videoWindow into account: - qApp->processEvents(); - resize(sizeHint()); - } else - resize(minimumSize()); - } - } - - switch (newstate) { - case Phonon::ErrorState: - if (m_MediaObject.errorType() == Phonon::FatalError) { - playButton->setEnabled(false); - rewindButton->setEnabled(false); - } else { - m_MediaObject.pause(); - } - QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close); - break; - - case Phonon::StoppedState: - m_videoWidget->setFullScreen(false); - // Fall through - case Phonon::PausedState: - playButton->setIcon(playIcon); - if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ - playButton->setEnabled(true); - rewindButton->setEnabled(true); - } else { - playButton->setEnabled(false); - rewindButton->setEnabled(false); - } - break; - case Phonon::PlayingState: - playButton->setEnabled(true); - playButton->setIcon(pauseIcon); - if (m_MediaObject.hasVideo()) - m_videoWindow.show(); - // Fall through - case Phonon::BufferingState: - rewindButton->setEnabled(true); - break; - case Phonon::LoadingState: - rewindButton->setEnabled(false); - break; - } - -} - -void MediaPlayer::initSettingsDialog() -{ - settingsDialog = new QDialog(this); - ui = new Ui_settings(); - ui->setupUi(settingsDialog); - - connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrightness(int))); - connect(ui->hueSlider, SIGNAL(valueChanged(int)), this, SLOT(setHue(int))); - connect(ui->saturationSlider, SIGNAL(valueChanged(int)), this, SLOT(setSaturation(int))); - connect(ui->contrastSlider , SIGNAL(valueChanged(int)), this, SLOT(setContrast(int))); - connect(ui->aspectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setAspect(int))); - connect(ui->scalemodeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setScale(int))); - - ui->brightnessSlider->setValue(int(m_videoWidget->brightness() * SLIDER_RANGE)); - ui->hueSlider->setValue(int(m_videoWidget->hue() * SLIDER_RANGE)); - ui->saturationSlider->setValue(int(m_videoWidget->saturation() * SLIDER_RANGE)); - ui->contrastSlider->setValue(int(m_videoWidget->contrast() * SLIDER_RANGE)); - ui->aspectCombo->setCurrentIndex(m_videoWidget->aspectRatio()); - ui->scalemodeCombo->setCurrentIndex(m_videoWidget->scaleMode()); - connect(ui->effectButton, SIGNAL(clicked()), this, SLOT(configureEffect())); - -#ifdef Q_WS_X11 - //Cross fading is not currently implemented in the GStreamer backend - ui->crossFadeSlider->setVisible(false); - ui->crossFadeLabel->setVisible(false); - ui->crossFadeLabel1->setVisible(false); - ui->crossFadeLabel2->setVisible(false); - ui->crossFadeLabel3->setVisible(false); -#endif - ui->crossFadeSlider->setValue((int)(2 * m_MediaObject.transitionTime() / 1000.0f)); - - // Insert audio devices: - QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); - for (int i=0; ideviceCombo->addItem(itemText); - if (devices[i] == m_AudioOutput.outputDevice()) - ui->deviceCombo->setCurrentIndex(i); - } - - // Insert audio effects: - ui->audioEffectsCombo->addItem(tr("")); - QList currEffects = m_audioOutputPath.effects(); - Phonon::Effect *currEffect = currEffects.size() ? currEffects[0] : 0; - QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - for (int i=0; iaudioEffectsCombo->addItem(availableEffects[i].name()); - if (currEffect && availableEffects[i] == currEffect->description()) - ui->audioEffectsCombo->setCurrentIndex(i+1); - } - connect(ui->audioEffectsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(effectChanged())); - -} - -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(); - if (currentIndex) { - QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - Phonon::EffectDescription chosenEffect = availableEffects[currentIndex - 1]; - - QList currEffects = m_audioOutputPath.effects(); - Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; - - // Deleting the running effect will stop playback, it is deleted when removed from path - if (nextEffect && !(currentEffect && (currentEffect->description().name() == nextEffect->description().name()))) - delete nextEffect; - - nextEffect = new Phonon::Effect(chosenEffect); - } - ui->effectButton->setEnabled(currentIndex); -} - -void MediaPlayer::showSettingsDialog() -{ - const bool hasPausedForDialog = playPauseForDialog(); - - if (!settingsDialog) - initSettingsDialog(); - - float oldBrightness = m_videoWidget->brightness(); - float oldHue = m_videoWidget->hue(); - float oldSaturation = m_videoWidget->saturation(); - float oldContrast = m_videoWidget->contrast(); - Phonon::VideoWidget::AspectRatio oldAspect = m_videoWidget->aspectRatio(); - Phonon::VideoWidget::ScaleMode oldScale = m_videoWidget->scaleMode(); - int currentEffect = ui->audioEffectsCombo->currentIndex(); - settingsDialog->exec(); - - if (settingsDialog->result() == QDialog::Accepted){ - m_MediaObject.setTransitionTime((int)(1000 * float(ui->crossFadeSlider->value()) / 2.0f)); - QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); - m_AudioOutput.setOutputDevice(devices[ui->deviceCombo->currentIndex()]); - QList currEffects = m_audioOutputPath.effects(); - QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - - if (ui->audioEffectsCombo->currentIndex() > 0){ - Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; - if (!currentEffect || currentEffect->description() != nextEffect->description()){ - foreach(Phonon::Effect *effect, currEffects) { - m_audioOutputPath.removeEffect(effect); - delete effect; - } - m_audioOutputPath.insertEffect(nextEffect); - } - } else { - foreach(Phonon::Effect *effect, currEffects) { - m_audioOutputPath.removeEffect(effect); - delete effect; - nextEffect = 0; - } - } - } else { - // Restore previous settings - m_videoWidget->setBrightness(oldBrightness); - m_videoWidget->setSaturation(oldSaturation); - m_videoWidget->setHue(oldHue); - m_videoWidget->setContrast(oldContrast); - m_videoWidget->setAspectRatio(oldAspect); - m_videoWidget->setScaleMode(oldScale); - ui->audioEffectsCombo->setCurrentIndex(currentEffect); - } - - if (hasPausedForDialog) - m_MediaObject.play(); -} - -void MediaPlayer::initVideoWindow() -{ - QVBoxLayout *videoLayout = new QVBoxLayout(); - videoLayout->addWidget(m_videoWidget); - videoLayout->setContentsMargins(0, 0, 0, 0); - m_videoWindow.setLayout(videoLayout); - m_videoWindow.setMinimumSize(100, 100); -} - - -void MediaPlayer::configureEffect() -{ - if (!nextEffect) - return; - - - QList currEffects = m_audioOutputPath.effects(); - const QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); - if (ui->audioEffectsCombo->currentIndex() > 0) { - Phonon::EffectDescription chosenEffect = availableEffects[ui->audioEffectsCombo->currentIndex() - 1]; - - QDialog effectDialog; - effectDialog.setWindowTitle(tr("Configure effect")); - QVBoxLayout *topLayout = new QVBoxLayout(&effectDialog); - - QLabel *description = new QLabel("Description:
" + chosenEffect.description(), &effectDialog); - description->setWordWrap(true); - topLayout->addWidget(description); - - QScrollArea *scrollArea = new QScrollArea(&effectDialog); - topLayout->addWidget(scrollArea); - - QVariantList savedParamValues; - foreach(Phonon::EffectParameter param, nextEffect->parameters()) { - savedParamValues << nextEffect->parameterValue(param); - } - - QWidget *scrollWidget = new Phonon::EffectWidget(nextEffect); - scrollWidget->setMinimumWidth(320); - scrollWidget->setContentsMargins(10, 10, 10,10); - scrollArea->setWidget(scrollWidget); - - QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &effectDialog); - connect(bbox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), &effectDialog, SLOT(accept())); - connect(bbox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), &effectDialog, SLOT(reject())); - topLayout->addWidget(bbox); - - effectDialog.exec(); - - if (effectDialog.result() != QDialog::Accepted) { - //we need to restore the parameters values - int currentIndex = 0; - foreach(Phonon::EffectParameter param, nextEffect->parameters()) { - nextEffect->setParameterValue(param, savedParamValues.at(currentIndex++)); - } - - } - } -} - -void MediaPlayer::handleDrop(QDropEvent *e) -{ - QList urls = e->mimeData()->urls(); - if (e->proposedAction() == Qt::MoveAction){ - // Just add to the queue: - for (int i=0; i 0) { - QString fileName = urls[0].toLocalFile(); - QDir dir(fileName); - if (dir.exists()) { - dir.setFilter(QDir::Files); - QStringList entries = dir.entryList(); - if (entries.size() > 0) { - setFile(fileName + QDir::separator() + entries[0]); - for (int i=1; i< entries.size(); ++i) - m_MediaObject.enqueue(fileName + QDir::separator() + entries[i]); - } - } else { - setFile(fileName); - for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); - m_MediaObject.play(); -} - -void MediaPlayer::dropEvent(QDropEvent *e) -{ - if (e->mimeData()->hasUrls() && e->proposedAction() != Qt::LinkAction) { - e->acceptProposedAction(); - handleDrop(e); - } else { - e->ignore(); - } -} - -void MediaPlayer::dragEnterEvent(QDragEnterEvent *e) -{ - dragMoveEvent(e); -} - -void MediaPlayer::dragMoveEvent(QDragMoveEvent *e) -{ - if (e->mimeData()->hasUrls()) { - if (e->proposedAction() == Qt::CopyAction || e->proposedAction() == Qt::MoveAction){ - e->acceptProposedAction(); - } - } -} - -void MediaPlayer::playPause() -{ - if (m_MediaObject.state() == Phonon::PlayingState) - m_MediaObject.pause(); - else { - if (m_MediaObject.currentTime() == m_MediaObject.totalTime()) - m_MediaObject.seek(0); - m_MediaObject.play(); - } -} - -void MediaPlayer::setFile(const QString &fileName) -{ - setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); - m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); - m_MediaObject.play(); -} - -void MediaPlayer::setLocation(const QString& location) -{ - setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1)); - m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8()))); - m_MediaObject.play(); -} - -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_smallScreen && m_MediaObject.hasVideo()) { - if (Phonon::PlayingState == m_MediaObject.state()) { - m_MediaObject.pause(); - return true; - } - } - return false; -} - -void MediaPlayer::openFile() -{ - const bool hasPausedForDialog = playPauseForDialog(); - - QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), - QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - - if (hasPausedForDialog) - m_MediaObject.play(); - - m_MediaObject.clearQueue(); - if (fileNames.size() > 0) { - QString fileName = fileNames[0]; - setFile(fileName); - for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); -} - -void MediaPlayer::bufferStatus(int percent) -{ - if (percent == 100) - progressLabel->setText(QString()); - else { - QString str = QString::fromLatin1("(%1%)").arg(percent); - progressLabel->setText(str); - } -} - -void MediaPlayer::setSaturation(int val) -{ - m_videoWidget->setSaturation(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::setHue(int val) -{ - m_videoWidget->setHue(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::setAspect(int val) -{ - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio(val)); -} - -void MediaPlayer::setScale(int val) -{ - m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleMode(val)); -} - -void MediaPlayer::setBrightness(int val) -{ - m_videoWidget->setBrightness(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::setContrast(int val) -{ - m_videoWidget->setContrast(val / qreal(SLIDER_RANGE)); -} - -void MediaPlayer::updateInfo() -{ - int maxLength = 30; - QString font = ""; - QString fontmono = ""; - - QMap metaData = m_MediaObject.metaData(); - QString trackArtist = metaData.value("ARTIST"); - if (trackArtist.length() > maxLength) - trackArtist = trackArtist.left(maxLength) + "..."; - - QString trackTitle = metaData.value("TITLE"); - int trackBitrate = metaData.value("BITRATE").toInt(); - - QString fileName; - if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { - fileName = m_MediaObject.currentSource().url().toString(); - } else { - fileName = m_MediaObject.currentSource().fileName(); - fileName = fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1); - if (fileName.length() > maxLength) - fileName = fileName.left(maxLength) + "..."; - } - - QString title; - if (!trackTitle.isEmpty()) { - if (trackTitle.length() > maxLength) - trackTitle = trackTitle.left(maxLength) + "..."; - title = "Title: " + font + trackTitle + "
"; - } else if (!fileName.isEmpty()) { - if (fileName.length() > maxLength) - fileName = fileName.left(maxLength) + "..."; - title = font + fileName + "
"; - if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { - title.prepend("Url: "); - } else { - title.prepend("File: "); - } - } - - QString artist; - if (!trackArtist.isEmpty()) - artist = "Artist: " + font + trackArtist + ""; - - QString bitrate; - if (trackBitrate != 0) - bitrate = "
Bitrate: " + font + QString::number(trackBitrate/1000) + "kbit"; - - info->setText(title + artist + bitrate); -} - -void MediaPlayer::updateTime() -{ - long len = m_MediaObject.totalTime(); - long pos = m_MediaObject.currentTime(); - QString timeString; - if (pos || len) - { - int sec = pos/1000; - int min = sec/60; - int hour = min/60; - int msec = pos; - - QTime playTime(hour%60, min%60, sec%60, msec%1000); - sec = len / 1000; - min = sec / 60; - hour = min / 60; - msec = len; - - QTime stopTime(hour%60, min%60, sec%60, msec%1000); - QString timeFormat = "m:ss"; - if (hour > 0) - timeFormat = "h:mm:ss"; - timeString = playTime.toString(timeFormat); - if (len) - timeString += " / " + stopTime.toString(timeFormat); - } - timeLabel->setText(timeString); -} - -void MediaPlayer::rewind() -{ - m_MediaObject.seek(0); -} - -void MediaPlayer::forward() -{ - QList queue = m_MediaObject.queue(); - if (queue.size() > 0) { - m_MediaObject.setCurrentSource(queue[0]); - forwardButton->setEnabled(queue.size() > 1); - m_MediaObject.play(); - } -} - -void MediaPlayer::openUrl() -{ - QSettings settings; - settings.beginGroup(QLatin1String("BrowserMainWindow")); - QString sourceURL = settings.value("location").toString(); - bool ok = false; - sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); - if (ok && !sourceURL.isEmpty()) { - setLocation(sourceURL); - settings.setValue("location", sourceURL); - } -} - -/*! - \since 4.6 - */ -void MediaPlayer::openRamFile() -{ - QSettings settings; - settings.beginGroup(QLatin1String("BrowserMainWindow")); - - const QStringList fileNameList(QFileDialog::getOpenFileNames(this, - QString(), - settings.value("openRamFile").toString(), - QLatin1String("RAM files (*.ram)"))); - - if (fileNameList.isEmpty()) - return; - - QFile linkFile; - QList list; - QByteArray sourceURL; - for (int i = 0; i < fileNameList.count(); i++ ) { - linkFile.setFileName(fileNameList[i]); - if (linkFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - while (!linkFile.atEnd()) { - sourceURL = linkFile.readLine().trimmed(); - if (!sourceURL.isEmpty()) { - const QUrl url(QUrl::fromEncoded(sourceURL)); - if (url.isValid()) - list.append(url); - } - } - linkFile.close(); - } - } - - if (!list.isEmpty()) { - m_MediaObject.clearQueue(); - setLocation(list[0].toString()); - for (int i = 1; i < list.count(); i++) - m_MediaObject.enqueue(Phonon::MediaSource(list[i])); - m_MediaObject.play(); - } - - forwardButton->setEnabled(!m_MediaObject.queue().isEmpty()); - settings.setValue("openRamFile", fileNameList[0]); -} - -void MediaPlayer::finished() -{ -} - -void MediaPlayer::showContextMenu(const QPoint &p) -{ - fileMenu->popup(m_videoWidget->isFullScreen() ? p : mapToGlobal(p)); -} - -void MediaPlayer::scaleChanged(QAction *act) -{ - if (act->text() == tr("Scale and crop")) - m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleAndCrop); - else - m_videoWidget->setScaleMode(Phonon::VideoWidget::FitInView); -} - -void MediaPlayer::aspectChanged(QAction *act) -{ - if (act->text() == tr("16/9")) - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio16_9); - else if (act->text() == tr("Scale")) - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioWidget); - else if (act->text() == tr("4/3")) - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio4_3); - else - m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); -} - -void MediaPlayer::hasVideoChanged(bool bHasVideo) -{ - info->setVisible(!bHasVideo); - m_videoWindow.setVisible(bHasVideo); - m_fullScreenAction->setEnabled(bHasVideo); -} - -#ifdef Q_OS_SYMBIAN -void MediaPlayer::selectIAP() -{ - TRAPD(err, selectIAPL()); - if (KErrNone != err) - QMessageBox::warning(this, "Phonon Mediaplayer", "Error selecting IAP", QMessageBox::Close); -} - -void MediaPlayer::selectIAPL() -{ - QVariant currentIAPValue = m_MediaObject.property("InternetAccessPointName"); - QString currentIAPString = currentIAPValue.toString(); - bool ok = false; - CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP); - CleanupStack::PushL(commsDb); - commsDb->ShowHiddenRecords(); - CCommsDbTableView* view = commsDb->OpenTableLC(TPtrC(IAP)); - QStringList items; - TInt currentIAP = 0; - for (TInt l = view->GotoFirstRecord(), i = 0; l != KErrNotFound; l = view->GotoNextRecord(), i++) { - TBuf iapName; - view->ReadTextL(TPtrC(COMMDB_NAME), iapName); - QString iapString = QString::fromUtf16(iapName.Ptr(), iapName.Length()); - items << iapString; - if (iapString == currentIAPString) - currentIAP = i; - } - currentIAPString = QInputDialog::getItem(this, tr("Select Access Point"), tr("Select Access Point"), items, currentIAP, false, &ok); - if (ok) - m_MediaObject.setProperty("InternetAccessPointName", currentIAPString); - CleanupStack::PopAndDestroy(2); //commsDB, view -} -#endif diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h deleted file mode 100644 index 0b9dcf3..0000000 --- a/demos/qmediaplayer/mediaplayer.h +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -***************************************************************************/ - -#ifndef MEDIALAYER_H -#define MEDIAPLAYER_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QPushButton; -class QLabel; -class QSlider; -class QTextEdit; -class QMenu; -class Ui_settings; -QT_END_NAMESPACE - -class MediaPlayer; - -class MediaVideoWidget : public Phonon::VideoWidget -{ - Q_OBJECT - -public: - MediaVideoWidget(MediaPlayer *player, QWidget *parent = 0); - -public slots: - // Over-riding non-virtual Phonon::VideoWidget slot - void setFullScreen(bool); - -signals: - void fullScreenChanged(bool); - -protected: - void mouseDoubleClickEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - bool event(QEvent *e); - void timerEvent(QTimerEvent *e); - void dropEvent(QDropEvent *e); - void dragEnterEvent(QDragEnterEvent *e); - -private: - MediaPlayer *m_player; - QBasicTimer m_timer; - QAction m_action; -}; - -class MediaPlayer : - public QWidget -{ - Q_OBJECT -public: - MediaPlayer(); - - void dragEnterEvent(QDragEnterEvent *e); - void dragMoveEvent(QDragMoveEvent *e); - void dropEvent(QDropEvent *e); - void handleDrop(QDropEvent *e); - void setFile(const QString &text); - void setLocation(const QString &location); - void initVideoWindow(); - void initSettingsDialog(); - void setVolume(qreal volume); - void setSmallScreen(bool smallScreen); - -public slots: - void openFile(); - void rewind(); - void forward(); - void updateInfo(); - void updateTime(); - void finished(); - void playPause(); - void scaleChanged(QAction *); - void aspectChanged(QAction *); - -private slots: - void setAspect(int); - void setScale(int); - void setSaturation(int); - void setContrast(int); - void setHue(int); - void setBrightness(int); - void stateChanged(Phonon::State newstate, Phonon::State oldstate); - void effectChanged(); - void showSettingsDialog(); - void showContextMenu(const QPoint& point); - void bufferStatus(int percent); - void openUrl(); -#ifdef Q_OS_SYMBIAN - void selectIAP(); -#endif - void openRamFile(); - void configureEffect(); - void hasVideoChanged(bool); - -private: - bool playPauseForDialog(); -#ifdef Q_OS_SYMBIAN - void selectIAPL(); -#endif - - QIcon playIcon; - QIcon pauseIcon; - QMenu *fileMenu; - QPushButton *playButton; - QPushButton *rewindButton; - QPushButton *forwardButton; - Phonon::SeekSlider *slider; - QLabel *timeLabel; - QLabel *progressLabel; - Phonon::VolumeSlider *volume; - QSlider *m_hueSlider; - QSlider *m_satSlider; - QSlider *m_contSlider; - QLabel *info; - Phonon::Effect *nextEffect; - QDialog *settingsDialog; - Ui_settings *ui; - QAction *m_fullScreenAction; - - QWidget m_videoWindow; - Phonon::MediaObject m_MediaObject; - Phonon::AudioOutput m_AudioOutput; - MediaVideoWidget *m_videoWidget; - Phonon::Path m_audioOutputPath; - bool m_smallScreen; -}; - -#endif //MEDIAPLAYER_H diff --git a/demos/qmediaplayer/mediaplayer.qrc b/demos/qmediaplayer/mediaplayer.qrc deleted file mode 100644 index bcdf404..0000000 --- a/demos/qmediaplayer/mediaplayer.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/screen.png - - diff --git a/demos/qmediaplayer/qmediaplayer.pro b/demos/qmediaplayer/qmediaplayer.pro deleted file mode 100644 index 14cfb6f..0000000 --- a/demos/qmediaplayer/qmediaplayer.pro +++ /dev/null @@ -1,39 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Aug 23 18:02:14 2007 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . build src ui - -QT += phonon - -FORMS += settings.ui -RESOURCES += mediaplayer.qrc - -!win32:CONFIG += CONSOLE - -SOURCES += main.cpp mediaplayer.cpp -HEADERS += mediaplayer.h - -target.path = $$[QT_INSTALL_DEMOS]/qtphonon/qmediaplayer -sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.html *.doc images -sources.path = $$[QT_INSTALL_DEMOS]/qtphonon/qmediaplayer -INSTALLS += target sources - -wince*{ -DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout -} - -symbian { - TARGET.UID3 = 0xA000C613 - - addFiles.files = ../embedded/desktopservices/data/sax.mp3 - addFiles.path = /data/sounds/ - DEPLOYMENT += addFiles - - CONFIG += qt_demo - - LIBS += -lcommdb - - TARGET.CAPABILITY="NetworkServices" -} diff --git a/demos/qmediaplayer/settings.ui b/demos/qmediaplayer/settings.ui deleted file mode 100644 index 03bd70e..0000000 --- a/demos/qmediaplayer/settings.ui +++ /dev/null @@ -1,495 +0,0 @@ - - - settings - - - - 0 - 0 - 175 - 397 - - - - Settings - - - - - - Video options: - - - true - - - - - - QComboBox::AdjustToContentsOnFirstShow - - - - Fit in view - - - - - Scale and crop - - - - - - - - Contrast: - - - - - - - - 0 - 0 - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Brightness: - - - - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Saturation: - - - - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Hue: - - - - - - - -8 - - - 8 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 4 - - - - - - - Aspect ratio: - - - - - - - QComboBox::AdjustToContentsOnFirstShow - - - - Auto - - - - - Stretch - - - - - 4/3 - - - - - 16/9 - - - - - - - - Scale Mode: - - - - - scalemodeCombo - label_9 - contrastSlider - label_8 - brightnessSlider - label_7 - saturationSlider - label_2 - hueSlider - label_10 - aspectCombo - label_11 - - - - - - Audio options: - - - true - - - - - - - - - 0 - 0 - - - - - 10 - 0 - - - - Audio device: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - - 10 - 0 - - - - QComboBox::AdjustToMinimumContentsLength - - - - - - - - - - - - 0 - 0 - - - - - 10 - 0 - - - - Audio effect: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - - 10 - 0 - - - - QComboBox::AdjustToMinimumContentsLength - - - - - - - false - - - Setup - - - - - - - - - - - - 0 - 0 - - - - - 10 - 0 - - - - Cross fade: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - 0 - 0 - - - - -20 - - - 20 - - - 1 - - - 2 - - - 0 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - - - - - - - - 9 - - - - -10 Sec - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - - - - - 9 - - - - 0 - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - - - - - 9 - - - - 10 Sec - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - settings - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - settings - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/examples/phonon/phonon.pro b/examples/phonon/phonon.pro index ee1e018..4246f75 100644 --- a/examples/phonon/phonon.pro +++ b/examples/phonon/phonon.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = qmusicplayer \ +SUBDIRS = qmediaplayer \ + qmusicplayer \ capabilities # Disable capabilities example for symbian-gcce due to a bug in elf2e32. diff --git a/examples/phonon/qmediaplayer/images/screen.png b/examples/phonon/qmediaplayer/images/screen.png new file mode 100644 index 0000000..a15df92 Binary files /dev/null and b/examples/phonon/qmediaplayer/images/screen.png differ diff --git a/examples/phonon/qmediaplayer/main.cpp b/examples/phonon/qmediaplayer/main.cpp new file mode 100644 index 0000000..aee7d2b --- /dev/null +++ b/examples/phonon/qmediaplayer/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#include +#include "mediaplayer.h" + +const qreal DefaultVolume = -1.0; + +int main (int argc, char *argv[]) +{ + Q_INIT_RESOURCE(mediaplayer); + QApplication app(argc, argv); + app.setApplicationName("Media Player"); + app.setOrganizationName("Qt"); + app.setQuitOnLastWindowClosed(true); + + QString fileName; + qreal volume = DefaultVolume; + bool smallScreen = false; +#ifdef Q_OS_SYMBIAN + smallScreen = true; +#endif + + 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; + player.setSmallScreen(smallScreen); + if (DefaultVolume != volume) + player.setVolume(volume); + if (!fileName.isNull()) + player.setFile(fileName); + + if (smallScreen) + player.showMaximized(); + else + player.show(); + + return app.exec(); +} + diff --git a/examples/phonon/qmediaplayer/mediaplayer.cpp b/examples/phonon/qmediaplayer/mediaplayer.cpp new file mode 100644 index 0000000..91f24b7 --- /dev/null +++ b/examples/phonon/qmediaplayer/mediaplayer.cpp @@ -0,0 +1,994 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#include + +#define SLIDER_RANGE 8 + +#include "mediaplayer.h" +#include "ui_settings.h" + +#ifdef Q_OS_SYMBIAN +#include +#include +#include +#endif + +MediaVideoWidget::MediaVideoWidget(MediaPlayer *player, QWidget *parent) : + Phonon::VideoWidget(parent), m_player(player), m_action(this) +{ + m_action.setCheckable(true); + m_action.setChecked(false); + m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); + m_action.setShortcutContext(Qt::WindowShortcut); + connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); + addAction(&m_action); + setAcceptDrops(true); +} + +void MediaVideoWidget::setFullScreen(bool enabled) +{ + Phonon::VideoWidget::setFullScreen(enabled); + emit fullScreenChanged(enabled); +} + +void MediaVideoWidget::mouseDoubleClickEvent(QMouseEvent *e) +{ + Phonon::VideoWidget::mouseDoubleClickEvent(e); + setFullScreen(!isFullScreen()); +} + +void MediaVideoWidget::keyPressEvent(QKeyEvent *e) +{ + if(!e->modifiers()) { + // On non-QWERTY Symbian key-based devices, there is no space key. + // The zero key typically is marked with a space character. + if (e->key() == Qt::Key_Space || e->key() == Qt::Key_0) { + m_player->playPause(); + e->accept(); + return; + } + + // On Symbian devices, there is no key which maps to Qt::Key_Escape + // On devices which lack a backspace key (i.e. non-QWERTY devices), + // the 'C' key maps to Qt::Key_Backspace + else if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Backspace) { + setFullScreen(false); + e->accept(); + return; + } + } + Phonon::VideoWidget::keyPressEvent(e); +} + +bool MediaVideoWidget::event(QEvent *e) +{ + switch(e->type()) + { + case QEvent::Close: + //we just ignore the cose events on the video widget + //this prevents ALT+F4 from having an effect in fullscreen mode + e->ignore(); + return true; + case QEvent::MouseMove: +#ifndef QT_NO_CURSOR + unsetCursor(); +#endif + //fall through + case QEvent::WindowStateChange: + { + //we just update the state of the checkbox, in case it wasn't already + m_action.setChecked(windowState() & Qt::WindowFullScreen); + const Qt::WindowFlags flags = m_player->windowFlags(); + if (windowState() & Qt::WindowFullScreen) { + m_timer.start(1000, this); + } else { + m_timer.stop(); +#ifndef QT_NO_CURSOR + unsetCursor(); +#endif + } + } + break; + default: + break; + } + + return Phonon::VideoWidget::event(e); +} + +void MediaVideoWidget::timerEvent(QTimerEvent *e) +{ + if (e->timerId() == m_timer.timerId()) { + //let's store the cursor shape +#ifndef QT_NO_CURSOR + setCursor(Qt::BlankCursor); +#endif + } + Phonon::VideoWidget::timerEvent(e); +} + +void MediaVideoWidget::dropEvent(QDropEvent *e) +{ + m_player->handleDrop(e); +} + +void MediaVideoWidget::dragEnterEvent(QDragEnterEvent *e) { + if (e->mimeData()->hasUrls()) + e->acceptProposedAction(); +} + + +MediaPlayer::MediaPlayer() : + playButton(0), nextEffect(0), settingsDialog(0), ui(0), + m_AudioOutput(Phonon::VideoCategory), + m_videoWidget(new MediaVideoWidget(this)) +{ + setWindowTitle(tr("Media Player")); + setContextMenuPolicy(Qt::CustomContextMenu); + m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + QSize buttonSize(34, 28); + + QPushButton *openButton = new QPushButton(this); + + openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); + QPalette bpal; + QColor arrowcolor = bpal.buttonText().color(); + if (arrowcolor == Qt::black) + arrowcolor = QColor(80, 80, 80); + bpal.setBrush(QPalette::ButtonText, arrowcolor); + openButton->setPalette(bpal); + + rewindButton = new QPushButton(this); + rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); + + forwardButton = new QPushButton(this); + forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); + forwardButton->setEnabled(false); + + playButton = new QPushButton(this); + playIcon = style()->standardIcon(QStyle::SP_MediaPlay); + pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); + playButton->setIcon(playIcon); + + slider = new Phonon::SeekSlider(this); + slider->setMediaObject(&m_MediaObject); + volume = new Phonon::VolumeSlider(&m_AudioOutput); + + QVBoxLayout *vLayout = new QVBoxLayout(this); + vLayout->setContentsMargins(8, 8, 8, 8); + + QHBoxLayout *layout = new QHBoxLayout(); + + info = new QLabel(this); + info->setMinimumHeight(70); + info->setAcceptDrops(false); + info->setMargin(2); + info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + info->setLineWidth(2); + info->setAutoFillBackground(true); + + QPalette palette; + palette.setBrush(QPalette::WindowText, Qt::white); +#ifndef Q_WS_MAC + openButton->setMinimumSize(54, buttonSize.height()); + rewindButton->setMinimumSize(buttonSize); + forwardButton->setMinimumSize(buttonSize); + playButton->setMinimumSize(buttonSize); +#endif + info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px"); + info->setPalette(palette); + info->setText(tr("
No media
")); + + volume->setFixedWidth(120); + + layout->addWidget(openButton); + layout->addWidget(rewindButton); + layout->addWidget(playButton); + layout->addWidget(forwardButton); + + layout->addStretch(); + layout->addWidget(volume); + + vLayout->addWidget(info); + initVideoWindow(); + vLayout->addWidget(&m_videoWindow); + QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); + m_videoWindow.hide(); + buttonPanelLayout->addLayout(layout); + + timeLabel = new QLabel(this); + progressLabel = new QLabel(this); + QWidget *sliderPanel = new QWidget(this); + QHBoxLayout *sliderLayout = new QHBoxLayout(); + sliderLayout->addWidget(slider); + sliderLayout->addWidget(timeLabel); + sliderLayout->addWidget(progressLabel); + sliderLayout->setContentsMargins(0, 0, 0, 0); + sliderPanel->setLayout(sliderLayout); + + buttonPanelLayout->addWidget(sliderPanel); + buttonPanelLayout->setContentsMargins(0, 0, 0, 0); +#ifdef Q_OS_MAC + layout->setSpacing(4); + buttonPanelLayout->setSpacing(0); + info->setMinimumHeight(100); + info->setFont(QFont("verdana", 15)); + // QStyle *flatButtonStyle = new QWindowsStyle; + openButton->setFocusPolicy(Qt::NoFocus); + // openButton->setStyle(flatButtonStyle); + // playButton->setStyle(flatButtonStyle); + // rewindButton->setStyle(flatButtonStyle); + // forwardButton->setStyle(flatButtonStyle); + #endif + QWidget *buttonPanelWidget = new QWidget(this); + buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + buttonPanelWidget->setLayout(buttonPanelLayout); + vLayout->addWidget(buttonPanelWidget); + + QHBoxLayout *labelLayout = new QHBoxLayout(); + + vLayout->addLayout(labelLayout); + setLayout(vLayout); + + // Create menu bar: + fileMenu = new QMenu(this); + QAction *openFileAction = fileMenu->addAction(tr("Open &File...")); + QAction *openUrlAction = fileMenu->addAction(tr("Open &Location...")); +#ifdef Q_OS_SYMBIAN + QAction *selectIAPAction = fileMenu->addAction(tr("Select &IAP...")); + connect(selectIAPAction, SIGNAL(triggered(bool)), this, SLOT(selectIAP())); +#endif + QAction *const openLinkAction = fileMenu->addAction(tr("Open &RAM File...")); + + connect(openLinkAction, SIGNAL(triggered(bool)), this, SLOT(openRamFile())); + + fileMenu->addSeparator(); + QMenu *aspectMenu = fileMenu->addMenu(tr("&Aspect ratio")); + QActionGroup *aspectGroup = new QActionGroup(aspectMenu); + connect(aspectGroup, SIGNAL(triggered(QAction*)), this, SLOT(aspectChanged(QAction*))); + aspectGroup->setExclusive(true); + QAction *aspectActionAuto = aspectMenu->addAction(tr("Auto")); + aspectActionAuto->setCheckable(true); + aspectActionAuto->setChecked(true); + aspectGroup->addAction(aspectActionAuto); + QAction *aspectActionScale = aspectMenu->addAction(tr("Scale")); + aspectActionScale->setCheckable(true); + aspectGroup->addAction(aspectActionScale); + QAction *aspectAction16_9 = aspectMenu->addAction(tr("16/9")); + aspectAction16_9->setCheckable(true); + aspectGroup->addAction(aspectAction16_9); + QAction *aspectAction4_3 = aspectMenu->addAction(tr("4/3")); + aspectAction4_3->setCheckable(true); + aspectGroup->addAction(aspectAction4_3); + + QMenu *scaleMenu = fileMenu->addMenu(tr("&Scale mode")); + QActionGroup *scaleGroup = new QActionGroup(scaleMenu); + connect(scaleGroup, SIGNAL(triggered(QAction*)), this, SLOT(scaleChanged(QAction*))); + scaleGroup->setExclusive(true); + QAction *scaleActionFit = scaleMenu->addAction(tr("Fit in view")); + scaleActionFit->setCheckable(true); + scaleActionFit->setChecked(true); + scaleGroup->addAction(scaleActionFit); + QAction *scaleActionCrop = scaleMenu->addAction(tr("Scale and crop")); + scaleActionCrop->setCheckable(true); + scaleGroup->addAction(scaleActionCrop); + + m_fullScreenAction = fileMenu->addAction(tr("Full screen video")); + m_fullScreenAction->setCheckable(true); + m_fullScreenAction->setEnabled(false); // enabled by hasVideoChanged + bool b = connect(m_fullScreenAction, SIGNAL(toggled(bool)), m_videoWidget, SLOT(setFullScreen(bool))); + Q_ASSERT(b); + b = connect(m_videoWidget, SIGNAL(fullScreenChanged(bool)), m_fullScreenAction, SLOT(setChecked(bool))); + Q_ASSERT(b); + + fileMenu->addSeparator(); + QAction *settingsAction = fileMenu->addAction(tr("&Settings...")); + + // Setup signal connections: + connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind())); + //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + openButton->setMenu(fileMenu); + + connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); + connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); + //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(showSettingsDialog())); + connect(openUrlAction, SIGNAL(triggered(bool)), this, SLOT(openUrl())); + connect(openFileAction, SIGNAL(triggered(bool)), this, SLOT(openFile())); + + connect(m_videoWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); + connect(&m_MediaObject, SIGNAL(metaDataChanged()), this, SLOT(updateInfo())); + connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); + connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime())); + connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); + connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); + connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); + connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); + + rewindButton->setEnabled(false); + playButton->setEnabled(false); + setAcceptDrops(true); + + m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); + Phonon::createPath(&m_MediaObject, m_videoWidget); + + resize(minimumSizeHint()); +} + +void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) +{ + Q_UNUSED(oldstate); + + if (oldstate == Phonon::LoadingState) { + QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); + QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); + if (!m_smallScreen) { + if (m_MediaObject.hasVideo()) { + // Flush event que so that sizeHint takes the + // recently shown/hidden m_videoWindow into account: + qApp->processEvents(); + resize(sizeHint()); + } else + resize(minimumSize()); + } + } + + switch (newstate) { + case Phonon::ErrorState: + if (m_MediaObject.errorType() == Phonon::FatalError) { + playButton->setEnabled(false); + rewindButton->setEnabled(false); + } else { + m_MediaObject.pause(); + } + QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close); + break; + + case Phonon::StoppedState: + m_videoWidget->setFullScreen(false); + // Fall through + case Phonon::PausedState: + playButton->setIcon(playIcon); + if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ + playButton->setEnabled(true); + rewindButton->setEnabled(true); + } else { + playButton->setEnabled(false); + rewindButton->setEnabled(false); + } + break; + case Phonon::PlayingState: + playButton->setEnabled(true); + playButton->setIcon(pauseIcon); + if (m_MediaObject.hasVideo()) + m_videoWindow.show(); + // Fall through + case Phonon::BufferingState: + rewindButton->setEnabled(true); + break; + case Phonon::LoadingState: + rewindButton->setEnabled(false); + break; + } + +} + +void MediaPlayer::initSettingsDialog() +{ + settingsDialog = new QDialog(this); + ui = new Ui_settings(); + ui->setupUi(settingsDialog); + + connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrightness(int))); + connect(ui->hueSlider, SIGNAL(valueChanged(int)), this, SLOT(setHue(int))); + connect(ui->saturationSlider, SIGNAL(valueChanged(int)), this, SLOT(setSaturation(int))); + connect(ui->contrastSlider , SIGNAL(valueChanged(int)), this, SLOT(setContrast(int))); + connect(ui->aspectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setAspect(int))); + connect(ui->scalemodeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setScale(int))); + + ui->brightnessSlider->setValue(int(m_videoWidget->brightness() * SLIDER_RANGE)); + ui->hueSlider->setValue(int(m_videoWidget->hue() * SLIDER_RANGE)); + ui->saturationSlider->setValue(int(m_videoWidget->saturation() * SLIDER_RANGE)); + ui->contrastSlider->setValue(int(m_videoWidget->contrast() * SLIDER_RANGE)); + ui->aspectCombo->setCurrentIndex(m_videoWidget->aspectRatio()); + ui->scalemodeCombo->setCurrentIndex(m_videoWidget->scaleMode()); + connect(ui->effectButton, SIGNAL(clicked()), this, SLOT(configureEffect())); + +#ifdef Q_WS_X11 + //Cross fading is not currently implemented in the GStreamer backend + ui->crossFadeSlider->setVisible(false); + ui->crossFadeLabel->setVisible(false); + ui->crossFadeLabel1->setVisible(false); + ui->crossFadeLabel2->setVisible(false); + ui->crossFadeLabel3->setVisible(false); +#endif + ui->crossFadeSlider->setValue((int)(2 * m_MediaObject.transitionTime() / 1000.0f)); + + // Insert audio devices: + QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); + for (int i=0; ideviceCombo->addItem(itemText); + if (devices[i] == m_AudioOutput.outputDevice()) + ui->deviceCombo->setCurrentIndex(i); + } + + // Insert audio effects: + ui->audioEffectsCombo->addItem(tr("")); + QList currEffects = m_audioOutputPath.effects(); + Phonon::Effect *currEffect = currEffects.size() ? currEffects[0] : 0; + QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + for (int i=0; iaudioEffectsCombo->addItem(availableEffects[i].name()); + if (currEffect && availableEffects[i] == currEffect->description()) + ui->audioEffectsCombo->setCurrentIndex(i+1); + } + connect(ui->audioEffectsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(effectChanged())); + +} + +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(); + if (currentIndex) { + QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + Phonon::EffectDescription chosenEffect = availableEffects[currentIndex - 1]; + + QList currEffects = m_audioOutputPath.effects(); + Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; + + // Deleting the running effect will stop playback, it is deleted when removed from path + if (nextEffect && !(currentEffect && (currentEffect->description().name() == nextEffect->description().name()))) + delete nextEffect; + + nextEffect = new Phonon::Effect(chosenEffect); + } + ui->effectButton->setEnabled(currentIndex); +} + +void MediaPlayer::showSettingsDialog() +{ + const bool hasPausedForDialog = playPauseForDialog(); + + if (!settingsDialog) + initSettingsDialog(); + + float oldBrightness = m_videoWidget->brightness(); + float oldHue = m_videoWidget->hue(); + float oldSaturation = m_videoWidget->saturation(); + float oldContrast = m_videoWidget->contrast(); + Phonon::VideoWidget::AspectRatio oldAspect = m_videoWidget->aspectRatio(); + Phonon::VideoWidget::ScaleMode oldScale = m_videoWidget->scaleMode(); + int currentEffect = ui->audioEffectsCombo->currentIndex(); + settingsDialog->exec(); + + if (settingsDialog->result() == QDialog::Accepted){ + m_MediaObject.setTransitionTime((int)(1000 * float(ui->crossFadeSlider->value()) / 2.0f)); + QList devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); + m_AudioOutput.setOutputDevice(devices[ui->deviceCombo->currentIndex()]); + QList currEffects = m_audioOutputPath.effects(); + QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + + if (ui->audioEffectsCombo->currentIndex() > 0){ + Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; + if (!currentEffect || currentEffect->description() != nextEffect->description()){ + foreach(Phonon::Effect *effect, currEffects) { + m_audioOutputPath.removeEffect(effect); + delete effect; + } + m_audioOutputPath.insertEffect(nextEffect); + } + } else { + foreach(Phonon::Effect *effect, currEffects) { + m_audioOutputPath.removeEffect(effect); + delete effect; + nextEffect = 0; + } + } + } else { + // Restore previous settings + m_videoWidget->setBrightness(oldBrightness); + m_videoWidget->setSaturation(oldSaturation); + m_videoWidget->setHue(oldHue); + m_videoWidget->setContrast(oldContrast); + m_videoWidget->setAspectRatio(oldAspect); + m_videoWidget->setScaleMode(oldScale); + ui->audioEffectsCombo->setCurrentIndex(currentEffect); + } + + if (hasPausedForDialog) + m_MediaObject.play(); +} + +void MediaPlayer::initVideoWindow() +{ + QVBoxLayout *videoLayout = new QVBoxLayout(); + videoLayout->addWidget(m_videoWidget); + videoLayout->setContentsMargins(0, 0, 0, 0); + m_videoWindow.setLayout(videoLayout); + m_videoWindow.setMinimumSize(100, 100); +} + + +void MediaPlayer::configureEffect() +{ + if (!nextEffect) + return; + + + QList currEffects = m_audioOutputPath.effects(); + const QList availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + if (ui->audioEffectsCombo->currentIndex() > 0) { + Phonon::EffectDescription chosenEffect = availableEffects[ui->audioEffectsCombo->currentIndex() - 1]; + + QDialog effectDialog; + effectDialog.setWindowTitle(tr("Configure effect")); + QVBoxLayout *topLayout = new QVBoxLayout(&effectDialog); + + QLabel *description = new QLabel("Description:
" + chosenEffect.description(), &effectDialog); + description->setWordWrap(true); + topLayout->addWidget(description); + + QScrollArea *scrollArea = new QScrollArea(&effectDialog); + topLayout->addWidget(scrollArea); + + QVariantList savedParamValues; + foreach(Phonon::EffectParameter param, nextEffect->parameters()) { + savedParamValues << nextEffect->parameterValue(param); + } + + QWidget *scrollWidget = new Phonon::EffectWidget(nextEffect); + scrollWidget->setMinimumWidth(320); + scrollWidget->setContentsMargins(10, 10, 10,10); + scrollArea->setWidget(scrollWidget); + + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &effectDialog); + connect(bbox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), &effectDialog, SLOT(accept())); + connect(bbox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), &effectDialog, SLOT(reject())); + topLayout->addWidget(bbox); + + effectDialog.exec(); + + if (effectDialog.result() != QDialog::Accepted) { + //we need to restore the parameters values + int currentIndex = 0; + foreach(Phonon::EffectParameter param, nextEffect->parameters()) { + nextEffect->setParameterValue(param, savedParamValues.at(currentIndex++)); + } + + } + } +} + +void MediaPlayer::handleDrop(QDropEvent *e) +{ + QList urls = e->mimeData()->urls(); + if (e->proposedAction() == Qt::MoveAction){ + // Just add to the queue: + for (int i=0; i 0) { + QString fileName = urls[0].toLocalFile(); + QDir dir(fileName); + if (dir.exists()) { + dir.setFilter(QDir::Files); + QStringList entries = dir.entryList(); + if (entries.size() > 0) { + setFile(fileName + QDir::separator() + entries[0]); + for (int i=1; i< entries.size(); ++i) + m_MediaObject.enqueue(fileName + QDir::separator() + entries[i]); + } + } else { + setFile(fileName); + for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); + m_MediaObject.play(); +} + +void MediaPlayer::dropEvent(QDropEvent *e) +{ + if (e->mimeData()->hasUrls() && e->proposedAction() != Qt::LinkAction) { + e->acceptProposedAction(); + handleDrop(e); + } else { + e->ignore(); + } +} + +void MediaPlayer::dragEnterEvent(QDragEnterEvent *e) +{ + dragMoveEvent(e); +} + +void MediaPlayer::dragMoveEvent(QDragMoveEvent *e) +{ + if (e->mimeData()->hasUrls()) { + if (e->proposedAction() == Qt::CopyAction || e->proposedAction() == Qt::MoveAction){ + e->acceptProposedAction(); + } + } +} + +void MediaPlayer::playPause() +{ + if (m_MediaObject.state() == Phonon::PlayingState) + m_MediaObject.pause(); + else { + if (m_MediaObject.currentTime() == m_MediaObject.totalTime()) + m_MediaObject.seek(0); + m_MediaObject.play(); + } +} + +void MediaPlayer::setFile(const QString &fileName) +{ + setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); + m_MediaObject.play(); +} + +void MediaPlayer::setLocation(const QString& location) +{ + setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8()))); + m_MediaObject.play(); +} + +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_smallScreen && m_MediaObject.hasVideo()) { + if (Phonon::PlayingState == m_MediaObject.state()) { + m_MediaObject.pause(); + return true; + } + } + return false; +} + +void MediaPlayer::openFile() +{ + const bool hasPausedForDialog = playPauseForDialog(); + + QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), + QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + + if (hasPausedForDialog) + m_MediaObject.play(); + + m_MediaObject.clearQueue(); + if (fileNames.size() > 0) { + QString fileName = fileNames[0]; + setFile(fileName); + for (int i=1; isetEnabled(m_MediaObject.queue().size() > 0); +} + +void MediaPlayer::bufferStatus(int percent) +{ + if (percent == 100) + progressLabel->setText(QString()); + else { + QString str = QString::fromLatin1("(%1%)").arg(percent); + progressLabel->setText(str); + } +} + +void MediaPlayer::setSaturation(int val) +{ + m_videoWidget->setSaturation(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setHue(int val) +{ + m_videoWidget->setHue(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setAspect(int val) +{ + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio(val)); +} + +void MediaPlayer::setScale(int val) +{ + m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleMode(val)); +} + +void MediaPlayer::setBrightness(int val) +{ + m_videoWidget->setBrightness(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setContrast(int val) +{ + m_videoWidget->setContrast(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::updateInfo() +{ + int maxLength = 30; + QString font = ""; + QString fontmono = ""; + + QMap metaData = m_MediaObject.metaData(); + QString trackArtist = metaData.value("ARTIST"); + if (trackArtist.length() > maxLength) + trackArtist = trackArtist.left(maxLength) + "..."; + + QString trackTitle = metaData.value("TITLE"); + int trackBitrate = metaData.value("BITRATE").toInt(); + + QString fileName; + if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { + fileName = m_MediaObject.currentSource().url().toString(); + } else { + fileName = m_MediaObject.currentSource().fileName(); + fileName = fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1); + if (fileName.length() > maxLength) + fileName = fileName.left(maxLength) + "..."; + } + + QString title; + if (!trackTitle.isEmpty()) { + if (trackTitle.length() > maxLength) + trackTitle = trackTitle.left(maxLength) + "..."; + title = "Title: " + font + trackTitle + "
"; + } else if (!fileName.isEmpty()) { + if (fileName.length() > maxLength) + fileName = fileName.left(maxLength) + "..."; + title = font + fileName + "
"; + if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { + title.prepend("Url: "); + } else { + title.prepend("File: "); + } + } + + QString artist; + if (!trackArtist.isEmpty()) + artist = "Artist: " + font + trackArtist + ""; + + QString bitrate; + if (trackBitrate != 0) + bitrate = "
Bitrate: " + font + QString::number(trackBitrate/1000) + "kbit"; + + info->setText(title + artist + bitrate); +} + +void MediaPlayer::updateTime() +{ + long len = m_MediaObject.totalTime(); + long pos = m_MediaObject.currentTime(); + QString timeString; + if (pos || len) + { + int sec = pos/1000; + int min = sec/60; + int hour = min/60; + int msec = pos; + + QTime playTime(hour%60, min%60, sec%60, msec%1000); + sec = len / 1000; + min = sec / 60; + hour = min / 60; + msec = len; + + QTime stopTime(hour%60, min%60, sec%60, msec%1000); + QString timeFormat = "m:ss"; + if (hour > 0) + timeFormat = "h:mm:ss"; + timeString = playTime.toString(timeFormat); + if (len) + timeString += " / " + stopTime.toString(timeFormat); + } + timeLabel->setText(timeString); +} + +void MediaPlayer::rewind() +{ + m_MediaObject.seek(0); +} + +void MediaPlayer::forward() +{ + QList queue = m_MediaObject.queue(); + if (queue.size() > 0) { + m_MediaObject.setCurrentSource(queue[0]); + forwardButton->setEnabled(queue.size() > 1); + m_MediaObject.play(); + } +} + +void MediaPlayer::openUrl() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + QString sourceURL = settings.value("location").toString(); + bool ok = false; + sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); + if (ok && !sourceURL.isEmpty()) { + setLocation(sourceURL); + settings.setValue("location", sourceURL); + } +} + +/*! + \since 4.6 + */ +void MediaPlayer::openRamFile() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + + const QStringList fileNameList(QFileDialog::getOpenFileNames(this, + QString(), + settings.value("openRamFile").toString(), + QLatin1String("RAM files (*.ram)"))); + + if (fileNameList.isEmpty()) + return; + + QFile linkFile; + QList list; + QByteArray sourceURL; + for (int i = 0; i < fileNameList.count(); i++ ) { + linkFile.setFileName(fileNameList[i]); + if (linkFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + while (!linkFile.atEnd()) { + sourceURL = linkFile.readLine().trimmed(); + if (!sourceURL.isEmpty()) { + const QUrl url(QUrl::fromEncoded(sourceURL)); + if (url.isValid()) + list.append(url); + } + } + linkFile.close(); + } + } + + if (!list.isEmpty()) { + m_MediaObject.clearQueue(); + setLocation(list[0].toString()); + for (int i = 1; i < list.count(); i++) + m_MediaObject.enqueue(Phonon::MediaSource(list[i])); + m_MediaObject.play(); + } + + forwardButton->setEnabled(!m_MediaObject.queue().isEmpty()); + settings.setValue("openRamFile", fileNameList[0]); +} + +void MediaPlayer::finished() +{ +} + +void MediaPlayer::showContextMenu(const QPoint &p) +{ + fileMenu->popup(m_videoWidget->isFullScreen() ? p : mapToGlobal(p)); +} + +void MediaPlayer::scaleChanged(QAction *act) +{ + if (act->text() == tr("Scale and crop")) + m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleAndCrop); + else + m_videoWidget->setScaleMode(Phonon::VideoWidget::FitInView); +} + +void MediaPlayer::aspectChanged(QAction *act) +{ + if (act->text() == tr("16/9")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio16_9); + else if (act->text() == tr("Scale")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioWidget); + else if (act->text() == tr("4/3")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio4_3); + else + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); +} + +void MediaPlayer::hasVideoChanged(bool bHasVideo) +{ + info->setVisible(!bHasVideo); + m_videoWindow.setVisible(bHasVideo); + m_fullScreenAction->setEnabled(bHasVideo); +} + +#ifdef Q_OS_SYMBIAN +void MediaPlayer::selectIAP() +{ + TRAPD(err, selectIAPL()); + if (KErrNone != err) + QMessageBox::warning(this, "Phonon Mediaplayer", "Error selecting IAP", QMessageBox::Close); +} + +void MediaPlayer::selectIAPL() +{ + QVariant currentIAPValue = m_MediaObject.property("InternetAccessPointName"); + QString currentIAPString = currentIAPValue.toString(); + bool ok = false; + CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP); + CleanupStack::PushL(commsDb); + commsDb->ShowHiddenRecords(); + CCommsDbTableView* view = commsDb->OpenTableLC(TPtrC(IAP)); + QStringList items; + TInt currentIAP = 0; + for (TInt l = view->GotoFirstRecord(), i = 0; l != KErrNotFound; l = view->GotoNextRecord(), i++) { + TBuf iapName; + view->ReadTextL(TPtrC(COMMDB_NAME), iapName); + QString iapString = QString::fromUtf16(iapName.Ptr(), iapName.Length()); + items << iapString; + if (iapString == currentIAPString) + currentIAP = i; + } + currentIAPString = QInputDialog::getItem(this, tr("Select Access Point"), tr("Select Access Point"), items, currentIAP, false, &ok); + if (ok) + m_MediaObject.setProperty("InternetAccessPointName", currentIAPString); + CleanupStack::PopAndDestroy(2); //commsDB, view +} +#endif diff --git a/examples/phonon/qmediaplayer/mediaplayer.h b/examples/phonon/qmediaplayer/mediaplayer.h new file mode 100644 index 0000000..0b9dcf3 --- /dev/null +++ b/examples/phonon/qmediaplayer/mediaplayer.h @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#ifndef MEDIALAYER_H +#define MEDIAPLAYER_H + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QPushButton; +class QLabel; +class QSlider; +class QTextEdit; +class QMenu; +class Ui_settings; +QT_END_NAMESPACE + +class MediaPlayer; + +class MediaVideoWidget : public Phonon::VideoWidget +{ + Q_OBJECT + +public: + MediaVideoWidget(MediaPlayer *player, QWidget *parent = 0); + +public slots: + // Over-riding non-virtual Phonon::VideoWidget slot + void setFullScreen(bool); + +signals: + void fullScreenChanged(bool); + +protected: + void mouseDoubleClickEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent *e); + bool event(QEvent *e); + void timerEvent(QTimerEvent *e); + void dropEvent(QDropEvent *e); + void dragEnterEvent(QDragEnterEvent *e); + +private: + MediaPlayer *m_player; + QBasicTimer m_timer; + QAction m_action; +}; + +class MediaPlayer : + public QWidget +{ + Q_OBJECT +public: + MediaPlayer(); + + void dragEnterEvent(QDragEnterEvent *e); + void dragMoveEvent(QDragMoveEvent *e); + void dropEvent(QDropEvent *e); + void handleDrop(QDropEvent *e); + void setFile(const QString &text); + void setLocation(const QString &location); + void initVideoWindow(); + void initSettingsDialog(); + void setVolume(qreal volume); + void setSmallScreen(bool smallScreen); + +public slots: + void openFile(); + void rewind(); + void forward(); + void updateInfo(); + void updateTime(); + void finished(); + void playPause(); + void scaleChanged(QAction *); + void aspectChanged(QAction *); + +private slots: + void setAspect(int); + void setScale(int); + void setSaturation(int); + void setContrast(int); + void setHue(int); + void setBrightness(int); + void stateChanged(Phonon::State newstate, Phonon::State oldstate); + void effectChanged(); + void showSettingsDialog(); + void showContextMenu(const QPoint& point); + void bufferStatus(int percent); + void openUrl(); +#ifdef Q_OS_SYMBIAN + void selectIAP(); +#endif + void openRamFile(); + void configureEffect(); + void hasVideoChanged(bool); + +private: + bool playPauseForDialog(); +#ifdef Q_OS_SYMBIAN + void selectIAPL(); +#endif + + QIcon playIcon; + QIcon pauseIcon; + QMenu *fileMenu; + QPushButton *playButton; + QPushButton *rewindButton; + QPushButton *forwardButton; + Phonon::SeekSlider *slider; + QLabel *timeLabel; + QLabel *progressLabel; + Phonon::VolumeSlider *volume; + QSlider *m_hueSlider; + QSlider *m_satSlider; + QSlider *m_contSlider; + QLabel *info; + Phonon::Effect *nextEffect; + QDialog *settingsDialog; + Ui_settings *ui; + QAction *m_fullScreenAction; + + QWidget m_videoWindow; + Phonon::MediaObject m_MediaObject; + Phonon::AudioOutput m_AudioOutput; + MediaVideoWidget *m_videoWidget; + Phonon::Path m_audioOutputPath; + bool m_smallScreen; +}; + +#endif //MEDIAPLAYER_H diff --git a/examples/phonon/qmediaplayer/mediaplayer.qrc b/examples/phonon/qmediaplayer/mediaplayer.qrc new file mode 100644 index 0000000..bcdf404 --- /dev/null +++ b/examples/phonon/qmediaplayer/mediaplayer.qrc @@ -0,0 +1,5 @@ + + + images/screen.png + + diff --git a/examples/phonon/qmediaplayer/qmediaplayer.pro b/examples/phonon/qmediaplayer/qmediaplayer.pro new file mode 100644 index 0000000..901cf5e --- /dev/null +++ b/examples/phonon/qmediaplayer/qmediaplayer.pro @@ -0,0 +1,39 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Thu Aug 23 18:02:14 2007 +###################################################################### + +TEMPLATE = app +DEPENDPATH += . build src ui + +QT += phonon + +FORMS += settings.ui +RESOURCES += mediaplayer.qrc + +!win32:CONFIG += CONSOLE + +SOURCES += main.cpp mediaplayer.cpp +HEADERS += mediaplayer.h + +target.path = $$[QT_INSTALL_EXAMPLES]/phonon/qmediaplayer +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.html *.doc images +sources.path = $$[QT_INSTALL_EXAMPLES]/phonon/qmediaplayer +INSTALLS += target sources + +wince*{ +DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout +} + +symbian { + TARGET.UID3 = 0xA000C613 + + addFiles.files = ../embedded/desktopservices/data/sax.mp3 + addFiles.path = /data/sounds/ + DEPLOYMENT += addFiles + + CONFIG += qt_demo + + LIBS += -lcommdb + + TARGET.CAPABILITY="NetworkServices" +} diff --git a/examples/phonon/qmediaplayer/settings.ui b/examples/phonon/qmediaplayer/settings.ui new file mode 100644 index 0000000..03bd70e --- /dev/null +++ b/examples/phonon/qmediaplayer/settings.ui @@ -0,0 +1,495 @@ + + + settings + + + + 0 + 0 + 175 + 397 + + + + Settings + + + + + + Video options: + + + true + + + + + + QComboBox::AdjustToContentsOnFirstShow + + + + Fit in view + + + + + Scale and crop + + + + + + + + Contrast: + + + + + + + + 0 + 0 + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Brightness: + + + + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Saturation: + + + + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Hue: + + + + + + + -8 + + + 8 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 4 + + + + + + + Aspect ratio: + + + + + + + QComboBox::AdjustToContentsOnFirstShow + + + + Auto + + + + + Stretch + + + + + 4/3 + + + + + 16/9 + + + + + + + + Scale Mode: + + + + + scalemodeCombo + label_9 + contrastSlider + label_8 + brightnessSlider + label_7 + saturationSlider + label_2 + hueSlider + label_10 + aspectCombo + label_11 + + + + + + Audio options: + + + true + + + + + + + + + 0 + 0 + + + + + 10 + 0 + + + + Audio device: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + + 10 + 0 + + + + QComboBox::AdjustToMinimumContentsLength + + + + + + + + + + + + 0 + 0 + + + + + 10 + 0 + + + + Audio effect: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + + 10 + 0 + + + + QComboBox::AdjustToMinimumContentsLength + + + + + + + false + + + Setup + + + + + + + + + + + + 0 + 0 + + + + + 10 + 0 + + + + Cross fade: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + 0 + 0 + + + + -20 + + + 20 + + + 1 + + + 2 + + + 0 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + + + + + + + + 9 + + + + -10 Sec + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + 9 + + + + 0 + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + 9 + + + + 10 Sec + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + settings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + settings + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- cgit v1.2.3