[mpris] kdereview/dragonplayer

Ian Monroe ian.monroe at gmail.com
Wed Jan 16 22:39:10 CET 2008


SVN commit 762366 by ianmonroe:

New DBus API, kind of a subset of MPRIS. Can't really do the full thing since
Dragon Player doesn't have a playlist.
CCMAIL:mpris at videolan.org


 M  +1 -0      ChangeLog  
 M  +4 -1      TODO  
 M  +5 -1      src/app/CMakeLists.txt  
 M  +0 -1      src/app/fullScreenAction.cpp  
 M  +6 -3      src/app/mainWindow.cpp  
 M  +7 -4      src/app/mainWindow.h  
 M  +17 -0     src/app/stateChange.cpp  
 M  +31 -7     src/app/videoWindow.cpp  
 M  +6 -2      src/app/videoWindow.h  
 A             src/dbus (directory)  
 A             src/dbus/org.kde.dragon.player.xml  
 A             src/dbus/playerDbusHandler.cpp   [License: GPL (v2/3)]
 A             src/dbus/playerDbusHandler.h   [License: UNKNOWN]


--- trunk/kdereview/dragonplayer/ChangeLog #762365:762366
@@ -3,6 +3,7 @@
    Can turn off subtitles
    Can revert to the 'auto' audio channel
    Save subtitle and audio channel selection
+   New DBus API under /Player
  
 2.0-beta1
    Fix hang on close when paused
--- trunk/kdereview/dragonplayer/TODO #762365:762366
@@ -4,11 +4,14 @@
 *external subtitle support
 *'o' in fullscreen mode shows OSD of length and elapsed time info, <-- emulate mplayer
 *indiciate remote media somehow in PlayDialog
-*DBus interface, subset of the VideoLAN Dbus API
+*DBus interface, subset of the VideoLAN Dbus API (done)
 *resume DVD playback, probably requires remembering chapter and stuff which might need 
 more Phonon API
+*Look into using LiveConnectExtension to provide a WMP or RealPlayer-like 
+JavaScript interface for the kpart. KMplayer apparently does this.
 
 _Thoughts_:
+*a movie-like rolling credits instead of the about dialog
 *PlayDialog optimization
     *show an icon in the previously played list, indicating whether its audio or video. (done)
     *allow filtering by audio/video? too confusing?
--- trunk/kdereview/dragonplayer/src/app/CMakeLists.txt #762365:762366
@@ -15,7 +15,11 @@
     playlistFile.cpp
     main.cpp
     timeLabel.cpp
-    mainWindow.cpp )
+    mainWindow.cpp 
+    ../dbus/playerDbusHandler.cpp )
+
+qt4_add_dbus_adaptor( videoplayer_app_SRCS ../dbus/org.kde.dragon.player.xml ../dbus/playerDbusHandler.h PlayerDbusHandler )
+
 kde4_add_ui_files(videoplayer_app_SRCS videoSettingsWidget.ui)
 
 kde4_add_executable(dragon ${videoplayer_app_SRCS} )
--- trunk/kdereview/dragonplayer/src/app/fullScreenAction.cpp #762365:762366
@@ -35,7 +35,6 @@
     setObjectName( "fullscreen" );
     setShortcut( Qt::Key_F );
     parent->addAction( objectName(), this );
-    connect( this, SIGNAL( toggled( bool ) ), Codeine::mainWindow(), SLOT( setFullScreen( bool ) ) );
 }
 
 void
--- trunk/kdereview/dragonplayer/src/app/mainWindow.cpp #762365:762366
@@ -55,6 +55,7 @@
 #include <QTimer>
 
 #include "actions.h"
+#include "dbus/playerDbusHandler.h"
 #include "debug.h"
 #include "extern.h"         //dialog creation function definitions
 #include "fullScreenAction.h"
@@ -172,7 +173,6 @@
 MainWindow::init()
 {
     DEBUG_BLOCK
-
     connect( engine(), SIGNAL( statusMessage( const QString& ) ), this, SLOT( engineMessage( const QString&   ) ) );
     connect( engine(), SIGNAL( stateChanged( Engine::State ) ), this, SLOT( engineStateChanged( Engine::State ) ) );
     connect( engine(), SIGNAL( titleChanged( const QString& ) ), m_titleLabel, SLOT( setText( const QString&  ) ) );
@@ -197,8 +197,8 @@
     statusBar()->addPermanentWidget( m_titleLabel, 100 );
     statusBar()->addPermanentWidget( m_timeLabel );
 
+    new PlayerDbusHandler( this );
 
-
     QApplication::restoreOverrideCursor();
     engineStateChanged( Engine::Empty );
     if( !kapp->isSessionRestored() ) {
@@ -236,6 +236,7 @@
     KStandardAction::quit( kapp, SLOT( closeAllWindows() ), ac );
     KStandardAction::open( this, SLOT(playMedia()), ac )->setText( i18n("Play &Media...") );
     m_fullScreenAction = new FullScreenAction( this, ac );
+    connect( m_fullScreenAction, SIGNAL( toggled( bool ) ), Codeine::mainWindow(), SLOT( setFullScreen( bool ) ) );
 
     new PlayAction( this, SLOT( play() ), ac );
     new VolumeAction( this, SLOT( toggleVolumeSlider( bool ) ), ac );
@@ -401,8 +402,10 @@
 {
     switch( engine()->state() ) {
     case Engine::Playing:
+        engine()->pause();
+        break;
     case Engine::Paused:
-        engine()->playPause();
+        engine()->play();
         break;
     case Engine::Loaded:
         break;
--- trunk/kdereview/dragonplayer/src/app/mainWindow.h #762365:762366
@@ -54,19 +54,23 @@
       friend int ::main( int, char** );
       friend QWidget* mainWindow();
 
-      enum { SubtitleChannelsMenuItemId = 2000, AudioChannelsMenuItemId, AspectRatioMenuItemId };
-
    public:
       void openRecentFile( const KUrl& );
+      bool open( const KUrl& );
+
+   signals:
+      void dbusStatusChanged( int );
+      void fileChanged( QString );
+
    public slots:
       void play();
       void playMedia( bool show_welcome_dialog = false );
-      void setFullScreen( bool full );
       void toggleVideoSettings( bool );
       void toggleVolumeSlider( bool );
       void playDialogResult( int result );
 
    private slots:
+      void setFullScreen( bool full );
       void engineMessage( const QString& );
       void engineStateChanged( Engine::State );
       void init();
@@ -76,7 +80,6 @@
       void audioChannelsChanged( QList< QAction* > );
 
    private:
-      bool open( const KUrl& );
       void setupActions();
       void updateSliders();
 
--- trunk/kdereview/dragonplayer/src/app/stateChange.cpp #762365:762366
@@ -35,6 +35,7 @@
 
 #include "actions.h"
 #include "adjustSizeButton.h"
+#include "dbus/playerDbusHandler.h"
 #include "debug.h"
 #include "fullScreenAction.h"
 #include "mxcl.library.h"
@@ -137,6 +138,7 @@
     /// update recent files list if necessary
     if( state == Engine::Loaded ) 
     {
+        emit fileChanged( engine()->urlOrDisc() );
         // update recently played list
         debug() << " update recent files list ";
         #ifndef NO_SKIP_PR0N
@@ -233,6 +235,21 @@
             toolBar()->hide();
             break;
         }
+    } 
+    switch( state )
+    {
+        case Engine::TrackEnded:
+        case Engine::Empty:
+            emit dbusStatusChanged( PlayerDbusHandler::Stopped ), debug() << "dbus: stopped";
+            break;
+        case Engine::Paused:
+            emit dbusStatusChanged( PlayerDbusHandler::Paused ), debug() << "dbus: paused";
+            break;
+        case Engine::Playing:
+            emit dbusStatusChanged( PlayerDbusHandler::Playing ), debug() << "dbus: playing";
+            break;
+        break;
+        default: break;
     }
     /*
     ///hide videoWindow if audio-only
--- trunk/kdereview/dragonplayer/src/app/videoWindow.cpp #762365:762366
@@ -233,14 +233,32 @@
 }
 
 void
-VideoWindow::playPause()
+VideoWindow::pause()
 {
-    if( m_media->state() == Phonon::PlayingState )
-        m_media->pause();
-    else
-        m_media->play();
+    m_media->pause();
 }
 
+QString
+VideoWindow::urlOrDisc()
+{
+    Phonon::MediaSource source = m_media->currentSource();
+    switch( source.type() )
+    {
+        case Phonon::MediaSource::Invalid:
+            return "Invalid"; //no i18n, used for DBus responses
+            break;
+        case Phonon::MediaSource::Url:
+        case Phonon::MediaSource::LocalFile:
+            return source.url().toString();
+            break;
+        case Phonon::MediaSource::Disc:
+            return source.deviceName();
+            break;
+        case Phonon::MediaSource::Stream:
+            return "Data Stream";
+            break;
+    }
+}
 
 Engine::State
 VideoWindow::state() const
@@ -289,13 +307,19 @@
     }
 }
 
-uint
+qreal
 VideoWindow::volume() const
 {
-    return static_cast<uint>( m_aOutput->volume() * 1.0 );
+    return m_aOutput->volume();
 }
 
 void
+VideoWindow::setVolume( qreal vol )
+{
+    m_aOutput->setVolume( vol );
+}
+
+void
 VideoWindow::seek( qint64 pos )
 {
     DEBUG_BLOCK
--- trunk/kdereview/dragonplayer/src/app/videoWindow.h #762365:762366
@@ -85,7 +85,12 @@
         qint64 length() const;
         bool isDVD() const;
 
-        uint volume() const;
+        ///stuff for dbus:
+        void pause();
+        qreal volume() const;
+        void setVolume( qreal );
+        QString urlOrDisc();
+
         QWidget* newPositionSlider();
         QWidget* newVolumeSlider();
         void loadSettings();
@@ -106,7 +111,6 @@
         const xine_stream_t* xineStream() const { return m_xineStream; }
 
     public slots:
-        void playPause();
         void seek( qint64 );
         void stop();
         void stateChanged( Phonon::State, Phonon::State );



More information about the mpris mailing list