Archived
1

Added "Show in Spotify" functionality"

This commit is contained in:
Kim Wittenburg
2012-06-17 23:09:35 +02:00
parent 1295f22371
commit dd82658055
11 changed files with 266 additions and 65 deletions

View File

@@ -15,6 +15,7 @@
NSInteger selectedSavePanelButton;
NSURL *saveFile;
iTunesApplication *iTunes;
SpotifyApplication *spotify;
Lyrics *currentLyrics;
int selectedRow;
}
@@ -35,6 +36,7 @@
-(id)init {
iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
spotify = [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
loadedResults = [[NSMutableArray alloc] init];
currentHoster = [[Magistrix alloc] init];
return [super init];
@@ -90,6 +92,19 @@
[searchField performClick:sender];
}
- (IBAction)getCurrentSpotifySong:(id)sender {
SpotifyTrack *track = [spotify currentTrack];
NSString *name = [track name];
NSString *artist = [track artist];
if (name == nil) {
NSBeginAlertSheet(NSLocalizedString(@"Spotify.messages.noTrackPlaying.title", @""), NSLocalizedString(@"OK", @""), nil, nil, window, nil, nil, nil, nil, NSLocalizedString(@"Spotify.messages.noTrackPlaying.detail", @""));
return;
}
NSString *searchText = [NSString stringWithFormat:@"%@ - %@", name, artist];
[searchField setStringValue:searchText];
[searchField performClick:sender];
}
- (IBAction)startNewSearch:(id)sender {
[self resetLoadedResults:sender];
if ([[searchField stringValue] length] > 0) {
@@ -260,6 +275,9 @@
if (action == @selector(getCurrentiTunesSong:)) {
return [iTunes isRunning];
}
if (action == @selector(getCurrentSpotifySong:)) {
return [spotify isRunning];
}
if (action == @selector(showPreview:)) {
return [resultsOutline clickedRow] >= 0;
}