diff --git a/Application/MediaKeysApplication.m b/Application/MediaKeysApplication.m
index 9bf4a406f..2fba4ced0 100644
--- a/Application/MediaKeysApplication.m
+++ b/Application/MediaKeysApplication.m
@@ -26,6 +26,11 @@
- (void)finishLaunching {
[super finishLaunching];
+ [[NSUserDefaults standardUserDefaults] addObserver:self
+ forKeyPath:@"allowLastfmMediaKeys"
+ options:NSKeyValueObservingOptionNew
+ context:nil];
+
keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self];
if([SPMediaKeyTap usesGlobalMediaKeyTap])
[keyTap startWatchingMediaKeys];
@@ -74,4 +79,31 @@
}
}
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
+ if ([keyPath isEqualToString:@"allowLastfmMediaKeys"])
+ {
+ NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
+ BOOL allowLastfmMediaKeys = [defs boolForKey:@"allowLastfmMediaKeys"];
+ NSArray *old = [defs arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey];
+
+ NSMutableArray *new = [old mutableCopy];
+ NSArray *lastfmIds = [NSArray arrayWithObjects:@"fm.last.Last.fm", @"fm.last.Scrobbler", nil];
+ if (allowLastfmMediaKeys)
+ {
+ [new addObjectsFromArray:lastfmIds];
+ }
+ else
+ {
+ [new removeObjectsInArray:lastfmIds];
+ }
+
+ [defs setObject:new forKey:kMediaKeyUsingBundleIdentifiersDefaultsKey];
+ }
+ else
+ {
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ }
+}
+
+
@end
diff --git a/Preferences/General/English.lproj/Preferences.xib b/Preferences/General/English.lproj/Preferences.xib
index fbb5f04a6..fd13c62c2 100644
--- a/Preferences/General/English.lproj/Preferences.xib
+++ b/Preferences/General/English.lproj/Preferences.xib
@@ -13,7 +13,7 @@
-
+
@@ -272,41 +272,65 @@
name
-
-
-
-
-
-
-
-
name
url
+
+
+ name
+ slug
+ preference
+
+
+
+
+ name
+ slug
+ preference
+
+
+
+
+
+
+
+
+
+
+
@@ -384,20 +408,6 @@
-
-
- name
- slug
- preference
-
-
-
-
- name
- slug
- preference
-
-