Bug 102668 - support for media:/ URLs
Summary: support for media:/ URLs
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
: 101671 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-03-28 14:37 UTC by Till
Modified: 2006-06-11 12:32 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
load media:/ urls like local files (1.09 KB, patch)
2005-06-01 17:08 UTC, Sergio Cambra
Details
load media:/ urls like local files (1.51 KB, patch)
2005-06-22 12:57 UTC, Sergio Cambra
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till 2005-03-28 14:37:56 UTC
Version:            1.1.1 (using KDE KDE 3.4.0)
Installed from:    Debian testing/unstable Packages
OS:                Linux

Amarok doesn't play files from a media:/ URL. Playing from a "normal" mounted location works (e.g. /cdrom). Bug 101671 may be related, but I don't really get what the reporter wants to tell us. Here is some console output though I don't know if this helps:

amarok: [aRts-Engine] Loading url: media:/cdrom/De-Phazz/De-Phazz%20-%20Godsdog/03-Jazz%20Music.mp3
amarok: aRts-Engine: url.path()     == /cdrom/De-Phazz/De-Phazz - Godsdog/03-Jazz Music.mp3
amarok: aRts-Engine: url.protocol() == media
amarok: aRts-Engine: url.host()     == 
amarok: aRts-Engine: url.port()     == 0
amarok: [virtual bool ArtsEngine::load(const KURL&, bool)]  m_pPlayObject->object().isNull()
Comment 1 Till 2005-03-28 14:58:57 UTC
Just upgraded. Same Problem exists with amarok 1.2.1
Comment 2 Till 2005-04-02 13:04:53 UTC
Just found out that this is obviously a problem with the arts-engine. Playing media:/ URLs works fine with the gstreamer-engine.
Comment 3 Sergio Cambra 2005-06-01 03:44:35 UTC
To support media:/ URLs like local files, it's possible decode to a path, like kaffeine:
http://cvs.sourceforge.net/viewcvs.py/kaffeine/kaffeine/kaffeine/kaffeineapp.cpp?r1=1.21&r2=1.22
Comment 4 Sergio Cambra 2005-06-01 17:08:31 UTC
Created attachment 11285 [details]
load media:/ urls like local files

It modifies playlistloader.cpp to decode media URLs to local paths and then all
engines can play media URLs and can seek in them, like with files in hard disk.
Comment 5 Sergio Cambra 2005-06-01 17:11:10 UTC
If you apply that patch, add media should permit media:/ URLs instead only local files.
Comment 6 Sergio Cambra 2005-06-06 17:01:09 UTC
With 1.3beta I can add media:/ URLs, but I can't play it with xine engine. With the patch I sent before, the URL is resolved to a file:/ URL and I can play it like a file in hard disk.
Comment 7 Sergio Cambra 2005-06-22 12:56:55 UTC
Comment on attachment 11285 [details]
load media:/ urls like local files

I'll send a patch with comments
Comment 8 Sergio Cambra 2005-06-22 12:57:56 UTC
Created attachment 11540 [details]
load media:/ urls like local files

The previous patch with comments
Comment 9 Mark Kretschmann 2005-06-24 09:43:14 UTC
SVN commit 428454 by markey:

Support for "media:/" URLs. Patch from  
Sergio Cambra <sergio@ensanjose.net>

Sergio writes:
Some engines doesn't understand media:/ URLs, like xine, but media:/ URLs 
are local files too, and it's easy convert these urls to local files using 
DCOP, and then all engines can seek in those files like files in hard 
disk.

I sent a patch to fix it in bug #102668. I applied that patch to 1.2.4 and 
to 1.3 beta1 and works with no problem. I have attached that patch too.

CCMAIL: sergio@ensanjose.net
CCMAIL: amarok-devel@lists.sf.net
BUG: 102668



 M  +2 -0      ChangeLog  
 M  +23 -0     src/playlistloader.cpp  


--- trunk/extragear/multimedia/amarok/ChangeLog #428453:428454
@@ -5,6 +5,8 @@
 
 VERSION 1.3-beta2:
   FEATURES:
+    * Support for "media:" URLs. Patch by Sergio Cambra <sergio@ensanjose.net>
+      (BR 102668)
     * Support for visualizations in the Helix engine.
     * Queue manager to help organise your queued tracks. (BR 90594)
     * Ability to create Smart Playlists based on file path. (BR 92467)
--- trunk/extragear/multimedia/amarok/src/playlistloader.cpp #428453:428454
@@ -26,6 +26,7 @@
 #include <qstringlist.h>
 #include <qtextstream.h> //::loadPlaylist()
 #include "statusbar.h"
+#include <dcopref.h>
 
 
 typedef QValueList<QDomNode> NodeList;
@@ -68,6 +69,28 @@
                 m_URLs += url;
         }
 
+       else if( protocol == "media" ) {
+            // url looks like media:/device/path
+            DCOPRef mediamanager( "kded", "mediamanager" );
+            QString device = url.path( -1 ).mid( 1 ); // remove first slash
+            const int slash = device.find( '/' );
+            const QString filePath = device.mid( slash ); // extract relative path
+            device = device.left( slash ); // extract device
+            DCOPReply reply = mediamanager.call( "properties(QString)", device );
+
+            if( reply.isValid() ) {
+                const QStringList properties = reply;
+                // properties[6] is the mount point
+                KURL localUrl = KURL( properties[6] + filePath );
+
+                // add urls
+                if( QFileInfo( localUrl.path() ).isDir() )
+                    m_URLs += recurse( localUrl );
+                else
+                    m_URLs += localUrl;
+            }
+        }
+
         else if( PlaylistFile::isPlaylistFile( url ) ) {
             new RemotePlaylistFetcher( url, after, m_playFirstUrl );
             m_playFirstUrl = false;
Comment 10 Thiago Macieira 2005-06-25 02:42:04 UTC
You shouldn't hardcode "media".

You should instead use KIO::stat and use mostLocalURL.
Comment 11 Sergio Cambra 2005-06-25 13:59:44 UTC
I think mostLocalURL doesn't exist in KDE 3.3, and amarok depends on it.
Comment 12 Thiago Macieira 2005-06-25 16:00:29 UTC
media:/ doesn't exist in KDE 3.3 either, but I see your point.

Can you add a "FIXME" for when amaroK no longer depends on KDE 3.3? That should happen at least for KDE4.
Comment 13 Kevin Ottens 2005-06-26 18:00:05 UTC
Thiago is right, media:/ uses UDS_LOCAL_PATH, and it's not the only one to do
this. Starting with KDE 3.5 it'll become even "worse", since home:/ is
introduced using the same technics.

To solve your issue in a generic way, you could define KIO::UDS_LOCAL_PATH which is equal to "72 | UDS_STRING" (defined in kdelibs/kio/kio/global.h in
trunk). Stating a file and search for the atom having this id number would
be enough. 
 
It's definitely a workaround but would be far better than using DCOP for this. 
And it would work with other ioslaves using UDS_LOCAL_PATH.
Comment 14 Thiago Macieira 2005-10-04 06:21:10 UTC
*** Bug 101671 has been marked as a duplicate of this bug. ***
Comment 15 Juuso Alasuutari 2006-05-31 00:13:27 UTC
Why hasn't this been implemented in 1.4.0?