[banshee] PlayerEngineService: Obtain library or metadata info for opened uris



commit 2af263ed6cd2d5ac73c9128a51deb9f98e02db73
Author: Carlos Sanchez <chukysoria gmail com>
Date:   Sat May 7 00:09:27 2011 +0200

    PlayerEngineService: Obtain library or metadata info for opened uris
    
    When opening a file from a uri, instead of creating an unknown track,
    try to find the uri on the library or extract the metadata from the
    file.
    This only affects the Open method used by the D-Bus interfaces. The
    various other ways to open a file use different code paths.
    
    Fixes bgo#636071.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 .../Banshee.MediaEngine/PlayerEngineService.cs     |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs b/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
index 59bcf72..cc6c70d 100644
--- a/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
+++ b/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
@@ -42,6 +42,7 @@ using Banshee.Metadata;
 using Banshee.Configuration;
 using Banshee.Collection;
 using Banshee.Equalizer;
+using Banshee.Collection.Database;
 
 namespace Banshee.MediaEngine
 {
@@ -283,7 +284,23 @@ namespace Banshee.MediaEngine
 
         public void Open (SafeUri uri)
         {
-            Open (new UnknownTrackInfo (uri));
+             // Check if the uri exists
+            if (uri == null || !File.Exists (uri.AbsolutePath)) {
+                return;
+            }
+            // Try to find uri in the library
+            int track_id = DatabaseTrackInfo.GetTrackIdForUri (uri);
+            if (track_id > 0) {
+                DatabaseTrackInfo track_db = DatabaseTrackInfo.Provider.FetchSingle (track_id);
+                Open (track_db);
+            } else {
+                // Not in the library, get info from the file
+                TrackInfo track = new TrackInfo ();
+                using (var file = StreamTagger.ProcessUri (uri)) {
+                    StreamTagger.TrackInfoMerge (track, file, false);
+                }
+                Open (track);
+            }
         }
 
         void IPlayerEngineService.Open (string uri)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]