Volume up/down through remote, menu, and kb shortcuts.

CQTexperiment
vspader 2007-02-18 23:41:44 +00:00
parent caf6fe2c9d
commit 7499b0615f
7 changed files with 50 additions and 12 deletions

View File

@ -2,6 +2,8 @@
#import <Cocoa/Cocoa.h>
#import "PlaybackController.h"
#import "PlaylistController.h"
#import "PlaylistView.h"
@ -15,6 +17,7 @@
@interface AppController : NSObject
{
IBOutlet PlaylistController *playlistController;
IBOutlet PlaybackController *playbackController;
IBOutlet NSPanel *mainWindow;

View File

@ -48,9 +48,11 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
break;
case kRemoteButtonVolume_Plus_Hold:
//Volume Up
[playbackController volumeUp: self];
break;
case kRemoteButtonVolume_Minus_Hold:
//Volume Down
[playbackController volumeDown: self];
break;
}
if (remoteButtonHeld)
@ -75,8 +77,10 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
break;
case kRemoteButtonVolume_Plus:
[playbackController volumeUp: self];
break;
case kRemoteButtonVolume_Minus:
[playbackController volumeDown: self];
break;
case kRemoteButtonRight:
[self clickNext];

View File

@ -14,7 +14,6 @@
},
{
ACTIONS = {
addFiles = id;
delEntries = id;
donate = id;
loadPlaylist = id;
@ -27,7 +26,6 @@
CLASS = AppController;
LANGUAGE = ObjC;
OUTLETS = {
addButton = NSButton;
fileButton = NSButton;
fileDrawer = NSDrawer;
fileOutlineView = FileOutlineView;
@ -37,10 +35,10 @@
mainWindow = NSPanel;
nextButton = NSButton;
playButton = NSButton;
playbackController = PlaybackController;
playlistController = PlaylistController;
playlistView = PlaylistView;
prevButton = NSButton;
remButton = NSButton;
repeatButton = NSButton;
showAlbumColumn = NSMenuItem;
showArtistColumn = NSMenuItem;
@ -105,6 +103,8 @@
seek = id;
stop = id;
toggleShowTimeRemaining = id;
volumeDown = id;
volumeUp = id;
};
CLASS = PlaybackController;
LANGUAGE = ObjC;

View File

@ -3,19 +3,19 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>56 66 639 388 0 0 1024 746 </string>
<string>104 34 639 388 0 0 1680 1028 </string>
<key>IBEditorPositions</key>
<dict>
<key>1063</key>
<string>0 228 136 49 0 0 1024 746 </string>
<key>1156</key>
<string>391 336 241 366 0 0 1024 746 </string>
<string>719 527 241 366 0 0 1680 1028 </string>
<key>29</key>
<string>-3 695 383 44 0 0 1024 746 </string>
<string>-3 974 383 44 0 0 1680 1028 </string>
<key>463</key>
<string>341 447 341 145 0 0 1024 746 </string>
<string>669 637 341 145 0 0 1680 1028 </string>
<key>513</key>
<string>639 190 125 137 0 0 1024 746 </string>
<string>1105 278 125 137 0 0 1680 1028 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
@ -33,12 +33,12 @@
<key>IBOpenObjects</key>
<array>
<integer>513</integer>
<integer>21</integer>
<integer>29</integer>
<integer>21</integer>
<integer>1156</integer>
<integer>463</integer>
</array>
<key>IBSystem Version</key>
<string>8L127</string>
<string>8L2127</string>
</dict>
</plist>

Binary file not shown.

View File

@ -28,7 +28,7 @@
int playbackStatus;
float currentVolume;
double currentVolume;
BOOL showTimeRemaining;
}
@ -36,6 +36,9 @@
- (IBAction)toggleShowTimeRemaining:(id)sender;
- (IBAction)changeVolume:(id)sender;
- (IBAction)volumeDown:(id)sender;
- (IBAction)volumeUp:(id)sender;
- (IBAction)playPauseResume:(id)sender;
- (IBAction)pauseResume:(id)sender;

View File

@ -156,7 +156,7 @@
- (IBAction)changeVolume:(id)sender
{
float percent;
double percent;
//Approximated log
percent = (float)[sender doubleValue]/[sender maxValue];
@ -176,6 +176,34 @@
[soundController setVolume:currentVolume];
}
- (IBAction)volumeDown:(id)sender
{
double percent;
[volumeSlider setDoubleValue:([volumeSlider doubleValue] - 5)];
percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];
percent = percent * percent * percent * percent;
currentVolume = percent * [volumeSlider maxValue];
[soundController setVolume:currentVolume];
}
- (IBAction)volumeUp:(id)sender
{
double percent;
[volumeSlider setDoubleValue:([volumeSlider doubleValue] + 5)];
percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];
percent = percent * percent * percent * percent;
currentVolume = percent * [volumeSlider maxValue];
[soundController setVolume:currentVolume];
}
- (void)updateTimeField:(double)pos
{