| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** All rights reserved. | 
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
|---|
| 6 | ** | 
|---|
| 7 | ** This file is part of the demonstration applications of the Qt Toolkit. | 
|---|
| 8 | ** | 
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 10 | ** Commercial Usage | 
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and Nokia. | 
|---|
| 15 | ** | 
|---|
| 16 | ** GNU Lesser General Public License Usage | 
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 20 | ** packaging of this file.  Please review the following information to | 
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 23 | ** | 
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional | 
|---|
| 25 | ** rights.  These rights are described in the Nokia Qt LGPL Exception | 
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ***************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef MEDIALAYER_H | 
|---|
| 43 | #define MEDIAPLAYER_H | 
|---|
| 44 |  | 
|---|
| 45 | #include <QtGui/QWidget> | 
|---|
| 46 | #include <QtGui/QApplication> | 
|---|
| 47 | #include <QtCore/QTimerEvent> | 
|---|
| 48 | #include <QtGui/QShowEvent> | 
|---|
| 49 | #include <QtGui/QIcon> | 
|---|
| 50 | #include <QtCore/QBasicTimer> | 
|---|
| 51 | #include <QtGui/QAction> | 
|---|
| 52 |  | 
|---|
| 53 | #include <phonon/audiooutput.h> | 
|---|
| 54 | #include <phonon/backendcapabilities.h> | 
|---|
| 55 | #include <phonon/effect.h> | 
|---|
| 56 | #include <phonon/effectparameter.h> | 
|---|
| 57 | #include <phonon/effectwidget.h> | 
|---|
| 58 | #include <phonon/mediaobject.h> | 
|---|
| 59 | #include <phonon/seekslider.h> | 
|---|
| 60 | #include <phonon/videowidget.h> | 
|---|
| 61 | #include <phonon/volumeslider.h> | 
|---|
| 62 |  | 
|---|
| 63 | QT_BEGIN_NAMESPACE | 
|---|
| 64 | class QPushButton; | 
|---|
| 65 | class QLabel; | 
|---|
| 66 | class QSlider; | 
|---|
| 67 | class QTextEdit; | 
|---|
| 68 | class QMenu; | 
|---|
| 69 | class Ui_settings; | 
|---|
| 70 | QT_END_NAMESPACE | 
|---|
| 71 |  | 
|---|
| 72 | class MediaPlayer; | 
|---|
| 73 |  | 
|---|
| 74 | class MediaVideoWidget : public Phonon::VideoWidget | 
|---|
| 75 | { | 
|---|
| 76 | Q_OBJECT | 
|---|
| 77 |  | 
|---|
| 78 | public: | 
|---|
| 79 | MediaVideoWidget(MediaPlayer *player, QWidget *parent = 0); | 
|---|
| 80 |  | 
|---|
| 81 | public slots: | 
|---|
| 82 | // Over-riding non-virtual Phonon::VideoWidget slot | 
|---|
| 83 | void setFullScreen(bool); | 
|---|
| 84 |  | 
|---|
| 85 | signals: | 
|---|
| 86 | void fullScreenChanged(bool); | 
|---|
| 87 |  | 
|---|
| 88 | protected: | 
|---|
| 89 | void mouseDoubleClickEvent(QMouseEvent *e); | 
|---|
| 90 | void keyPressEvent(QKeyEvent *e); | 
|---|
| 91 | bool event(QEvent *e); | 
|---|
| 92 | void timerEvent(QTimerEvent *e); | 
|---|
| 93 | void dropEvent(QDropEvent *e); | 
|---|
| 94 | void dragEnterEvent(QDragEnterEvent *e); | 
|---|
| 95 |  | 
|---|
| 96 | private: | 
|---|
| 97 | MediaPlayer *m_player; | 
|---|
| 98 | QBasicTimer m_timer; | 
|---|
| 99 | QAction m_action; | 
|---|
| 100 | }; | 
|---|
| 101 |  | 
|---|
| 102 | class MediaPlayer : | 
|---|
| 103 | public QWidget | 
|---|
| 104 | { | 
|---|
| 105 | Q_OBJECT | 
|---|
| 106 | public: | 
|---|
| 107 | MediaPlayer(const QString &, | 
|---|
| 108 | const bool hasSmallScreen); | 
|---|
| 109 |  | 
|---|
| 110 | void dragEnterEvent(QDragEnterEvent *e); | 
|---|
| 111 | void dragMoveEvent(QDragMoveEvent *e); | 
|---|
| 112 | void dropEvent(QDropEvent *e); | 
|---|
| 113 | void handleDrop(QDropEvent *e); | 
|---|
| 114 | void setFile(const QString &text); | 
|---|
| 115 | void initVideoWindow(); | 
|---|
| 116 | void initSettingsDialog(); | 
|---|
| 117 |  | 
|---|
| 118 | public slots: | 
|---|
| 119 | void openFile(); | 
|---|
| 120 | void rewind(); | 
|---|
| 121 | void forward(); | 
|---|
| 122 | void updateInfo(); | 
|---|
| 123 | void updateTime(); | 
|---|
| 124 | void finished(); | 
|---|
| 125 | void playPause(); | 
|---|
| 126 | void scaleChanged(QAction *); | 
|---|
| 127 | void aspectChanged(QAction *); | 
|---|
| 128 |  | 
|---|
| 129 | private slots: | 
|---|
| 130 | void setAspect(int); | 
|---|
| 131 | void setScale(int); | 
|---|
| 132 | void setSaturation(int); | 
|---|
| 133 | void setContrast(int); | 
|---|
| 134 | void setHue(int); | 
|---|
| 135 | void setBrightness(int); | 
|---|
| 136 | void stateChanged(Phonon::State newstate, Phonon::State oldstate); | 
|---|
| 137 | void effectChanged(); | 
|---|
| 138 | void showSettingsDialog(); | 
|---|
| 139 | void showContextMenu(const QPoint& point); | 
|---|
| 140 | void bufferStatus(int percent); | 
|---|
| 141 | void openUrl(); | 
|---|
| 142 | void openRamFile(); | 
|---|
| 143 | void configureEffect(); | 
|---|
| 144 | void hasVideoChanged(bool); | 
|---|
| 145 |  | 
|---|
| 146 | private: | 
|---|
| 147 | bool playPauseForDialog(); | 
|---|
| 148 |  | 
|---|
| 149 | QIcon playIcon; | 
|---|
| 150 | QIcon pauseIcon; | 
|---|
| 151 | QMenu *fileMenu; | 
|---|
| 152 | QPushButton *playButton; | 
|---|
| 153 | QPushButton *rewindButton; | 
|---|
| 154 | QPushButton *forwardButton; | 
|---|
| 155 | Phonon::SeekSlider *slider; | 
|---|
| 156 | QLabel *timeLabel; | 
|---|
| 157 | QLabel *progressLabel; | 
|---|
| 158 | Phonon::VolumeSlider *volume; | 
|---|
| 159 | QSlider *m_hueSlider; | 
|---|
| 160 | QSlider *m_satSlider; | 
|---|
| 161 | QSlider *m_contSlider; | 
|---|
| 162 | QLabel *info; | 
|---|
| 163 | Phonon::Effect *nextEffect; | 
|---|
| 164 | QDialog *settingsDialog; | 
|---|
| 165 | Ui_settings *ui; | 
|---|
| 166 | QAction *m_fullScreenAction; | 
|---|
| 167 |  | 
|---|
| 168 | QWidget m_videoWindow; | 
|---|
| 169 | Phonon::MediaObject m_MediaObject; | 
|---|
| 170 | Phonon::AudioOutput m_AudioOutput; | 
|---|
| 171 | MediaVideoWidget *m_videoWidget; | 
|---|
| 172 | Phonon::Path m_audioOutputPath; | 
|---|
| 173 | const bool m_hasSmallScreen; | 
|---|
| 174 | }; | 
|---|
| 175 |  | 
|---|
| 176 | #endif //MEDIAPLAYER_H | 
|---|