Bug 120363 - random album playback should differentiate artists
Summary: random album playback should differentiate artists
Status: RESOLVED FIXED
Alias: None
Product: juk
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Scott Wheeler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-18 06:22 UTC by Marcelo Vanzin
Modified: 2006-01-19 03:53 UTC (History)
0 users

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


Attachments
Proposed patch for bug 120363 (721 bytes, patch)
2006-01-18 06:24 UTC, Marcelo Vanzin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcelo Vanzin 2006-01-18 06:22:47 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    SuSE RPMs
Compiler:          gcc (GCC) 3.3.5 20050117 (prerelease) (SUSE Linux) 
OS:                Linux

When using random album play in juk, it should differentiate albums with the same name but different artists; currently it will play both albums "together", playing track 1 from the first, then track 1 from the second, then track 2 of the first, etc, etc.

I have a patch for this that I'll attach to the bug for consideration.
Comment 1 Marcelo Vanzin 2006-01-18 06:24:48 UTC
Created attachment 14298 [details]
Proposed patch for bug 120363

This just adds the "artist" tag to the list of tags used in the search when
defining the next album to play; a quick test showed this to work w.r.t. this
bug (I haven't checked if that method is used from other parts of Juk).
Comment 2 Marcelo Vanzin 2006-01-18 06:25:47 UTC
(Attachment is a gzipped text file if you have problems opening it.)
Comment 3 Michael Pyne 2006-01-19 01:56:52 UTC
Comment on attachment 14298 [details]
Proposed patch for bug 120363

Correct mimetype.
Comment 4 Michael Pyne 2006-01-19 03:53:34 UTC
SVN commit 499931 by mpyne:

Fix bug 120363 (JuK should use Artist information in album random play).

Previously, only the Album name mattered, which meant that common names like "Greatest Hits"
would play different artists.

Thanks to the reporter for providing a reference patch.

BUG:120363


 M  +27 -2     tracksequenceiterator.cpp  


--- branches/KDE/3.5/kdemultimedia/juk/tracksequenceiterator.cpp #499930:499931
@@ -102,14 +102,21 @@
             }
 
             // This can be null if initAlbumSearch() left the m_albumSearch
-            // empty because the album text was empty.
+            // empty because the album text was empty.  Since we initAlbumSearch()
+            // with an item, the matchedItems() should never be empty.
 
             if(!m_albumSearch.isNull()) {
                 PlaylistItemList albumMatches = m_albumSearch.matchedItems();
+                if(albumMatches.isEmpty()) {
+                    kdError(65432) << "Unable to initialize album random play.\n";
+                    kdError(65432) << "List of potential results is empty.\n";
 
+                    return; // item is still set to random song from a few lines earlier.
+                }
+
                 item = albumMatches[0];
 
-                // Pick first song
+                // Pick first song remaining in list.
 
                 for(unsigned i = 0; i < albumMatches.count(); ++i)
                     if(albumMatches[i]->file().tag()->track() < item->file().tag()->track())
@@ -121,6 +128,8 @@
                     m_albumSearch.search();
                 }
             }
+            else
+                kdError(65432) << "Unable to perform album random play on " << *item << endl;
         }
         else
             item = m_randomItems[KApplication::random() % m_randomItems.count()];
@@ -279,6 +288,22 @@
         PlaylistSearch::Component::Exact)
     );
 
+    // If there is an Artist tag with the track, match against it as well
+    // to avoid things like multiple "Greatest Hits" albums matching the
+    // search.
+
+    if(!searchItem->file().tag()->artist().isEmpty()) {
+        kdDebug(65432) << "Searching both artist and album.\n";
+        columns[0] = PlaylistItem::ArtistColumn;
+
+        m_albumSearch.addComponent(PlaylistSearch::Component(
+            searchItem->file().tag()->artist(),
+            true,
+            columns,
+            PlaylistSearch::Component::Exact)
+        );
+    }
+
     m_albumSearch.search();
 }