[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bphonon/mrl=5D_demos/simpleplayer=3A_MRL_for_simplep?=
From:       Harald Sitter <sitter () kde ! org>
Date:       2011-02-28 22:11:48
Message-ID: 20110228221148.9EA3CA60C9 () git ! kde ! org
[Download RAW message or body]

Git commit ae41a4f16c0c12efcd88d6c451651b5de31305df by Harald Sitter.
Committed on 28/02/2011 at 23:10.
Pushed by sitter into branch 'mrl'.

MRL for simpleplayer

While I am at it, also fix up coding style a bit.

M  +8    -5    demos/simpleplayer/main.cpp     
M  +20   -18   demos/simpleplayer/player.cpp     
M  +8    -8    demos/simpleplayer/player.h     

http://commits.kde.org/phonon/ae41a4f16c0c12efcd88d6c451651b5de31305df

diff --git a/demos/simpleplayer/main.cpp b/demos/simpleplayer/main.cpp
index 56f3dda..00e7340 100644
--- a/demos/simpleplayer/main.cpp
+++ b/demos/simpleplayer/main.cpp
@@ -6,7 +6,7 @@
     License as published by the Free Software Foundation; either
     version 2.1 of the License, or (at your option) version 3, or any
     later version accepted by the membership of KDE e.V. (or its
-    successor approved by the membership of KDE e.V.), Nokia Corporation 
+    successor approved by the membership of KDE e.V.), Nokia Corporation
     (or its successors, if any) and the KDE Free Qt Foundation, which shall
     act as a proxy defined in Section 6 of version 3 of the license.
 
@@ -15,14 +15,17 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Lesser General Public License for more details.
 
-    You should have received a copy of the GNU Lesser General Public 
+    You should have received a copy of the GNU Lesser General Public
     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */
+
 #include <QtGui/QApplication>
-#include <QtCore/QUrl>
+
+#include <phonon/Mrl>
+
 #include "player.h"
 
-int main(int argc, char** argv)
+int main(int argc, char **argv)
 {
     QApplication app(argc, argv);
 
@@ -35,7 +38,7 @@ int main(int argc, char** argv)
     //Not passing an argument of what to play will prompt for a file inside \
Player::load(), called by Player::playPause()  QStringList args = \
QApplication::arguments();  if (args.size() > 1) {
-        p.load(QUrl(args[1]));
+        p.load(Phonon::Mrl(args[1]));
     }
 
     return app.exec();
diff --git a/demos/simpleplayer/player.cpp b/demos/simpleplayer/player.cpp
index 7a09720..46949f3 100644
--- a/demos/simpleplayer/player.cpp
+++ b/demos/simpleplayer/player.cpp
@@ -6,7 +6,7 @@
     License as published by the Free Software Foundation; either
     version 2.1 of the License, or (at your option) version 3, or any
     later version accepted by the membership of KDE e.V. (or its
-    successor approved by the membership of KDE e.V.), Nokia Corporation 
+    successor approved by the membership of KDE e.V.), Nokia Corporation
     (or its successors, if any) and the KDE Free Qt Foundation, which shall
     act as a proxy defined in Section 6 of version 3 of the license.
 
@@ -15,27 +15,29 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Lesser General Public License for more details.
 
-    You should have received a copy of the GNU Lesser General Public 
+    You should have received a copy of the GNU Lesser General Public
     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "player.h"
 
+#include <QtGui/QFileDialog>
 #include <QtGui/QHBoxLayout>
-#include <QtGui/QVBoxLayout>
 #include <QtGui/QPushButton>
-#include <QtGui/QFileDialog>
-#include <phonon/MediaObject>
+#include <QtGui/QVBoxLayout>
+
 #include <phonon/AudioOutput>
-#include <phonon/VideoWidget>
+#include <phonon/MediaObject>
+#include <phonon/Mrl>
 #include <phonon/SeekSlider>
+#include <phonon/VideoWidget>
 
