diff --git a/Application/PlaybackController.h b/Application/PlaybackController.h index 7cbd25b71..55bf1b86d 100644 --- a/Application/PlaybackController.h +++ b/Application/PlaybackController.h @@ -58,14 +58,14 @@ - (IBAction)seek:(id)sender; - (IBAction)seekForward:(id)sender; - (IBAction)seekBackward:(id)sender; +- (IBAction)fadeOut:(id)sender withTime:(double)time; - (void)initDefaults; +- (void)audioFader:(NSTimer *)audioTimer; - (void)updateTimeField:(double)pos; - (void)playEntryAtIndex:(int)i; - (void)playEntry:(PlaylistEntry *)pe; -- (int)status; - @end diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index eaa39a345..597eb97cc 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -1,6 +1,6 @@ #import "PlaybackController.h" #import "PlaylistView.h" - +#import #import "CogAudio/Status.h" #import "PlaylistController.h" @@ -53,8 +53,14 @@ - (void)awakeFromNib { - currentVolume = 100.0; [volumeSlider setDoubleValue:pow(10.0, log10(0.5)/4.0)*100]; + + double percent; + percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0; + percent = percent * percent * percent * percent; + + currentVolume = ((float)[volumeSlider doubleValue]/100.0)*[volumeSlider maxValue];//percent * 1000;//0;//[volumeSlider doubleValue]; + [positionSlider setEnabled:NO]; } @@ -265,16 +271,57 @@ [audioPlayer setVolume:currentVolume]; } +/* selector for NSTimer - gets passed the Timer object itself + and the appropriate userInfo, which in this case is an NSNumber + containing the current volume before we start fading. */ +- (void)audioFader:(NSTimer *)audioTimer +{ + double volume = currentVolume; + NSArray *origValues = [audioTimer userInfo]; + id originalVolume = [origValues objectAtIndex:0]; + id origSliderVolume = [origValues objectAtIndex:1]; + + if (volume > 0) + { + [self volumeDown:self]; + } + else // volume is at 0 or below, we are ready to release the timer and move on + { + [audioPlayer pause]; + currentVolume = [originalVolume doubleValue]; + [audioPlayer setVolume:currentVolume]; + [volumeSlider setDoubleValue:[origSliderVolume doubleValue]]; + [audioTimer invalidate]; + } + +} + +- (IBAction)fadeOut:(id)sender withTime:(double)time +{ + id origCurrentVolume = [NSNumber numberWithDouble: currentVolume]; + id origSliderVolume = [NSNumber numberWithDouble: [volumeSlider doubleValue]]; + + NSArray *originalValues = [NSArray arrayWithObjects:origCurrentVolume,origSliderVolume,nil]; + NSTimer *fadeTimer; + + NSLog(@"currentVolume here%f", [volumeSlider doubleValue]); + fadeTimer = [NSTimer scheduledTimerWithTimeInterval:time + target:self + selector:@selector(audioFader:) + userInfo:originalValues + repeats:YES]; +} + - (IBAction)volumeDown:(id)sender { double percent; - [volumeSlider setDoubleValue:([volumeSlider doubleValue] - 5)]; - percent = (float)[volumeSlider doubleValue]/100.0; + percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0; percent = percent * percent * percent * percent; - currentVolume = percent * 100.0; + currentVolume = (percent * [volumeSlider maxValue]) + [volumeSlider doubleValue];//100.0; + NSLog(@"currentVolume %f", currentVolume); [audioPlayer setVolume:currentVolume]; } @@ -285,11 +332,16 @@ [volumeSlider setDoubleValue:([volumeSlider doubleValue] + 5)]; - percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue]; + percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0; percent = percent * percent * percent * percent; - currentVolume = percent * [volumeSlider maxValue]; - + currentVolume = (percent * [volumeSlider maxValue]) + [volumeSlider doubleValue];//100.0); + if (currentVolume > 400) + currentVolume = 400; + + NSLog(@"%f", currentVolume); + + [audioPlayer setVolume:currentVolume]; } @@ -362,11 +414,6 @@ } -- (int)status -{ - return playbackStatus; -} - - (void)audioPlayer:(AudioPlayer *)player statusChanged:(id)s { int status = [s intValue]; diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index 4567738c6..d88041aea 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -1,4 +1,4 @@ -// + // AudioController.m // Cog // @@ -137,6 +137,7 @@ [output setVolume:v]; } + //This is called by the delegate DURING a requestNextStream request. - (void)setNextStream:(NSURL *)url { diff --git a/Playlist/PlaylistView.h b/Playlist/PlaylistView.h index b4bd385ff..156dff78c 100644 --- a/Playlist/PlaylistView.h +++ b/Playlist/PlaylistView.h @@ -14,7 +14,7 @@ @interface PlaylistView : NSTableView { IBOutlet PlaybackController *playbackController; IBOutlet PlaylistController *playlistController; - + NSMenu *headerContextMenu; } diff --git a/Playlist/PlaylistView.m b/Playlist/PlaylistView.m index a837d1631..79e8ea239 100644 --- a/Playlist/PlaylistView.m +++ b/Playlist/PlaylistView.m @@ -200,6 +200,11 @@ { [playlistController clearFilterPredicate:self]; } + // shift+command+p - fade to pause + else if (modifiers == (NSCommandKeyMask | NSShiftKeyMask) && c == 0x70) + { + [playbackController fadeOut:self withTime:0.4]; + } else { [super keyDown:e]; diff --git a/Preferences/General/English.lproj/Preferences.nib/classes.nib b/Preferences/General/English.lproj/Preferences.nib/classes.nib index df89aa4c5..d5982ce21 100644 --- a/Preferences/General/English.lproj/Preferences.nib/classes.nib +++ b/Preferences/General/English.lproj/Preferences.nib/classes.nib @@ -1,76 +1,157 @@ -{ - IBClasses = ( - { - CLASS = AppcastArrayController; - LANGUAGE = ObjC; - SUPERCLASS = NSArrayController; - }, - { - ACTIONS = {openSheet = id; }; - CLASS = FileDrawerPane; - LANGUAGE = ObjC; - OUTLETS = {rootPathTextView = NSTextField; }; - SUPERCLASS = PreferencePane; - }, - {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, - {CLASS = HotKeyControl; LANGUAGE = ObjC; SUPERCLASS = NDHotKeyControl; }, - { - ACTIONS = { - grabNextHotKey = id; - grabPlayHotKey = id; - grabPrevHotKey = id; - hotKeyChanged = id; - }; - CLASS = HotKeyPane; - LANGUAGE = ObjC; - OUTLETS = { - nextHotKeyControl = HotKeyControl; - playHotKeyControl = HotKeyControl; - prevHotKeyControl = HotKeyControl; - }; - SUPERCLASS = PreferencePane; - }, - {CLASS = NDHotKeyControl; LANGUAGE = ObjC; SUPERCLASS = NSTextField; }, - { - ACTIONS = {takeDeviceID = id; }; - CLASS = OutputPane; - LANGUAGE = ObjC; - OUTLETS = {outputDevices = OutputsArrayController; }; - SUPERCLASS = PreferencePane; - }, - { - CLASS = OutputsArrayController; - LANGUAGE = ObjC; - SUPERCLASS = NSArrayController; - }, - { - CLASS = PrefPaneController; - LANGUAGE = ObjC; - OUTLETS = { - fileDrawerPane = FileDrawerPane; - hotKeyPane = HotKeyPane; - outputPane = OutputPane; - remoteView = NSView; - scrobblerView = NSView; - updatesView = NSView; - }; - SUPERCLASS = NSObject; - }, - { - CLASS = PreferencePane; - LANGUAGE = ObjC; - OUTLETS = {view = NSView; }; - SUPERCLASS = NSObject; - }, - { - ACTIONS = {takeBool = id; }; - CLASS = RemotePane; - LANGUAGE = ObjC; - OUTLETS = {onlyOnActive = NSButton; }; - SUPERCLASS = PreferencePane; - }, - {CLASS = ScrobblerPane; LANGUAGE = ObjC; SUPERCLASS = PreferencePane; }, - {CLASS = UpdatesPane; LANGUAGE = ObjC; SUPERCLASS = PreferencePane; } - ); - IBVersion = 1; -} \ No newline at end of file + + + + + IBClasses + + + CLASS + AppcastArrayController + LANGUAGE + ObjC + SUPERCLASS + NSArrayController + + + CLASS + HotKeyControl + LANGUAGE + ObjC + SUPERCLASS + NDHotKeyControl + + + ACTIONS + + grabNextHotKey + id + grabPlayHotKey + id + grabPrevHotKey + id + hotKeyChanged + id + + CLASS + HotKeyPane + LANGUAGE + ObjC + OUTLETS + + nextHotKeyControl + HotKeyControl + playHotKeyControl + HotKeyControl + prevHotKeyControl + HotKeyControl + + SUPERCLASS + PreferencePane + + + CLASS + PrefPaneController + LANGUAGE + ObjC + OUTLETS + + fileDrawerPane + FileDrawerPane + hotKeyPane + HotKeyPane + outputPane + OutputPane + remoteView + NSView + scrobblerView + NSView + updatesView + NSView + + SUPERCLASS + NSObject + + + CLASS + OutputsArrayController + LANGUAGE + ObjC + SUPERCLASS + NSArrayController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + ACTIONS + + openSheet + id + + CLASS + FileDrawerPane + LANGUAGE + ObjC + OUTLETS + + rootPathTextView + NSTextField + + SUPERCLASS + PreferencePane + + + CLASS + NDHotKeyControl + LANGUAGE + ObjC + SUPERCLASS + NSTextField + + + CLASS + PreferencePane + LANGUAGE + ObjC + OUTLETS + + view + NSView + + SUPERCLASS + NSObject + + + ACTIONS + + takeDeviceID + id + + CLASS + OutputPane + LANGUAGE + ObjC + OUTLETS + + outputDevices + OutputsArrayController + + SUPERCLASS + PreferencePane + + + IBVersion + 1 + + diff --git a/Preferences/General/English.lproj/Preferences.nib/info.nib b/Preferences/General/English.lproj/Preferences.nib/info.nib index dbf0d4b4f..ed1752370 100644 --- a/Preferences/General/English.lproj/Preferences.nib/info.nib +++ b/Preferences/General/English.lproj/Preferences.nib/info.nib @@ -1,36 +1,20 @@ - + - IBDocumentLocation - 291 101 356 534 0 0 1680 1028 - IBEditorPositions - - 10 - 171 910 506 102 0 0 1680 1028 - 11 - 677 567 452 151 0 0 1680 1028 - 43 - 166 683 452 116 0 0 1680 1028 - 50 - 660 357 452 124 0 0 1680 1028 - 58 - 641 480 452 101 0 0 1680 1028 - 85 - 758 836 452 116 0 0 1680 1028 - IBFramework Version - 446.1 + 629 + IBLastKnownRelativeProjectPath + ../../General.xcodeproj + IBOldestOS + 5 IBOpenObjects - 50 - 11 10 - 58 - 85 - 43 IBSystem Version - 8P2137 + 9B18 + targetFramework + IBCocoaFramework diff --git a/Preferences/General/English.lproj/Preferences.nib/keyedobjects.nib b/Preferences/General/English.lproj/Preferences.nib/keyedobjects.nib index a5d45d537..64a4acf16 100644 Binary files a/Preferences/General/English.lproj/Preferences.nib/keyedobjects.nib and b/Preferences/General/English.lproj/Preferences.nib/keyedobjects.nib differ