Bug 136106 - [PATCH] Enable playing audio CDs in Amarok on CD insert
Summary: [PATCH] Enable playing audio CDs in Amarok on CD insert
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist (vote)
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-21 22:44 UTC by Will Stephenson
Modified: 2006-10-22 09:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch implementing feature (5.51 KB, patch)
2006-10-21 22:45 UTC, Will Stephenson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Will Stephenson 2006-10-21 22:44:32 UTC
Version:           1.4.4 (using KDE KDE 3.5.3)
Installed from:    Compiled From Sources

The attached patch enables amarok to be invoked with 
amarok --cdplay system:/media/hdx by kded's mediamanager, on cd insert, and adds a service menu desktop file.

The code is mostly the same as that in kscd and kaffeine, and uses a dcop call to kded mediamanager to resolve the actual device to play from.  This is the only way at present to work it out.
Comment 1 Will Stephenson 2006-10-21 22:45:03 UTC
Created attachment 18219 [details]
Patch implementing feature
Comment 2 Martin Aumueller 2006-10-21 23:21:26 UTC
SVN commit 597863 by aumuell:

apply patch for playing audio cds on insertion
BUG: 136106


 M  +1 -0      ChangeLog  
 M  +2 -1      src/Makefile.am  
 A             src/amarok_play_audiocd.desktop  
 M  +3 -0      src/app.cpp  
 M  +22 -0     src/devicemanager.cpp  
 M  +6 -0      src/devicemanager.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #597862:597863
@@ -29,6 +29,7 @@
 
 
   CHANGES:
+    * Enable playing audio CDs on CD insert. (BR 136106)
     * Bring Amarok main window to front when starting amarok again without
       arguments. (BR 135396)
     * Don't switch to playlist browser after saving a playlist from files tab.
--- trunk/extragear/multimedia/amarok/src/Makefile.am #597862:597863
@@ -224,7 +224,8 @@
 
 servicemenu_DATA = \
     amarok_addaspodcast.desktop \
-    amarok_append.desktop
+    amarok_append.desktop \
+    amarok_play_audiocd.desktop
 
 
 profiledatadir = \
--- trunk/extragear/multimedia/amarok/src/app.cpp #597862:597863
@@ -25,6 +25,7 @@
 #include "collectionbrowser.h"
 #include "dbsetup.h"             //firstRunWizard()
 #include "debug.h"
+#include "devicemanager.h"
 #include "mediadevicemanager.h"
 #include "enginebase.h"
 #include "enginecontroller.h"
@@ -277,6 +278,7 @@
     {
         haveArgs = true;
         QString device = args->getOption("cdplay");
+        device = DeviceManager::instance()->convertMediaUrlToDevice( device );
         KURL::List urls;
         if (EngineController::engine()->getAudioCDContents(device, urls)) {
             Playlist::instance()->insertMedia(
@@ -335,6 +337,7 @@
             { "engine <name>", I18N_NOOP( "Use the <name> engine" ), 0 },
             { "cwd <directory>", I18N_NOOP( "Base for relative filenames/URLs" ), 0 },
             { "cdplay <device>", I18N_NOOP("Play an AudioCD from <device>"), 0 },
+            //FIXME: after string freeze { "cdplay <device>", I18N_NOOP("Play an AudioCD from <device> or system:/media/<device>"), 0 },
             { 0, 0, 0 }
         };
 
--- trunk/extragear/multimedia/amarok/src/devicemanager.cpp #597862:597863
@@ -24,6 +24,7 @@
 
 #include <dcopclient.h>
 #include <dcopobject.h>
+#include <dcopref.h>
 #include <kapplication.h>
 
 typedef Medium::List MediumList;
@@ -226,4 +227,25 @@
     return returnedMedium;
 }
 
+QString DeviceManager::convertMediaUrlToDevice( QString url )
+{
+    QString device;
+    if ( url.startsWith( "media:" ) || url.startsWith( "system:" ) )
+    {
+        KURL devicePath( url );
+        DCOPRef mediamanager( "kded", "mediamanager" );
+        DCOPReply reply = mediamanager.call( "properties(QString)", devicePath.fileName() );
+        if ( reply.isValid() ) {
+            QStringList properties = reply;
+            device = properties[ 5 ];
+            //kdDebug() << "DeviceManager::convertMediaUrlToDevice() munged to: " << device << "\n";
+        } else
+            device = QString();
+    }
+    else
+        device = url;
+
+    return device;
+}
+
 #include "devicemanager.moc"
--- trunk/extragear/multimedia/amarok/src/devicemanager.h #597862:597863
@@ -54,6 +54,12 @@
         //warning about getDeviceList()
         QStringList getDeviceStringList();
 
+        // Converts a media://media/hdc URL as provided by the KDE media
+        // manager on CD insert to /dev/hdc so amarok can play it.
+        // This method is safe to call with a device path, it returns it
+        // unchanged.
+        QString convertMediaUrlToDevice( QString url );
+
     signals:
         void mediumAdded( const Medium*, QString );
         void mediumChanged( const Medium*, QString );
Comment 3 Seb Ruiz 2006-10-22 09:06:48 UTC
SVN commit 597963 by seb:

SVN_SILENT Give bille the credit he deserves for his audiocd patch.
CCBUG: 136106


 M  +2 -1      ChangeLog  


--- trunk/extragear/multimedia/amarok/ChangeLog #597962:597963
@@ -29,7 +29,8 @@
 
 
   CHANGES:
-    * Enable playing audio CDs on CD insert. (BR 136106)
+    * Enable playing audio CDs on CD insert. Patch by Will Stephenson
+      <wstephenson@kde.org>. (BR 136106)
     * Bring Amarok main window to front when starting amarok again without
       arguments. (BR 135396)
     * Don't switch to playlist browser after saving a playlist from files tab.