-Player::Player(QWidget* parent, Qt::WindowFlags f)
-    : QWidget(parent, f)
+Player::Player(QWidget* parent, Qt::WindowFlags flags)
+    : QWidget(parent, flags)
 {
     m_media = new Phonon::MediaObject(this);
 
-    Phonon::AudioOutput* audioOut = new Phonon::AudioOutput(Phonon::VideoCategory, \
                this);
-    Phonon::VideoWidget* videoOut = new Phonon::VideoWidget(this);
+    Phonon::AudioOutput *audioOut = new Phonon::AudioOutput(Phonon::VideoCategory, \
this); +    Phonon::VideoWidget *videoOut = new Phonon::VideoWidget(this);
     videoOut->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     //By default, there is no minimum size on a video widget. While the default
     //size is controlled by Qt's layouting system it makes sense to provide a
@@ -52,7 +54,7 @@ Player::Player(QWidget* parent, Qt::WindowFlags f)
     Phonon::createPath(m_media, videoOut);
 
     //This widget will contain the stop/pause buttons
-    QWidget* buttonBar = new QWidget(this);
+    QWidget *buttonBar = new QWidget(this);
 
     m_playPause = new QPushButton(tr("Play"), buttonBar);
     m_stop = new QPushButton(tr("Stop"), buttonBar);
@@ -60,13 +62,13 @@ Player::Player(QWidget* parent, Qt::WindowFlags f)
     Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider(this);
     seekSlider->setMediaObject(m_media);
 
-    QVBoxLayout* layout = new QVBoxLayout(this);
+    QVBoxLayout *layout = new QVBoxLayout(this);
     layout->addWidget(videoOut);
     layout->addWidget(seekSlider);
     layout->addWidget(buttonBar);
     setLayout(layout);
 
-    QHBoxLayout* buttonLayout = new QHBoxLayout(buttonBar);
+    QHBoxLayout *buttonLayout = new QHBoxLayout(buttonBar);
     buttonLayout->addWidget(m_stop);
     buttonLayout->addWidget(m_playPause);
     buttonBar->setLayout(buttonLayout);
@@ -92,12 +94,12 @@ void Player::playPause()
     }
 }
 
-void Player::load(const QUrl &url)
+void Player::load(const Phonon::Mrl &mrl)
 {
-    if (url.scheme().isEmpty())
-        m_media->setCurrentSource(QUrl::fromLocalFile(url.toString()));
+    if (mrl.scheme().isEmpty())
+        m_media->setCurrentSource(Phonon::Mrl::fromLocalFile(mrl.toString()));
     else
-        m_media->setCurrentSource(url);
+        m_media->setCurrentSource(mrl);
     m_media->play();
 }
 
@@ -106,7 +108,7 @@ void Player::load()
     QString url = QFileDialog::getOpenFileName(this);
     if (url.isEmpty())
         return;
-    load(QUrl::fromLocalFile(url));
+    load(Phonon::Mrl::fromLocalFile(url));
 }
 
 void Player::mediaStateChanged(Phonon::State newState, Phonon::State oldState)
diff --git a/demos/simpleplayer/player.h b/demos/simpleplayer/player.h
index 8f7f8b3..3aec8ad 100644
--- a/demos/simpleplayer/player.h
+++ b/demos/simpleplayer/player.h
@@ -6,7 +6,7 @@
     License as published by the Free Software Foundation; either
     version 2.1 of the License, or (at your option) version 3, or any
     later version accepted by the membership of KDE e.V. (or its
-    successor approved by the membership of KDE e.V.), Nokia Corporation 
+    successor approved by the membership of KDE e.V.), Nokia Corporation
     (or its successors, if any) and the KDE Free Qt Foundation, which shall
     act as a proxy defined in Section 6 of version 3 of the license.
 
@@ -15,19 +15,19 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Lesser General Public License for more details.
 
-    You should have received a copy of the GNU Lesser General Public 
+    You should have received a copy of the GNU Lesser General Public
     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */
 #ifndef PLAYER_H
 #define PLAYER_H
 
 #include <QtGui/QWidget>
-#include <QtCore/QUrl>
 #include <phonon/Global>
 
 class QPushButton;
 namespace Phonon {
     class MediaObject;
+    class Mrl;
 }
 
 /**
@@ -38,14 +38,14 @@ class Player : public QWidget {
 Q_OBJECT
 
 public:
-    Player(QWidget* parent = 0, Qt::WindowFlags f = 0);
+    Player(QWidget *parent = 0, Qt::WindowFlags flag = 0);
 
 public slots:
 
     /**
      * @brief Load a specific URL
      */
-    void load(const QUrl &url);
+    void load(const Phonon::Mrl &url);
 
     /**
      * @brief Prompt the user for a file to load
@@ -65,9 +65,9 @@ private slots:
     void playPause();
 
 private:
-    Phonon::MediaObject* m_media;
-    QPushButton* m_playPause;
-    QPushButton* m_stop;
+    Phonon::MediaObject *m_media;
+    QPushButton *m_playPause;
+    QPushButton *m_stop;
 
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic