diff options
Diffstat (limited to 'demos')
-rw-r--r-- | demos/demos.pro | 2 | ||||
-rw-r--r-- | demos/multimedia/multimedia.pro | 3 | ||||
-rw-r--r-- | demos/multimedia/player/main.cpp | 54 | ||||
-rw-r--r-- | demos/multimedia/player/player.cpp | 372 | ||||
-rw-r--r-- | demos/multimedia/player/player.h | 114 | ||||
-rw-r--r-- | demos/multimedia/player/player.pro | 29 | ||||
-rw-r--r-- | demos/multimedia/player/playercontrols.cpp | 205 | ||||
-rw-r--r-- | demos/multimedia/player/playercontrols.h | 107 | ||||
-rw-r--r-- | demos/multimedia/player/playlistmodel.cpp | 160 | ||||
-rw-r--r-- | demos/multimedia/player/playlistmodel.h | 95 | ||||
-rw-r--r-- | demos/multimedia/player/videowidget.cpp | 78 | ||||
-rw-r--r-- | demos/multimedia/player/videowidget.h | 66 |
12 files changed, 0 insertions, 1285 deletions
diff --git a/demos/demos.pro b/demos/demos.pro index b174135..f359bd7 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -57,7 +57,6 @@ wince*:SUBDIRS += demos_sqlbrowser } contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):!symbian:SUBDIRS += demos_browser -contains(QT_CONFIG, multimedia):SUBDIRS += demos_multimedia contains(QT_CONFIG, declarative):SUBDIRS += demos_declarative contains(QT_CONFIG, multimedia):SUBDIRS += demos_spectrum @@ -90,7 +89,6 @@ demos_sqlbrowser.subdir = sqlbrowser demos_undo.subdir = undo demos_qtdemo.subdir = qtdemo demos_mediaplayer.subdir = qmediaplayer -demos_multimedia.subdir = multimedia demos_declarative.subdir = declarative demos_browser.subdir = browser diff --git a/demos/multimedia/multimedia.pro b/demos/multimedia/multimedia.pro deleted file mode 100644 index fa29a12..0000000 --- a/demos/multimedia/multimedia.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs -contains(QT_CONFIG, mediaservices): SUBDIRS = player - diff --git a/demos/multimedia/player/main.cpp b/demos/multimedia/player/main.cpp deleted file mode 100644 index 87c5b87..0000000 --- a/demos/multimedia/player/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "player.h" - -#include <QtGui> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - Player player; - player.show(); - - return app.exec(); -}; diff --git a/demos/multimedia/player/player.cpp b/demos/multimedia/player/player.cpp deleted file mode 100644 index bf314ee..0000000 --- a/demos/multimedia/player/player.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "player.h" - -#include "playercontrols.h" -#include "playlistmodel.h" -#include "videowidget.h" - -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplaylist.h> - -#include <QtGui> - -Player::Player(QWidget *parent) - : QWidget(parent) - , videoWidget(0) - , coverLabel(0) - , slider(0) - , colorDialog(0) -{ - player = new QMediaPlayer(this); - playlist = new QMediaPlaylist(this); - playlist->setMediaObject(player); - - connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64))); - connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64))); - connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged())); - connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int))); - connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - this, SLOT(statusChanged(QMediaPlayer::MediaStatus))); - connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int))); - - videoWidget = new VideoWidget; - videoWidget->setMediaObject(player); - - playlistModel = new PlaylistModel(this); - playlistModel->setPlaylist(playlist); - - playlistView = new QListView; - playlistView->setModel(playlistModel); - playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0)); - - connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex))); - - playbackModeBox = new QComboBox; - playbackModeBox->addItem(tr("Linear"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Linear)); - playbackModeBox->addItem(tr("Loop"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Loop)); - playbackModeBox->addItem(tr("Random"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Random)); - playbackModeBox->addItem(tr("Current Item Once"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::CurrentItemOnce)); - playbackModeBox->addItem(tr("Current Item In Loop"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::CurrentItemInLoop)); - playbackModeBox->setCurrentIndex(0); - - connect(playbackModeBox, SIGNAL(activated(int)), SLOT(updatePlaybackMode())); - updatePlaybackMode(); - - slider = new QSlider(Qt::Horizontal); - slider->setRange(0, player->duration() / 1000); - - connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int))); - - QPushButton *openButton = new QPushButton(tr("Open")); - - connect(openButton, SIGNAL(clicked()), this, SLOT(open())); - - PlayerControls *controls = new PlayerControls; - controls->setState(player->state()); - controls->setVolume(player->volume()); - controls->setMuted(controls->isMuted()); - - connect(controls, SIGNAL(play()), player, SLOT(play())); - connect(controls, SIGNAL(pause()), player, SLOT(pause())); - connect(controls, SIGNAL(stop()), player, SLOT(stop())); - connect(controls, SIGNAL(next()), playlist, SLOT(next())); - connect(controls, SIGNAL(previous()), this, SLOT(previousClicked())); - connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int))); - connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool))); - connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal))); - - connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), - controls, SLOT(setState(QMediaPlayer::State))); - connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int))); - connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool))); - - QPushButton *fullScreenButton = new QPushButton(tr("FullScreen")); - fullScreenButton->setCheckable(true); - - if (videoWidget != 0) { - connect(fullScreenButton, SIGNAL(clicked(bool)), videoWidget, SLOT(setFullScreen(bool))); - connect(videoWidget, SIGNAL(fullScreenChanged(bool)), - fullScreenButton, SLOT(setChecked(bool))); - } else { - fullScreenButton->setEnabled(false); - } - - QPushButton *colorButton = new QPushButton(tr("Color Options...")); - if (videoWidget) - connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog())); - else - colorButton->setEnabled(false); - - QBoxLayout *playlistLayout = new QVBoxLayout; - playlistLayout->addWidget(playlistView); - playlistLayout->addWidget(playbackModeBox); - - QBoxLayout *displayLayout = new QHBoxLayout; - if (videoWidget) - displayLayout->addWidget(videoWidget, 2); - else - displayLayout->addWidget(coverLabel, 2); - displayLayout->addLayout(playlistLayout); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setMargin(0); - controlLayout->addWidget(openButton); - controlLayout->addStretch(1); - controlLayout->addWidget(controls); - controlLayout->addStretch(1); - controlLayout->addWidget(fullScreenButton); - controlLayout->addWidget(colorButton); - - QBoxLayout *layout = new QVBoxLayout; - layout->addLayout(displayLayout); - layout->addWidget(slider); - layout->addLayout(controlLayout); - - setLayout(layout); - - metaDataChanged(); - - QStringList arguments = qApp->arguments(); - arguments.removeAt(0); - foreach (QString const &argument, arguments) { - QFileInfo fileInfo(argument); - if (fileInfo.exists()) { - QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); - if (fileInfo.suffix().toLower() == QLatin1String("m3u")) { - playlist->load(url); - } else - playlist->addMedia(url); - } else { - QUrl url(argument); - if (url.isValid()) { - playlist->addMedia(url); - } - } - } -} - -Player::~Player() -{ - delete playlist; - delete player; -} - -void Player::open() -{ - QStringList fileNames = QFileDialog::getOpenFileNames(); - foreach (QString const &fileName, fileNames) - playlist->addMedia(QUrl::fromLocalFile(fileName)); -} - -void Player::durationChanged(qint64 duration) -{ - slider->setMaximum(duration / 1000); -} - -void Player::positionChanged(qint64 progress) -{ - slider->setValue(progress / 1000); -} - -void Player::metaDataChanged() -{ - //qDebug() << "update metadata" << player->metaData(QtMediaServices::Title).toString(); - if (player->isMetaDataAvailable()) { - setTrackInfo(QString("%1 - %2") - .arg(player->metaData(QtMediaServices::AlbumArtist).toString()) - .arg(player->metaData(QtMediaServices::Title).toString())); - - if (coverLabel) { - QUrl url = player->metaData(QtMediaServices::CoverArtUrlLarge).value<QUrl>(); - - coverLabel->setPixmap(!url.isEmpty() - ? QPixmap(url.toString()) - : QPixmap()); - } - } -} - -void Player::previousClicked() -{ - // Go to previous track if we are within the first 5 seconds of playback - // Otherwise, seek to the beginning. - if(player->position() <= 5000) - playlist->previous(); - else - player->setPosition(0); -} - -void Player::jump(const QModelIndex &index) -{ - if (index.isValid()) { - playlist->setCurrentIndex(index.row()); - player->play(); - } -} - -void Player::playlistPositionChanged(int currentItem) -{ - playlistView->setCurrentIndex(playlistModel->index(currentItem, 0)); -} - -void Player::seek(int seconds) -{ - player->setPosition(seconds * 1000); -} - -void Player::statusChanged(QMediaPlayer::MediaStatus status) -{ - switch (status) { - case QMediaPlayer::UnknownMediaStatus: - case QMediaPlayer::NoMedia: - case QMediaPlayer::LoadedMedia: - case QMediaPlayer::BufferingMedia: - case QMediaPlayer::BufferedMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(QString()); - break; - case QMediaPlayer::LoadingMedia: -#ifndef QT_NO_CURSOR - setCursor(QCursor(Qt::BusyCursor)); -#endif - setStatusInfo(tr("Loading...")); - break; - case QMediaPlayer::StalledMedia: -#ifndef QT_NO_CURSOR - setCursor(QCursor(Qt::BusyCursor)); -#endif - break; - case QMediaPlayer::EndOfMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(QString()); - QApplication::alert(this); - break; - case QMediaPlayer::InvalidMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(player->errorString()); - break; - } -} - -void Player::bufferingProgress(int progress) -{ - setStatusInfo(tr("Buffering %4%%").arg(progress)); -} - -void Player::setTrackInfo(const QString &info) -{ - trackInfo = info; - - if (!statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo)); - else - setWindowTitle(trackInfo); - -} - -void Player::setStatusInfo(const QString &info) -{ - statusInfo = info; - - if (!statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo)); - else - setWindowTitle(trackInfo); -} - -void Player::showColorDialog() -{ - if (!colorDialog) { - QSlider *brightnessSlider = new QSlider(Qt::Horizontal); - brightnessSlider->setRange(-100, 100); - brightnessSlider->setValue(videoWidget->brightness()); - connect(brightnessSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setBrightness(int))); - connect(videoWidget, SIGNAL(brightnessChanged(int)), brightnessSlider, SLOT(setValue(int))); - - QSlider *contrastSlider = new QSlider(Qt::Horizontal); - contrastSlider->setRange(-100, 100); - contrastSlider->setValue(videoWidget->contrast()); - connect(contrastSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setContrast(int))); - connect(videoWidget, SIGNAL(contrastChanged(int)), contrastSlider, SLOT(setValue(int))); - - QSlider *hueSlider = new QSlider(Qt::Horizontal); - hueSlider->setRange(-100, 100); - hueSlider->setValue(videoWidget->hue()); - connect(hueSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setHue(int))); - connect(videoWidget, SIGNAL(hueChanged(int)), hueSlider, SLOT(setValue(int))); - - QSlider *saturationSlider = new QSlider(Qt::Horizontal); - saturationSlider->setRange(-100, 100); - saturationSlider->setValue(videoWidget->saturation()); - connect(saturationSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setSaturation(int))); - connect(videoWidget, SIGNAL(saturationChanged(int)), saturationSlider, SLOT(setValue(int))); - - QFormLayout *layout = new QFormLayout; - layout->addRow(tr("Brightness"), brightnessSlider); - layout->addRow(tr("Contrast"), contrastSlider); - layout->addRow(tr("Hue"), hueSlider); - layout->addRow(tr("Saturation"), saturationSlider); - - colorDialog = new QDialog(this); - colorDialog->setWindowTitle(tr("Color Options")); - colorDialog->setLayout(layout); - } - colorDialog->show(); -} - -void Player::updatePlaybackMode() -{ - playlist->setPlaybackMode( - playbackModeBox->itemData(playbackModeBox->currentIndex()).value<QMediaPlaylist::PlaybackMode>()); -} diff --git a/demos/multimedia/player/player.h b/demos/multimedia/player/player.h deleted file mode 100644 index cda3eb9..0000000 --- a/demos/multimedia/player/player.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PLAYER_H -#define PLAYER_H - -#include <QtGui/QWidget> - -#include <qmediaplayer.h> -#include <qmediaplaylist.h> -#include <qvideowidget.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractItemView; -class QLabel; -class QModelIndex; -class QSlider; -class QComboBox; -class QMediaPlayer; -class QVideoWidget; -class PlaylistModel; - -class Player : public QWidget -{ - Q_OBJECT -public: - Player(QWidget *parent = 0); - ~Player(); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - -private slots: - void open(); - void durationChanged(qint64 duration); - void positionChanged(qint64 progress); - void metaDataChanged(); - - void previousClicked(); - - void seek(int seconds); - void jump(const QModelIndex &index); - void playlistPositionChanged(int); - - void statusChanged(QMediaPlayer::MediaStatus status); - void bufferingProgress(int progress); - - void showColorDialog(); - void updatePlaybackMode(); - -private: - void setTrackInfo(const QString &info); - void setStatusInfo(const QString &info); - - QMediaPlayer *player; - QMediaPlaylist *playlist; - QVideoWidget *videoWidget; - QLabel *coverLabel; - QSlider *slider; - QComboBox *playbackModeBox; - PlaylistModel *playlistModel; - QAbstractItemView *playlistView; - QDialog *colorDialog; - QString trackInfo; - QString statusInfo; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/player.pro b/demos/multimedia/player/player.pro deleted file mode 100644 index 12bdf64..0000000 --- a/demos/multimedia/player/player.pro +++ /dev/null @@ -1,29 +0,0 @@ -TEMPLATE = app -TARGET = player - -QT += gui mediaservices - -HEADERS = \ - player.h \ - playercontrols.h \ - playlistmodel.h \ - videowidget.h - -SOURCES = \ - main.cpp \ - player.cpp \ - playercontrols.cpp \ - playlistmodel.cpp \ - videowidget.cpp - -target.path = $$[QT_INSTALL_DEMOS]/multimedia/player -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_DEMOS]/multimedia/player - -INSTALLS += target sources - -symbian { - TARGET.UID3 = 0xA000E3FA - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) -} - diff --git a/demos/multimedia/player/playercontrols.cpp b/demos/multimedia/player/playercontrols.cpp deleted file mode 100644 index 3798a71..0000000 --- a/demos/multimedia/player/playercontrols.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "playercontrols.h" - -#include <QtGui/qboxlayout.h> -#include <QtGui/qslider.h> -#include <QtGui/qstyle.h> -#include <QtGui/qtoolbutton.h> -#include <QtGui/qcombobox.h> - -PlayerControls::PlayerControls(QWidget *parent) - : QWidget(parent) - , playerState(QMediaPlayer::StoppedState) - , playerMuted(false) - , playButton(0) - , stopButton(0) - , nextButton(0) - , previousButton(0) - , muteButton(0) - , volumeSlider(0) - , rateBox(0) -{ - playButton = new QToolButton; - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(playButton, SIGNAL(clicked()), this, SLOT(playClicked())); - - stopButton = new QToolButton; - stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); - stopButton->setEnabled(false); - - connect(stopButton, SIGNAL(clicked()), this, SIGNAL(stop())); - - nextButton = new QToolButton; - nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); - - connect(nextButton, SIGNAL(clicked()), this, SIGNAL(next())); - - previousButton = new QToolButton; - previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); - - connect(previousButton, SIGNAL(clicked()), this, SIGNAL(previous())); - - muteButton = new QToolButton; - muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume)); - - connect(muteButton, SIGNAL(clicked()), this, SLOT(muteClicked())); - - volumeSlider = new QSlider(Qt::Horizontal); - volumeSlider->setRange(0, 100); - - connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int))); - - rateBox = new QComboBox; - rateBox->addItem("0.5x", QVariant(0.5)); - rateBox->addItem("1.0x", QVariant(1.0)); - rateBox->addItem("2.0x", QVariant(2.0)); - rateBox->setCurrentIndex(1); - - connect(rateBox, SIGNAL(activated(int)), SLOT(updateRate())); - - QBoxLayout *layout = new QHBoxLayout; - layout->setMargin(0); - layout->addWidget(stopButton); - layout->addWidget(previousButton); - layout->addWidget(playButton); - layout->addWidget(nextButton); - layout->addWidget(muteButton); - layout->addWidget(volumeSlider); - layout->addWidget(rateBox); - setLayout(layout); -} - -QMediaPlayer::State PlayerControls::state() const -{ - return playerState; -} - -void PlayerControls::setState(QMediaPlayer::State state) -{ - if (state != playerState) { - playerState = state; - - switch (state) { - case QMediaPlayer::StoppedState: - stopButton->setEnabled(false); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - case QMediaPlayer::PlayingState: - stopButton->setEnabled(true); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - case QMediaPlayer::PausedState: - stopButton->setEnabled(true); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } - } -} - -int PlayerControls::volume() const -{ - return volumeSlider->value(); -} - -void PlayerControls::setVolume(int volume) -{ - volumeSlider->setValue(volume); -} - -bool PlayerControls::isMuted() const -{ - return playerMuted; -} - -void PlayerControls::setMuted(bool muted) -{ - if (muted != playerMuted) { - playerMuted = muted; - - muteButton->setIcon(style()->standardIcon(muted - ? QStyle::SP_MediaVolumeMuted - : QStyle::SP_MediaVolume)); - } -} - -void PlayerControls::playClicked() -{ - switch (playerState) { - case QMediaPlayer::StoppedState: - case QMediaPlayer::PausedState: - emit play(); - break; - case QMediaPlayer::PlayingState: - emit pause(); - break; - } -} - -void PlayerControls::muteClicked() -{ - emit changeMuting(!playerMuted); -} - -qreal PlayerControls::playbackRate() const -{ - return rateBox->itemData(rateBox->currentIndex()).toDouble(); -} - -void PlayerControls::setPlaybackRate(float rate) -{ - for (int i=0; i<rateBox->count(); i++) { - if (qFuzzyCompare(rate, float(rateBox->itemData(i).toDouble()))) { - rateBox->setCurrentIndex(i); - return; - } - } - - rateBox->addItem( QString("%1x").arg(rate), QVariant(rate)); - rateBox->setCurrentIndex(rateBox->count()-1); -} - -void PlayerControls::updateRate() -{ - emit changeRate(playbackRate()); -} diff --git a/demos/multimedia/player/playercontrols.h b/demos/multimedia/player/playercontrols.h deleted file mode 100644 index d2229bd..0000000 --- a/demos/multimedia/player/playercontrols.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PLAYERCONTROLS_H -#define PLAYERCONTROLS_H - -#include <QtMediaServices/qmediaplayer.h> - -#include <QtGui/qwidget.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractButton; -class QAbstractSlider; -class QComboBox; - -class PlayerControls : public QWidget -{ - Q_OBJECT -public: - PlayerControls(QWidget *parent = 0); - - QMediaPlayer::State state() const; - - int volume() const; - bool isMuted() const; - qreal playbackRate() const; - -public slots: - void setState(QMediaPlayer::State state); - void setVolume(int volume); - void setMuted(bool muted); - void setPlaybackRate(float rate); - -signals: - void play(); - void pause(); - void stop(); - void next(); - void previous(); - void changeVolume(int volume); - void changeMuting(bool muting); - void changeRate(qreal rate); - -private slots: - void playClicked(); - void muteClicked(); - void updateRate(); - -private: - QMediaPlayer::State playerState; - bool playerMuted; - QAbstractButton *playButton; - QAbstractButton *stopButton; - QAbstractButton *nextButton; - QAbstractButton *previousButton; - QAbstractButton *muteButton; - QAbstractSlider *volumeSlider; - QComboBox *rateBox; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/playlistmodel.cpp b/demos/multimedia/player/playlistmodel.cpp deleted file mode 100644 index b60f914..0000000 --- a/demos/multimedia/player/playlistmodel.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "playlistmodel.h" - -#include <QtCore/qfileinfo.h> -#include <QtCore/qurl.h> - -#include <qmediaplaylist.h> - -PlaylistModel::PlaylistModel(QObject *parent) - : QAbstractItemModel(parent) - , m_playlist(0) -{ -} - -int PlaylistModel::rowCount(const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0; -} - -int PlaylistModel::columnCount(const QModelIndex &parent) const -{ - return !parent.isValid() ? ColumnCount : 0; -} - -QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() - && row >= 0 && row < m_playlist->mediaCount() - && column >= 0 && column < ColumnCount - ? createIndex(row, column) - : QModelIndex(); -} - -QModelIndex PlaylistModel::parent(const QModelIndex &child) const -{ - Q_UNUSED(child); - - return QModelIndex(); -} - -QVariant PlaylistModel::data(const QModelIndex &index, int role) const -{ - if (index.isValid() && role == Qt::DisplayRole) { - QVariant value = m_data[index]; - if (!value.isValid() && index.column() == Title) { - QUrl location = m_playlist->media(index.row()).canonicalUrl(); - return QFileInfo(location.path()).fileName(); - } - - return value; - } - return QVariant(); -} - -QMediaPlaylist *PlaylistModel::playlist() const -{ - return m_playlist; -} - -void PlaylistModel::setPlaylist(QMediaPlaylist *playlist) -{ - if (m_playlist) { - disconnect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int))); - disconnect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems())); - disconnect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int))); - disconnect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems())); - disconnect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int))); - } - - m_playlist = playlist; - - if (m_playlist) { - connect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int))); - connect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems())); - connect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int))); - connect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems())); - connect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int))); - } - - - reset(); -} - -bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - Q_UNUSED(role); - m_data[index] = value; - emit dataChanged(index, index); - return true; -} - -void PlaylistModel::beginInsertItems(int start, int end) -{ - m_data.clear(); - beginInsertRows(QModelIndex(), start, end); -} - -void PlaylistModel::endInsertItems() -{ - endInsertRows(); -} - -void PlaylistModel::beginRemoveItems(int start, int end) -{ - m_data.clear(); - beginRemoveRows(QModelIndex(), start, end); -} - -void PlaylistModel::endRemoveItems() -{ - endInsertRows(); -} - -void PlaylistModel::changeItems(int start, int end) -{ - m_data.clear(); - emit dataChanged(index(start,0), index(end,ColumnCount)); -} - - diff --git a/demos/multimedia/player/playlistmodel.h b/demos/multimedia/player/playlistmodel.h deleted file mode 100644 index 0180282..0000000 --- a/demos/multimedia/player/playlistmodel.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PLAYLISTMODEL_H -#define PLAYLISTMODEL_H - -#include <QtCore/qabstractitemmodel.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylist; - -class PlaylistModel : public QAbstractItemModel -{ - Q_OBJECT -public: - enum Column - { - Title = 0, - ColumnCount - }; - - PlaylistModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - - QMediaPlaylist *playlist() const; - void setPlaylist(QMediaPlaylist *playlist); - - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole); - -private slots: - void beginInsertItems(int start, int end); - void endInsertItems(); - void beginRemoveItems(int start, int end); - void endRemoveItems(); - void changeItems(int start, int end); - -private: - QMediaPlaylist *m_playlist; - QMap<QModelIndex, QVariant> m_data; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/videowidget.cpp b/demos/multimedia/player/videowidget.cpp deleted file mode 100644 index be864ec..0000000 --- a/demos/multimedia/player/videowidget.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "videowidget.h" - -#include <QtGui> - -VideoWidget::VideoWidget(QWidget *parent) - : QVideoWidget(parent) -{ - setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - - QPalette p = palette(); - p.setColor(QPalette::Window, Qt::black); - setPalette(p); - - setAttribute(Qt::WA_OpaquePaintEvent); -} - -void VideoWidget::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_Escape && isFullScreen()) { - showNormal(); - - event->accept(); - } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) { - setFullScreen(!isFullScreen()); - - event->accept(); - } else { - QVideoWidget::keyPressEvent(event); - } -} - -void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event) -{ - setFullScreen(!isFullScreen()); - - event->accept(); -} diff --git a/demos/multimedia/player/videowidget.h b/demos/multimedia/player/videowidget.h deleted file mode 100644 index b5bf581..0000000 --- a/demos/multimedia/player/videowidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include <QtMediaServices/qvideowidget.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class VideoWidget : public QVideoWidget -{ - Q_OBJECT -public: - VideoWidget(QWidget *parent = 0); - -protected: - void keyPressEvent(QKeyEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif |