[banshee] [Halie] Relative values for --set-volume (bgo#610981)



commit b024b64543c89d89e6855144e03d5dcf6de1a247
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Fri Feb 26 13:31:46 2010 +1100

    [Halie] Relative values for --set-volume (bgo#610981)

 src/Clients/Booter/Booter/Entry.cs |    2 +-
 src/Clients/Halie/Halie/Client.cs  |   11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/Clients/Booter/Booter/Entry.cs b/src/Clients/Booter/Booter/Entry.cs
index f6d1677..2d1cfd8 100644
--- a/src/Clients/Booter/Booter/Entry.cs
+++ b/src/Clients/Booter/Booter/Entry.cs
@@ -165,7 +165,7 @@ namespace Booter
                     new LayoutOption ("stop", Catalog.GetString ("Completely stop playback")),
                     new LayoutOption ("stop-when-finished", Catalog.GetString (
                         "Enable or disable playback stopping after the currently playing track (value should be either 'true' or 'false')")),
-                    new LayoutOption ("set-volume=LEVEL", Catalog.GetString ("Set the playback volume (0-100)")),
+                    new LayoutOption ("set-volume=LEVEL", Catalog.GetString ("Set the playback volume (0-100), prefix with +/- for relative values")),
                     new LayoutOption ("set-position=POS", Catalog.GetString ("Seek to a specific point (seconds, float)")),
                     new LayoutOption ("set-rating=RATING", Catalog.GetString ("Set the currently played track's rating (0 to 5)"))
                 ),
diff --git a/src/Clients/Halie/Halie/Client.cs b/src/Clients/Halie/Halie/Client.cs
index 4f628c6..980d64f 100644
--- a/src/Clients/Halie/Halie/Client.cs
+++ b/src/Clients/Halie/Halie/Client.cs
@@ -143,6 +143,17 @@ namespace Halie
                         player.Position = (uint)Math.Round (Double.Parse (arg.Value) * 1000);
                         break;
                     case "set-volume":
+                        if (arg.Value.Length > 1) {
+                            if (arg.Value[0] == '+') {
+                                player.Volume += UInt16.Parse (arg.Value.Substring (1));
+                                break;
+                            }
+                            if (arg.Value[0] == '-') {
+                                var dec = UInt16.Parse (arg.Value.Substring (1));
+                                player.Volume = (ushort)(player.Volume > dec ? player.Volume - dec : 0);
+                                break;
+                            }
+                        }
                         player.Volume = UInt16.Parse (arg.Value);
                         break;
                     case "set-rating":



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