Skip to content

Commit

Permalink
Actually preserve saved volume on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jun 14, 2012
1 parent a1e8198 commit 877dfbe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Classes/HermesAppDelegate.m
Expand Up @@ -178,6 +178,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults registerDefaults:app_defaults]; [defaults registerDefaults:app_defaults];
[self migrateDefaults:defaults]; [self migrateDefaults:defaults];
[playback prepareFirst];
} }


- (NSMenu *)applicationDockMenu:(NSApplication *)sender { - (NSMenu *)applicationDockMenu:(NSApplication *)sender {
Expand Down
1 change: 1 addition & 0 deletions Classes/PlaybackController.h
Expand Up @@ -38,6 +38,7 @@
- (void) playStation: (Station*) station; - (void) playStation: (Station*) station;
- (BOOL) saveState; - (BOOL) saveState;
- (void) show; - (void) show;
- (void) prepareFirst;


- (BOOL) play; - (BOOL) play;
- (BOOL) pause; - (BOOL) pause;
Expand Down
7 changes: 4 additions & 3 deletions Classes/PlaybackController.m
Expand Up @@ -87,15 +87,16 @@ - (id) init {
selector:@selector(songPlayed:) selector:@selector(songPlayed:)
name:@"song.playing" name:@"song.playing"
object:nil]; object:nil];
return self;
}


- (void) prepareFirst {
int saved = [[NSUserDefaults standardUserDefaults] int saved = [[NSUserDefaults standardUserDefaults]
integerForKey:@"hermes.volume"]; integerForKey:@"hermes.volume"];
if (saved == 0) { if (saved == 0) {
saved = 100; saved = 100;
} }
[self setIntVolume:saved]; [self setIntVolume:saved];

return self;
} }


- (Pandora*) pandora { - (Pandora*) pandora {
Expand All @@ -110,7 +111,6 @@ - (void) reset {
} }
playing = nil; playing = nil;
lastImgSrc = nil; lastImgSrc = nil;
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"hermes.volume"];
NSString *path = [[NSApp delegate] stateDirectory:@"station.savestate"]; NSString *path = [[NSApp delegate] stateDirectory:@"station.savestate"];
[[NSFileManager defaultManager] removeItemAtPath:path error:nil]; [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
} }
Expand Down Expand Up @@ -285,6 +285,7 @@ - (void) playStation: (Station*) station {
} else { } else {
playOnStart = 1; playOnStart = 1;
} }
[playing setVolume:[volume intValue]/100.0];
} }


- (BOOL) play { - (BOOL) play {
Expand Down

0 comments on commit 877dfbe

Please sign in to comment.