This patch allows the user to specify a "favorite" MythMusic
visualization, yet retain the ability to cycle through alternate modes.
For example, I love Goom, and use it almost all the time. However,
every once in a while it's nice to be able to show the AlbumArt or one
of the other visualizations. Therefore, I want to use Goom every time I
play music, unless I explicitly say otherwise, but I don't want to have
to go in and out of Setup to make the changes (or cycle through 10
"random" choices until I find the one I want).
This patch allows the user to specify a favorite (by placing an asterisk
after the name of the first visualization in the list), followed by a
list of alternate visualizations. The favorite is always chosen by
MythMusic (every time the user begins playing music); however, the user
may switch visualizations using the "cycle visualizations" key (by
default "6").
When the user requests an alternate visualization, the next
visualization in the list is displayed. If the user selects "Change
Visualization on each song," the next visualization will be chosen on
every song change (cycling, in order, through all visualizations in the
user's list); however, when starting playback, MythMusic will always
start with the user's favorite (regardless of which visualization he/she
was at exit last time).
I chose to use the "*" to specify a favorite (to distinguish it from a
list from which random visualizations should be chosen) because it's
non-intrusive (doesn't require any additional UI elements) and simple to
implement. If you would prefer a less "cryptic" approach, let me know.
As an example of the use of this patch, my "VisualMode" is specified as:
Goom*,AlbumArt,Synaesthesia,BumpScope,Spectrum,StereoScope,MonoScope
Thanks,
Mike
-------------- next part --------------
Index: mythmusic/mainvisual.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythmusic/mythmusic/mainvisual.cpp,v
retrieving revision 1.28
diff -u -r1.28 mainvisual.cpp
--- mythmusic/mainvisual.cpp 23 Jan 2004 06:08:06 -0000 1.28
+++ mythmusic/mainvisual.cpp 26 Jul 2004 06:58:18 -0000
@@ -98,7 +98,16 @@
allowed_modes = QStringList::split(",", visualname);
- if (allowed_modes.contains("Random"))
+ if (allowed_modes[0].stripWhiteSpace().endsWith("*"))
+ {
+ // User has a favorite
+ // The asterisk should only be passed in at startup, so start with
+ // the user's favorite
+
+ current_visual_name = allowed_modes[0].stripWhiteSpace();
+ current_visual_name.truncate(current_visual_name.length() - 1);
+ }
+ else if (allowed_modes.contains("Random"))
{
//
// Pick anything from compile time options
Index: mythmusic/playbackbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythmusic/mythmusic/playbackbox.cpp,v
retrieving revision 1.72
diff -u -r1.72 playbackbox.cpp
--- mythmusic/playbackbox.cpp 27 Apr 2004 09:50:22 -0000 1.72
+++ mythmusic/playbackbox.cpp 26 Jul 2004 06:58:19 -0000
@@ -637,9 +637,27 @@
// and the user currently has a visualizer active
if (mainvisual->numVisualizers() > 1 && visualizer_status > 0)
{
- if (visual_mode != "Random")
+ QStringList allowed_modes = QStringList::split(",", visual_mode);
+ if (allowed_modes[0].stripWhiteSpace().endsWith("*"))
+ {
+ //User has a favorite, but requested the next in the list
+ //Find the current position in the list
+ QString current_visual = mainvisual->getCurrentVisual();
+ unsigned int index = 0;
+ while ((index < allowed_modes.size()) &&
+ (!allowed_modes[index++].stripWhiteSpace().startsWith(current_visual))) { }
+ // index is 1 greater than the current visualizer's index
+ if (index >= allowed_modes.size()) {
+ index = 0;
+ }
+ new_visualizer = allowed_modes[index].stripWhiteSpace();
+ // Make sure the asterisk isn't passed through
+ if (new_visualizer.endsWith("*")) {
+ new_visualizer.truncate(new_visualizer.length() - 1);
+ }
+ }
+ else if (visual_mode != "Random")
{
- QStringList allowed_modes = QStringList::split(",", visual_mode);
//Find a visual thats not like the previous visual
do
{