banshee r4331 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Metadata.FileSystem src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying



Author: gburt
Date: Tue Aug  5 23:45:23 2008
New Revision: 4331
URL: http://svn.gnome.org/viewvc/banshee?rev=4331&view=rev

Log:
2008-08-05  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs:
	Show cover art here when playing music (BGO #539180).

	* src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs:
	Fix bug just introduced by recent commit that ignored the
	too-many-random-files-in-this-folder limit if the file was cover.jpg etc.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs	Tue Aug  5 23:45:23 2008
@@ -71,6 +71,7 @@
             long max_size = 0;
             string best_file = null;
             int items_in_directory = 0;
+            bool found_definite_best = false;
             int max_acceptable_items = Math.Max (20, track.TrackCount + 8);
             foreach (string file in Banshee.IO.Directory.GetFiles (directory)) {
                 // Ignore directories with tons of songs in them; this lookup is only intended for when the
@@ -79,18 +80,22 @@
                     return;
                 }
                 
+                if (found_definite_best) {
+                    continue;
+                }
+                
                 string extension = System.IO.Path.GetExtension (file).ToLower ();
                 if (Array.IndexOf (extensions, extension) != -1) {
                     string filename = System.IO.Path.GetFileNameWithoutExtension (file).ToLower ();
                     if (Array.IndexOf (filenames, filename) != -1) {
                         best_file = file;
-                        break;
-                    }
-
-                    long size = Banshee.IO.File.GetSize (new SafeUri (file));
-                    if (size > max_size) {
-                        max_size = size;
-                        best_file = file;
+                        found_definite_best = true;
+                    } else {
+                        long size = Banshee.IO.File.GetSize (new SafeUri (file));
+                        if (size > max_size) {
+                            max_size = size;
+                            best_file = file;
+                        }
                     }
                 }
             }

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs	Tue Aug  5 23:45:23 2008
@@ -39,6 +39,9 @@
     {
         private Gdk.Pixbuf idle_pixbuf;
         private bool render_idle = true;
+        private bool render_video = false;
+        private Gdk.Pixbuf last_coverart_pixbuf;
+        private string last_coverart_id;
 
         public VideoDisplay ()
         {
@@ -64,23 +67,60 @@
                 return true;
             }
             
-            if (!render_idle && ServiceManager.PlayerEngine.SupportsVideo) {
+            if (render_video && ServiceManager.PlayerEngine.SupportsVideo) {
                 ExposeVideo (evnt);
                 return true;
             }
-            
+
+            if (render_idle || !DrawCoverArt ()) {
+                DrawIdle ();
+            }
+
+            return true;
+        }
+        
+        private void DrawIdle ()
+        {
             if (idle_pixbuf == null) {
                 idle_pixbuf = Gdk.Pixbuf.LoadFromResource ("idle-logo.png");
             }
             
             if (idle_pixbuf == null) {
-                return true;
+                return;
             }
             
             RenderWindow.DrawPixbuf (Style.BackgroundGC (StateType.Normal), idle_pixbuf, 0, 0, 
                 (Allocation.Width - idle_pixbuf.Width) / 2, (Allocation.Height - idle_pixbuf.Height) / 2, 
                 idle_pixbuf.Width, idle_pixbuf.Height, Gdk.RgbDither.Normal, 0, 0);
+        }
+        
+        private bool DrawCoverArt ()
+        {
+            TrackInfo track = ServiceManager.PlayerEngine.CurrentTrack;
+            if (track == null) {
+                return false;
+            }
+            
+            Gdk.Pixbuf display_pixbuf = null;
+            
+            if (track.ArtworkId == last_coverart_id) {
+                display_pixbuf = last_coverart_pixbuf;
+            } else if (Banshee.Base.CoverArtSpec.CoverExists (track.ArtworkId)) {
+                if (last_coverart_pixbuf != null) {
+                    last_coverart_pixbuf.Dispose ();
+                }
+                last_coverart_id = track.ArtworkId;
+                display_pixbuf = last_coverart_pixbuf = new Gdk.Pixbuf (Banshee.Base.CoverArtSpec.GetPath (last_coverart_id));
+            } else {
+                return false;
+            }
             
+            int img_w = Math.Min (Allocation.Width, display_pixbuf.Width);
+            int img_h = Math.Min (Allocation.Height, display_pixbuf.Height);
+            RenderWindow.DrawPixbuf (Style.BackgroundGC (StateType.Normal), display_pixbuf, 0, 0, 
+                (Allocation.Width - img_w) / 2, (Allocation.Height - img_h) / 2, 
+                img_w, img_h, Gdk.RgbDither.Normal, 0, 0
+            );
             return true;
         }
         
@@ -92,7 +132,8 @@
         private void ToggleIdleVisibility ()
         {
             TrackInfo track = ServiceManager.PlayerEngine.CurrentTrack;
-            render_idle = track == null || (track.MediaAttributes & TrackMediaAttributes.VideoStream) == 0;
+            render_idle = track == null;
+            render_video = !render_idle && (track.MediaAttributes & TrackMediaAttributes.VideoStream) != 0;
             QueueDraw ();
         }
         



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