Commit 9fa00260 authored by Felix Paul Kühne's avatar Felix Paul Kühne

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

parent 967a86e5
...@@ -45,4 +45,7 @@ extern NSString * VLCMediaPlayerVolumeChanged; ...@@ -45,4 +45,7 @@ extern NSString * VLCMediaPlayerVolumeChanged;
@property (setter=setMute:) BOOL isMuted; @property (setter=setMute:) BOOL isMuted;
@property (assign) int volume; @property (assign) int volume;
- (void)volumeDown;
- (void)volumeUp;
@end @end
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
#import "VLCAudio.h" #import "VLCAudio.h"
#import "VLCLibVLCBridging.h" #import "VLCLibVLCBridging.h"
#define VOLUME_STEP 6
#define VOLUME_MAX 200
#define VOLUME_MIN 0
/* Notification Messages */ /* Notification Messages */
NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
...@@ -60,13 +64,33 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; ...@@ -60,13 +64,33 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
- (void)setVolume:(int)value - (void)setVolume:(int)value
{ {
if (value < 0) if (value < VOLUME_MIN)
value = 0; value = VOLUME_MIN;
else if (value > 200) else if (value > VOLUME_MAX)
value = 200; value = VOLUME_MAX;
libvlc_audio_set_volume([library instance], value, NULL); 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 - (int)volume
{ {
return libvlc_audio_get_volume([library instance]); return libvlc_audio_get_volume([library instance]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment