[vlc-devel] commit: osx/framework: added convience methods for volume up/down ( Felix Paul Kühne )

git version control git at videolan.org
Sat Oct 10 12:45:10 CEST 2009


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Oct 10 12:44:41 2009 +0200| [9fa00260e12ef76782ded9c534dd4c5494d49775] | committer: Felix Paul Kühne 

osx/framework: added convience methods for volume up/down

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9fa00260e12ef76782ded9c534dd4c5494d49775
---

 .../macosx/framework/Headers/Public/VLCAudio.h     |    3 ++
 projects/macosx/framework/Sources/VLCAudio.m       |   32 +++++++++++++++++--
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/projects/macosx/framework/Headers/Public/VLCAudio.h b/projects/macosx/framework/Headers/Public/VLCAudio.h
index b31dd45..0df81ca 100644
--- a/projects/macosx/framework/Headers/Public/VLCAudio.h
+++ b/projects/macosx/framework/Headers/Public/VLCAudio.h
@@ -45,4 +45,7 @@ extern NSString * VLCMediaPlayerVolumeChanged;
 
 @property (setter=setMute:) BOOL isMuted;
 @property (assign) int volume;
+
+- (void)volumeDown;
+- (void)volumeUp;
 @end
diff --git a/projects/macosx/framework/Sources/VLCAudio.m b/projects/macosx/framework/Sources/VLCAudio.m
index a5690af..4affd0f 100644
--- a/projects/macosx/framework/Sources/VLCAudio.m
+++ b/projects/macosx/framework/Sources/VLCAudio.m
@@ -25,6 +25,10 @@
 #import "VLCAudio.h"
 #import "VLCLibVLCBridging.h"
 
+#define VOLUME_STEP                6
+#define VOLUME_MAX                 200
+#define VOLUME_MIN                 0
+
 /* Notification Messages */
 NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; 
 
@@ -60,13 +64,33 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
 
 - (void)setVolume:(int)value
 {
-    if (value < 0)
-        value = 0;
-    else if (value > 200)
-        value = 200;
+    if (value < VOLUME_MIN)
+        value = VOLUME_MIN;
+    else if (value > VOLUME_MAX)
+        value = VOLUME_MAX;
     libvlc_audio_set_volume([library instance], value, NULL);
 }
 
+- (void)volumeUp
+{
+    int tempVolume = [self volume] + VOLUME_STEP;
+    if (tempVolume > VOLUME_MAX)
+        tempVolume = VOLUME_MAX;
+    else if (tempVolume < VOLUME_MIN)
+        tempVolume = VOLUME_MIN;
+    [self setVolume: tempVolume];
+}
+
+- (void)volumeDown
+{
+    int tempVolume = [self volume] - VOLUME_STEP;
+    if (tempVolume > VOLUME_MAX)
+        tempVolume = VOLUME_MAX;
+    else if (tempVolume < VOLUME_MIN)
+        tempVolume = VOLUME_MIN;
+    [self setVolume: tempVolume];
+}
+
 - (int)volume
 {
     return libvlc_audio_get_volume([library instance]);




More information about the vlc-devel mailing list