Release 1.0
iLyrics functionality added Magistrix Lyrics Hoster added Release 1.0.1 Added Split View in Main Window Some little code changes
This commit is contained in:
@@ -7,9 +7,25 @@
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <ScriptingBridge/ScriptingBridge.h>
|
||||
#import "iTunes.h"
|
||||
#import "PreferencesController.h"
|
||||
#import "MainController.h"
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate, NSTokenFieldDelegate>
|
||||
|
||||
@property (assign) IBOutlet NSWindow *window;
|
||||
@property (weak) IBOutlet MainController *mainController;
|
||||
@property (unsafe_unretained) IBOutlet NSWindow *preferencesWindow;
|
||||
@property (weak) IBOutlet PreferencesController *preferencesController;
|
||||
@property (weak) IBOutlet NSButton *quitWhenAllWindowClosedCheckBox;
|
||||
|
||||
//- (IBAction)showPreferences:(id)sender;
|
||||
//- (IBAction)searchFormatChanged:(id)sender;
|
||||
- (IBAction)runiTunes:(id)sender;
|
||||
- (IBAction)quitiTunes:(id)sender;
|
||||
- (IBAction)playPauseiTunes:(id)sender;
|
||||
- (IBAction)previousTrack:(id)sender;
|
||||
- (IBAction)nextTrack:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,14 +7,95 @@
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "Magistrix.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
@implementation AppDelegate {
|
||||
iTunesApplication *iTunes;
|
||||
NSArray *keyTokens;
|
||||
NSMutableArray *searchFormat;
|
||||
Magistrix *magistrix;
|
||||
}
|
||||
|
||||
@synthesize window = _window;
|
||||
@synthesize window;
|
||||
@synthesize mainController;
|
||||
@synthesize preferencesWindow;
|
||||
@synthesize preferencesController;
|
||||
@synthesize quitWhenAllWindowClosedCheckBox;
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
// Insert code here to initialize your application
|
||||
magistrix = [[Magistrix alloc] init];
|
||||
[preferencesController addHoster:magistrix];
|
||||
keyTokens = [NSArray arrayWithObjects:@"%name%", @"%artist%", @"%album%", nil];
|
||||
[window setExcludedFromWindowsMenu:YES];
|
||||
iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[quitWhenAllWindowClosedCheckBox setState:[defaults boolForKey:@"Quit when all windows are closed"]?NSOnState:NSOffState];
|
||||
[mainController loadFromDefaults:defaults];
|
||||
}
|
||||
|
||||
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults setBool:[quitWhenAllWindowClosedCheckBox state] == NSOnState forKey:@"Quit when all windows are closed"];
|
||||
[mainController saveToDefalts:defaults];
|
||||
[defaults synchronize];
|
||||
return NSTerminateNow;
|
||||
}
|
||||
|
||||
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
|
||||
return [quitWhenAllWindowClosedCheckBox state] == NSOnState;
|
||||
}
|
||||
|
||||
-(BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
||||
SEL action = [menuItem action];
|
||||
if (action == @selector(runitunes:)) {
|
||||
return ![iTunes isRunning];
|
||||
}
|
||||
if (action == @selector(quitiTunes:) || action == @selector(playPauseiTunes:) || action == @selector(previousTrack:) || action == @selector(nextTrack:)) {
|
||||
return [iTunes isRunning];
|
||||
}
|
||||
return [self respondsToSelector:action];
|
||||
}
|
||||
/*
|
||||
- (IBAction)showPreferences:(id)sender {
|
||||
[searchFormatField setObjectValue:searchFormat];
|
||||
[preferencesWindow makeKeyAndOrderFront:sender];
|
||||
}
|
||||
|
||||
- (IBAction)searchFormatChanged:(id)sender {
|
||||
NSArray *tokens = [searchFormatField objectValue];
|
||||
[searchFormat removeAllObjects];
|
||||
[searchFormat addObjectsFromArray:tokens];
|
||||
}
|
||||
*/
|
||||
-(NSString *)searchFormat {
|
||||
NSMutableString *string = [[NSMutableString alloc] init];
|
||||
for (NSString *token in searchFormat) {
|
||||
[string appendString:token];
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
- (IBAction)runiTunes:(id)sender {
|
||||
[iTunes run];
|
||||
[window update];
|
||||
}
|
||||
|
||||
- (IBAction)quitiTunes:(id)sender {
|
||||
[iTunes quit];
|
||||
[window update];
|
||||
}
|
||||
|
||||
- (IBAction)playPauseiTunes:(id)sender {
|
||||
[iTunes playpause];
|
||||
[window update];
|
||||
}
|
||||
|
||||
- (IBAction)previousTrack:(id)sender {
|
||||
[iTunes previousTrack];
|
||||
}
|
||||
|
||||
- (IBAction)nextTrack:(id)sender {
|
||||
[iTunes nextTrack];
|
||||
}
|
||||
@end
|
||||
|
||||
17
iLyrics/Lyrics.h
Normal file
17
iLyrics/Lyrics.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Lyrics.h
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 10.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface Lyrics : NSObject
|
||||
@property NSString *name;
|
||||
@property NSString *artist;
|
||||
@property NSString *lyrics;
|
||||
-(id)initWithName: (NSString*) name byArtist: (NSString*) artist withLyrics: (NSString*) lyrics;
|
||||
|
||||
@end
|
||||
24
iLyrics/Lyrics.m
Normal file
24
iLyrics/Lyrics.m
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Lyrics.m
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 10.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Lyrics.h"
|
||||
|
||||
@implementation Lyrics
|
||||
|
||||
@synthesize name;
|
||||
@synthesize artist;
|
||||
@synthesize lyrics;
|
||||
|
||||
-(id)initWithName:(NSString *)son byArtist:(NSString *)art withLyrics:(NSString *)lyr {
|
||||
lyrics = lyr;
|
||||
artist = art;
|
||||
name = son;
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
30
iLyrics/LyricsHoster.h
Normal file
30
iLyrics/LyricsHoster.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// LyricsHoster.h
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 10.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SearchResult.h"
|
||||
#import "Lyrics.h"
|
||||
|
||||
@protocol LyricsHoster <NSObject>
|
||||
|
||||
-(NSString*) name;
|
||||
|
||||
-(NSDate*) hosterVersion;
|
||||
|
||||
-(void) startNewSearchForQuery: (NSString*) query;
|
||||
|
||||
-(BOOL) hasMoreResults;
|
||||
|
||||
//Return an empty array for a "No results found" message and nil for a "network error".
|
||||
-(NSArray*) nextResults;
|
||||
|
||||
-(void) resetLoadedResults;
|
||||
|
||||
-(Lyrics*) lyricsBySearchResult: (SearchResult *) result;
|
||||
|
||||
@end
|
||||
14
iLyrics/Magistrix.h
Normal file
14
iLyrics/Magistrix.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Magistrix.h
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 14.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "LyricsHoster.h"
|
||||
|
||||
@interface Magistrix : NSObject <LyricsHoster>
|
||||
|
||||
@end
|
||||
210
iLyrics/Magistrix.m
Normal file
210
iLyrics/Magistrix.m
Normal file
@@ -0,0 +1,210 @@
|
||||
//
|
||||
// Magistrix.m
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 14.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
//
|
||||
//TODO: Use correct Date
|
||||
|
||||
#import "Magistrix.h"
|
||||
|
||||
typedef enum {
|
||||
LyricsPage,
|
||||
ResultsPage,
|
||||
NoResultsPage,
|
||||
UnknownPage
|
||||
} PageType;
|
||||
|
||||
@implementation Magistrix {
|
||||
NSString *query;
|
||||
int loadedResults;
|
||||
int resultCount;
|
||||
}
|
||||
|
||||
-(NSString*) name {
|
||||
return @"Magistrix";
|
||||
}
|
||||
|
||||
-(NSDate *)hosterVersion {
|
||||
return [NSDate dateWithString:@"2012-06-16 11:00:00 +0100"];
|
||||
}
|
||||
|
||||
-(void) startNewSearchForQuery: (NSString*) q {
|
||||
[self resetLoadedResults];
|
||||
query = q;
|
||||
}
|
||||
|
||||
-(BOOL) hasMoreResults {
|
||||
return loadedResults < resultCount;
|
||||
}
|
||||
|
||||
-(NSArray*) nextResults {
|
||||
int site = (loadedResults/10) + 1;
|
||||
NSString *searchPath = [NSString stringWithFormat:@"http://www.magistrix.de/lyrics/search?q=%@&page=%i", [query stringByReplacingOccurrencesOfString:@" " withString:@"+"], site];
|
||||
NSURL *searchURL = [NSURL URLWithString:searchPath];
|
||||
NSError *error;
|
||||
NSString *page = [NSString stringWithContentsOfURL:searchURL encoding:NSUTF8StringEncoding error:&error];
|
||||
if (error) {
|
||||
return nil;
|
||||
}
|
||||
PageType pType = [self typeOfPage:page];
|
||||
if (pType == LyricsPage) {
|
||||
resultCount = 1;
|
||||
loadedResults = 1;
|
||||
return [NSArray arrayWithObject:[self searchResultFromLyricsPage:page atURL:searchURL]];
|
||||
} else if (pType == ResultsPage) {
|
||||
[self shouldSetResultCountFromPage:page];
|
||||
return [self searchResultsFromPage:page];
|
||||
} else if (pType == NoResultsPage) {
|
||||
return [[NSArray alloc] init];
|
||||
} else {
|
||||
NSRunAlertPanel(NSLocalizedString(@"Magistrix.messages.unknownPage.title", @""), NSLocalizedString(@"Magistrix.messages.unknownPage.detail", @""), NSLocalizedString(@"OK", @""), nil, nil);
|
||||
return [[NSArray alloc] init];
|
||||
}
|
||||
}
|
||||
|
||||
-(PageType) typeOfPage: (NSString *) page {
|
||||
if ([page rangeOfString:@"<title>Songtext-Suche</title>"].location != NSNotFound) {
|
||||
if ([page rangeOfString:@"<div class='empty_collection'>"].location != NSNotFound) {
|
||||
return NoResultsPage;
|
||||
} else {
|
||||
return ResultsPage;
|
||||
}
|
||||
}
|
||||
if ([page rangeOfString:@"<div id='songtext'>"].location != NSNotFound) {
|
||||
return LyricsPage;
|
||||
}
|
||||
return UnknownPage;
|
||||
}
|
||||
|
||||
-(SearchResult*) searchResultFromLyricsPage: (NSString *) page atURL: (NSURL *) url{
|
||||
int headingStart = NSMaxRange([page rangeOfString:@"<h1>"]);
|
||||
int headingEnd = [page rangeOfString:@"</h1>"].location;
|
||||
int artistStart = NSMaxRange([page rangeOfString:@">" options:NSCaseInsensitiveSearch range:NSMakeRange(headingStart, headingEnd-headingStart)]);
|
||||
NSRange artistEndTag = [page rangeOfString:@"</a>" options:NSCaseInsensitiveSearch range:NSMakeRange(artistStart, headingEnd-artistStart)];
|
||||
int artistEnd = artistEndTag.location;
|
||||
int songNameStart = NSMaxRange(artistEndTag);
|
||||
int songNameEnd = headingEnd;
|
||||
NSString *artist = [page substringWithRange:NSMakeRange(artistStart, artistEnd-artistStart)];
|
||||
NSString *songName = [page substringWithRange:NSMakeRange(songNameStart, songNameEnd-songNameStart)];
|
||||
//Remove the " Lyric" and the " – " from the Song name
|
||||
songName = [[songName substringToIndex:[songName length]-[@" Lyric" length]] substringFromIndex:[@" – " length]];
|
||||
NSString *preview = [self lyricsFromPage:page];
|
||||
return [[SearchResult alloc]initWithName:songName fromArtist:artist preview:preview link:url];
|
||||
}
|
||||
|
||||
-(NSArray*) searchResultsFromPage: (NSString *) page {
|
||||
int resultsTableStart = NSMaxRange([page rangeOfString:@"<table>"]);
|
||||
int resultsTableEnd = [page rangeOfString:@"</table>"].location;
|
||||
NSArray *resultTags = [self resultTagsFromTable:[page substringWithRange:NSMakeRange(resultsTableStart, resultsTableEnd-resultsTableStart)]];
|
||||
NSMutableArray *searchResults = [[NSMutableArray alloc] init];
|
||||
for (NSString *tag in resultTags) {
|
||||
[searchResults addObject:[self searchResultFromResultTag:tag]];
|
||||
}
|
||||
//Increase loadedResults by 10 which is a full results site
|
||||
//Even if there are less than 10 results on a page (would not have any effect)
|
||||
loadedResults += 10;
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
-(NSArray*) resultTagsFromTable: (NSString *) table {
|
||||
NSRange restRange = NSMakeRange(0, [table length]);
|
||||
NSMutableArray *tags = [[NSMutableArray alloc] init];
|
||||
NSUInteger currentIndex = [table rangeOfString:@"<td>"].location;
|
||||
while (currentIndex != NSNotFound) {
|
||||
int startIndex = currentIndex + [@"<td>" length];
|
||||
int endIndex = [table rangeOfString:@"</td>" options:NSCaseInsensitiveSearch range:restRange].location;
|
||||
NSRange tagRange = NSMakeRange(startIndex, endIndex-startIndex);
|
||||
[tags addObject:[table substringWithRange:tagRange]];
|
||||
restRange = [self restRangeFromString:table subtractingRange:tagRange];
|
||||
restRange.length -= [@"</td>" length];
|
||||
restRange.location += [@"</td>" length];
|
||||
currentIndex = [table rangeOfString:@"<td>" options:NSCaseInsensitiveSearch range:restRange].location;
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
-(SearchResult*) searchResultFromResultTag: (NSString *) tag {
|
||||
NSRange artistStartRange = [tag rangeOfString:@">"];
|
||||
int artistEndIndex = [tag rangeOfString:@"<" options:NSCaseInsensitiveSearch range:[self restRangeFromString:tag subtractingRange:artistStartRange]].location;
|
||||
int artistStartIndex = NSMaxRange(artistStartRange);
|
||||
NSString *artist = [tag substringWithRange:NSMakeRange(artistStartIndex, artistEndIndex-artistStartIndex)];
|
||||
|
||||
NSRange restRange = [self restRangeFromString:tag subtractingRange:NSMakeRange(artistEndIndex, [@"</a>" length])];
|
||||
NSRange songNameTagStartRange = [tag rangeOfString:@"<a href=\"" options:NSCaseInsensitiveSearch range:restRange];
|
||||
int linkStart = NSMaxRange(songNameTagStartRange);
|
||||
NSRange linkEndRage = [tag rangeOfString:@"\"" options:NSCaseInsensitiveSearch range:[self restRangeFromString:tag subtractingRange:songNameTagStartRange]];
|
||||
NSURL *link = [self urlFromHref:[tag substringWithRange:NSMakeRange(linkStart, linkEndRage.location-linkStart)]];
|
||||
int songNameStart = NSMaxRange([tag rangeOfString:@">" options:NSCaseInsensitiveSearch range:[self restRangeFromString:tag subtractingRange:songNameTagStartRange]]);
|
||||
int songNameEnd = [tag rangeOfString:@"</a>" options:NSCaseInsensitiveSearch range:[self restRangeFromString:tag subtractingRange:songNameTagStartRange]].location;
|
||||
NSString *songName = [tag substringWithRange:NSMakeRange(songNameStart, songNameEnd-songNameStart)];
|
||||
int previewStart = songNameEnd + [@"</a>" length] + [@"\n<p>" length];
|
||||
NSRange previewRestRange = NSMakeRange(previewStart, [tag length]-previewStart);
|
||||
int previewEnd = [tag rangeOfString:@"</p>" options:NSCaseInsensitiveSearch range:previewRestRange].location;
|
||||
NSString *preview = [self stringByRemovingHTMLTags:[tag substringWithRange:NSMakeRange(previewStart, previewEnd-previewStart)]];
|
||||
return [[SearchResult alloc] initWithName:songName fromArtist:artist preview:preview link:link];
|
||||
}
|
||||
|
||||
-(NSURL*) urlFromHref: (NSString *) link {
|
||||
if ([link hasPrefix:@"/"]) {
|
||||
return [NSURL URLWithString:[NSString stringWithFormat:@"http://www.Magistrix.de%@", link]];
|
||||
} else {
|
||||
return [NSURL URLWithString:link];
|
||||
}
|
||||
}
|
||||
|
||||
-(NSString*) stringByRemovingHTMLTags: (NSString *)string {
|
||||
return [[[[[[[[[[string stringByReplacingOccurrencesOfString:@"<strong>" withString:@""] stringByReplacingOccurrencesOfString:@"</strong>" withString:@""] stringByReplacingOccurrencesOfString:@"<b>" withString:@""] stringByReplacingOccurrencesOfString:@"</b>" withString:@""] stringByReplacingOccurrencesOfString:@"<i>" withString:@""] stringByReplacingOccurrencesOfString:@"</i>" withString:@""] stringByReplacingOccurrencesOfString:@"<p>" withString:@""] stringByReplacingOccurrencesOfString:@"</p>" withString:@""] stringByReplacingOccurrencesOfString:@"<br />" withString:@""] stringByReplacingOccurrencesOfString:@""" withString:@"\""];
|
||||
}
|
||||
|
||||
-(NSRange) restRangeFromString: (NSString *) page subtractingRange: (NSRange) aRange {
|
||||
int loc = NSMaxRange(aRange);
|
||||
return NSMakeRange(loc, [page length]-loc);
|
||||
}
|
||||
|
||||
-(void) shouldSetResultCountFromPage: (NSString *) page {
|
||||
if (resultCount == 0) {
|
||||
//Nothing loaded before
|
||||
NSRange resultsLabelStartRange = [page rangeOfString:@"<p>Ergebnisse 1 bis "];
|
||||
int resultsLabelEnd = [page rangeOfString:@"</p>" options:NSCaseInsensitiveSearch range:[self restRangeFromString:page subtractingRange:resultsLabelStartRange]].location;
|
||||
NSString *resultsLabel = [page substringWithRange:NSMakeRange(NSMaxRange(resultsLabelStartRange), resultsLabelEnd-resultsLabelStartRange.location)];
|
||||
if ([resultsLabel rangeOfString:@"ungefähr"].location != NSNotFound){
|
||||
//Needs not more than 100 which means 10 sites (which is the maximum)
|
||||
resultCount = 100;
|
||||
} else {
|
||||
int resultsStart = NSMaxRange([resultsLabel rangeOfString:@"von "]);
|
||||
int resultsEnd = [resultsLabel rangeOfString:@"<"].location;
|
||||
NSString *results = [resultsLabel substringWithRange:NSMakeRange(resultsStart, resultsEnd-resultsStart)];
|
||||
resultCount = [results intValue];
|
||||
}
|
||||
if (resultCount > 100) {
|
||||
resultCount = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void) resetLoadedResults {
|
||||
loadedResults = 0;
|
||||
}
|
||||
|
||||
-(Lyrics*) lyricsBySearchResult: (SearchResult *) result {
|
||||
NSError *error = nil;
|
||||
NSString *page = [NSString stringWithContentsOfURL:[result link] encoding:NSUTF8StringEncoding error:&error];
|
||||
if (error) {
|
||||
return nil;
|
||||
}
|
||||
NSString *lyrics = [self lyricsFromPage:page];
|
||||
return [[Lyrics alloc] initWithName:[result name] byArtist:[result artist] withLyrics:lyrics];
|
||||
}
|
||||
|
||||
|
||||
-(NSString *) lyricsFromPage: (NSString *)page {
|
||||
int lyricsStart = NSMaxRange([page rangeOfString:@"<div id='songtext'>"]) + [@"\n" length];
|
||||
NSRange restRange = NSMakeRange(lyricsStart, [page length]-lyricsStart);
|
||||
int lyricsEnd = [page rangeOfString:@"<div class='clear'></div>" options:NSCaseInsensitiveSearch range:restRange].location;
|
||||
NSString *lyrics = [self stringByRemovingHTMLTags:[page substringWithRange:NSMakeRange(lyricsStart, lyricsEnd-lyricsStart)]];
|
||||
return lyrics;
|
||||
}
|
||||
@end
|
||||
46
iLyrics/MainController.h
Normal file
46
iLyrics/MainController.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// MainController.h
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 10.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Scripting/Scripting.h>
|
||||
#import <ScriptingBridge/ScriptingBridge.h>
|
||||
#import <AppKitScripting/AppKitScripting.h>
|
||||
#import "iTunes.h"
|
||||
#import "Magistrix.h"
|
||||
#import "SearchResult.h"
|
||||
#import "Lyrics.h"
|
||||
#import <Growl/Growl.h>
|
||||
|
||||
@interface MainController : NSObject <NSWindowDelegate, NSOutlineViewDataSource, NSOutlineViewDelegate>
|
||||
@property (weak) IBOutlet NSMenuItem *iLyricsMenuItem;
|
||||
@property (unsafe_unretained) IBOutlet NSWindow *window;
|
||||
@property (weak) IBOutlet NSSearchField *searchField;
|
||||
@property (weak) IBOutlet NSOutlineView *resultsOutline;
|
||||
@property (weak) IBOutlet NSButton *loadMoreResultsButton;
|
||||
@property (weak) IBOutlet NSButton *showPreviewCheckBox;
|
||||
@property (weak) IBOutlet NSPopover *previewPopover;
|
||||
@property (unsafe_unretained) IBOutlet NSTextView *previewTextArea;
|
||||
@property (weak) IBOutlet NSTextField *songLabel;
|
||||
@property (weak) IBOutlet NSTextField *artistLabel;
|
||||
@property (weak) IBOutlet NSButton *sendToiTunesButton;
|
||||
@property (weak) IBOutlet NSButton *downloadLyricsButton;
|
||||
@property (unsafe_unretained) IBOutlet NSTextView *lyricsArea;
|
||||
@property (readonly) Lyrics *currentLyrics;
|
||||
|
||||
- (IBAction)getCurrentiTunesSong:(id)sender;
|
||||
- (IBAction)startNewSearch:(id)sender;
|
||||
- (IBAction)loadNextResults:(id)sender;
|
||||
- (IBAction)resetLoadedResults:(id)sender;
|
||||
- (IBAction)lyricsSelectionChanged:(NSOutlineView *)sender;
|
||||
- (IBAction)sendLyricsToiTunes:(id)sender;
|
||||
- (IBAction)downloadLyrics:(id)sender;
|
||||
- (IBAction)showiLyricsWindow:(id)sender;
|
||||
- (void)saveToDefalts: (NSUserDefaults *)defaults;
|
||||
- (void)loadFromDefaults: (NSUserDefaults *)defaults;
|
||||
|
||||
@end
|
||||
283
iLyrics/MainController.m
Normal file
283
iLyrics/MainController.m
Normal file
@@ -0,0 +1,283 @@
|
||||
//
|
||||
// MainController.m
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 10.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MainController.h"
|
||||
|
||||
@implementation MainController {
|
||||
NSMutableArray *data;
|
||||
id<LyricsHoster> currentHoster;
|
||||
BOOL lyricsSelected;
|
||||
NSInteger selectedSavePanelButton;
|
||||
NSURL *saveFile;
|
||||
iTunesApplication *iTunes;
|
||||
Lyrics *currentLyrics;
|
||||
int selectedRow;
|
||||
}
|
||||
@synthesize iLyricsMenuItem;
|
||||
@synthesize window;
|
||||
@synthesize searchField;
|
||||
@synthesize resultsOutline;
|
||||
@synthesize loadMoreResultsButton;
|
||||
@synthesize showPreviewCheckBox;
|
||||
@synthesize previewPopover;
|
||||
@synthesize previewTextArea;
|
||||
@synthesize songLabel;
|
||||
@synthesize artistLabel;
|
||||
@synthesize sendToiTunesButton;
|
||||
@synthesize downloadLyricsButton;
|
||||
@synthesize lyricsArea;
|
||||
|
||||
|
||||
-(id)init {
|
||||
iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
|
||||
data = [[NSMutableArray alloc] init];
|
||||
currentHoster = [[Magistrix alloc] init];
|
||||
return [super init];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Outline view Data Source and Delegate
|
||||
-(NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
|
||||
return item == nil ? [data count] : 0;
|
||||
}
|
||||
|
||||
-(id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
|
||||
return [data objectAtIndex:index];
|
||||
}
|
||||
|
||||
-(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
|
||||
if ([[tableColumn identifier] isEqualToString:@"song"]) {
|
||||
return [item name];
|
||||
} else {
|
||||
return [item artist];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
-(NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item mouseLocation:(NSPoint)mouseLocation {
|
||||
//item is an instance of SearchResult
|
||||
[self shouldShowPreviewForCellRect:*rect searchResult:item];
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Responding to Lyrics Search
|
||||
|
||||
- (IBAction)getCurrentiTunesSong:(id)sender {
|
||||
iTunesTrack *track = [iTunes currentTrack];
|
||||
if (track == nil) {
|
||||
NSBeginAlertSheet(NSLocalizedString(@"iTunes.messages.iTunesIdle.title", @""), NSLocalizedString(@"OK", @""), nil, nil, window, nil, nil, nil, nil, NSLocalizedString(@"iTunes.messages.iTunesIdle.detail", @""));
|
||||
return;
|
||||
}
|
||||
NSString *name = [track name];
|
||||
NSString *artist = [track artist];
|
||||
if (name == nil) {
|
||||
NSBeginAlertSheet(NSLocalizedString(@"iTunes.messages.noTrackPlaying.title", @""), NSLocalizedString(@"OK", @""), nil, nil, window, nil, nil, nil, nil, NSLocalizedString(@"iTunes.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) {
|
||||
[currentHoster startNewSearchForQuery:[searchField stringValue]];
|
||||
[self loadNextResults:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)loadNextResults:(id)sender {
|
||||
NSArray *nextResults = [currentHoster nextResults];
|
||||
if (nextResults == nil) {
|
||||
NSRunCriticalAlertPanel(NSLocalizedString(@"Hoster.messages.networkError.title", @""), NSLocalizedString(@"Hoster.messages.networkError.detail", @""), NSLocalizedString(@"OK", @""), nil, nil);
|
||||
return;
|
||||
}
|
||||
if ([nextResults count] == 0) {
|
||||
NSRunAlertPanel(NSLocalizedString(@"Hoster.messages.noResults.title", @""), NSLocalizedString(@"Hoster.messages.noResults.detail", @""), NSLocalizedString(@"OK", @""), nil, nil);
|
||||
return;
|
||||
}
|
||||
[data addObjectsFromArray:nextResults];
|
||||
[resultsOutline reloadData];
|
||||
[loadMoreResultsButton setEnabled:[currentHoster hasMoreResults]];
|
||||
}
|
||||
|
||||
-(IBAction)resetLoadedResults:(id)sender {
|
||||
[currentHoster resetLoadedResults];
|
||||
[data removeAllObjects];
|
||||
[resultsOutline reloadData];
|
||||
[loadMoreResultsButton setEnabled:[currentHoster hasMoreResults]];
|
||||
[self lyricsSelectionChanged:resultsOutline];
|
||||
}
|
||||
|
||||
- (IBAction)lyricsSelectionChanged:(NSOutlineView *)sender {
|
||||
int index = [sender selectedRow];
|
||||
if (index < 0) {
|
||||
lyricsSelected = NO;
|
||||
currentLyrics = nil;
|
||||
NSString *noSelectionText = NSLocalizedString(@"iLyrics.text.noSelection", @"");
|
||||
[songLabel setStringValue:noSelectionText];
|
||||
[artistLabel setStringValue:noSelectionText];
|
||||
[lyricsArea setString:noSelectionText];
|
||||
[lyricsArea setEditable:NO];
|
||||
} else {
|
||||
if (selectedRow != index) {
|
||||
lyricsSelected = YES;
|
||||
SearchResult *result = [data objectAtIndex:index];
|
||||
Lyrics *lyrics = [currentHoster lyricsBySearchResult:result];
|
||||
currentLyrics = lyrics;
|
||||
if (lyrics == nil) {
|
||||
NSRunCriticalAlertPanel(NSLocalizedString(@"Hoster.messages.networkError.title", @""), NSLocalizedString(@"Hoster.messages.networkError.detail", @""), NSLocalizedString(@"OK", @""), nil, nil);
|
||||
NSString *noNetwork = NSLocalizedString(@"Hoster.text.noNetwork", @"");
|
||||
[songLabel setStringValue:noNetwork];
|
||||
[artistLabel setStringValue:noNetwork];
|
||||
[lyricsArea setString:noNetwork];
|
||||
[lyricsArea setEditable:NO];
|
||||
}
|
||||
[songLabel setStringValue:[lyrics name]];
|
||||
[artistLabel setStringValue:[lyrics artist]];
|
||||
[lyricsArea setString:[lyrics lyrics]];
|
||||
[lyricsArea setEditable:YES];
|
||||
}
|
||||
}
|
||||
selectedRow = index;
|
||||
[window update];
|
||||
}
|
||||
|
||||
-(void) shouldShowPreviewForCellRect: (NSRect) rect searchResult: (SearchResult *) result {
|
||||
if ([showPreviewCheckBox state] == NSOnState) {
|
||||
NSString *lyrics = [result preview];
|
||||
if (lyrics) {
|
||||
rect.size.width = [resultsOutline frame].size.width;
|
||||
[previewTextArea setString:lyrics];
|
||||
[previewPopover showRelativeToRect:rect ofView:resultsOutline preferredEdge:NSMaxXEdge];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)sendLyricsToiTunes:(id)sender {
|
||||
iTunesTrack *track = [iTunes currentTrack];
|
||||
NSString *name = [track name];
|
||||
if (name == nil) {
|
||||
NSBeginAlertSheet(NSLocalizedString(@"iTunes.messages.noTrackPlaying.title", @""), NSLocalizedString(@"OK", @""), nil, nil, window, nil, nil, nil, nil, NSLocalizedString(@"iTunes.messages.noTrackPlaying.detail", @""));
|
||||
return;
|
||||
}
|
||||
NSString *oldLyrics = [track lyrics];
|
||||
if (oldLyrics != nil && [oldLyrics length] > 0) {
|
||||
NSBeginAlertSheet(NSLocalizedString(@"iTunes.messages.replaceLyrics.title", @""), NSLocalizedString(@"Yes", @""), NSLocalizedString(@"No", @""), nil, window, self, @selector(replaceLyricsSheetDidEnd:returnCode:contextInfo:), nil, nil, NSLocalizedString(@"iTunes.messages.replaceLyrics.detail", @""));
|
||||
} else {
|
||||
[self replaceLyricsSheetDidEnd:nil returnCode:NSAlertDefaultReturn contextInfo:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)replaceLyricsSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
|
||||
if (returnCode == NSAlertDefaultReturn) {
|
||||
[[iTunes currentTrack] setLyrics:[lyricsArea string]];
|
||||
[GrowlApplicationBridge notifyWithTitle:NSLocalizedString(@"Growl.messages.lyricsSent.title", @"") description:NSLocalizedString(@"Growl.messages.lyricsSent.detail", @"") notificationName:@"Lyrics sent to iTunes" iconData:nil priority:0 isSticky:NO clickContext:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)downloadLyrics:(id)sender {
|
||||
NSSavePanel *savePanel = [NSSavePanel savePanel];
|
||||
[savePanel setAllowedFileTypes:[NSArray arrayWithObject:@"txt"]];
|
||||
[savePanel setAllowsOtherFileTypes:YES];
|
||||
[savePanel setCanSelectHiddenExtension:YES];
|
||||
[savePanel setExtensionHidden:YES];
|
||||
[savePanel setNameFieldStringValue:[currentLyrics name]];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(savePanelDidClose:) name:NSWindowDidEndSheetNotification object:window];
|
||||
void (^handler) (NSInteger) = ^(NSInteger result) {
|
||||
selectedSavePanelButton = result;
|
||||
saveFile = [savePanel URL];
|
||||
};
|
||||
[savePanel beginSheetModalForWindow:window completionHandler:handler];
|
||||
}
|
||||
|
||||
-(void) savePanelDidClose: (NSNotification *) notification{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidEndSheetNotification object:window];
|
||||
if (selectedSavePanelButton == NSOKButton) {
|
||||
BOOL success = [[[lyricsArea string] dataUsingEncoding:NSUTF8StringEncoding] writeToURL:saveFile atomically:NO];
|
||||
if (!success) {
|
||||
NSBeginAlertSheet(NSLocalizedString(@"messages.error.saveLyrics.title", @""), NSLocalizedString(@"OK", @""), nil, nil, window, nil, nil, nil, nil, NSLocalizedString(@"messages.error.saveLyrics.detail", @""));
|
||||
} else {
|
||||
[GrowlApplicationBridge notifyWithTitle:NSLocalizedString(@"Growl.messages.lyricsSaved.title", @"") description:[NSString stringWithFormat:NSLocalizedString(@"Growl.messages.lyricsSaved.detail", @""), [saveFile path]] notificationName:@"Lyrics saved to File" iconData:nil priority:0 isSticky:NO clickContext:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(Lyrics *)currentLyrics {
|
||||
return currentLyrics;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Show the window
|
||||
|
||||
- (IBAction)showiLyricsWindow:(id)sender {
|
||||
[window makeKeyAndOrderFront:sender];
|
||||
}
|
||||
|
||||
#pragma mark window delegate
|
||||
|
||||
-(BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
||||
return [self validateUserInterfaceItem:menuItem];
|
||||
}
|
||||
|
||||
-(BOOL)validateToolbarItem:(NSToolbarItem *)theItem {
|
||||
return [self validateUserInterfaceItem:theItem];
|
||||
}
|
||||
|
||||
-(BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
|
||||
SEL action = [item action];
|
||||
if (action == @selector(downloadLyrics:)) {
|
||||
[downloadLyricsButton setEnabled:lyricsSelected];
|
||||
return lyricsSelected;
|
||||
}
|
||||
if (action == @selector(sendLyricsToiTunes:)) {
|
||||
BOOL enabled = lyricsSelected && [iTunes isRunning];
|
||||
[sendToiTunesButton setEnabled:enabled];
|
||||
return enabled;
|
||||
}
|
||||
if (action == @selector(getCurrentiTunesSong:)) {
|
||||
return [iTunes isRunning];
|
||||
}
|
||||
if (action == @selector(showPreview:)) {
|
||||
return [resultsOutline clickedRow] >= 0;
|
||||
}
|
||||
return [self respondsToSelector:[item action]];
|
||||
}
|
||||
|
||||
-(void)windowDidBecomeMain:(NSNotification *)notification {
|
||||
[iLyricsMenuItem setOffStateImage:nil];
|
||||
[iLyricsMenuItem setState:NSOnState];
|
||||
}
|
||||
|
||||
-(void)windowDidResignMain:(NSNotification *)notification {
|
||||
[iLyricsMenuItem setOffStateImage:nil];
|
||||
[iLyricsMenuItem setState:NSOffState];
|
||||
}
|
||||
|
||||
-(void)windowDidMiniaturize:(NSNotification *)notification {
|
||||
NSString *imgPath = [[NSBundle mainBundle] pathForImageResource:@"Diamond"];
|
||||
NSImage *miniaturizedImage = [[NSImage alloc] initWithContentsOfFile:imgPath];
|
||||
[iLyricsMenuItem setOffStateImage:miniaturizedImage];
|
||||
[iLyricsMenuItem setState:NSOffState];
|
||||
}
|
||||
|
||||
-(void)saveToDefalts:(NSUserDefaults *)defaults {
|
||||
[defaults setBool:[showPreviewCheckBox state] == NSOnState forKey:@"Show preview"];
|
||||
}
|
||||
|
||||
-(void)loadFromDefaults:(NSUserDefaults *)defaults {
|
||||
[showPreviewCheckBox setState:[defaults boolForKey:@"Show preview"]?NSOnState:NSOffState];
|
||||
}
|
||||
@end
|
||||
20
iLyrics/PreferencesController.h
Normal file
20
iLyrics/PreferencesController.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// PreferencesController.h
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 14.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "LyricsHoster.h"
|
||||
|
||||
@interface PreferencesController : NSObject <NSTableViewDataSource>
|
||||
|
||||
@property (weak) IBOutlet NSTableView *hosterTable;
|
||||
@property NSArray *hosters;
|
||||
|
||||
-(void) addHoster: (id<LyricsHoster>) hoster;
|
||||
-(void) removeHoster: (id<LyricsHoster>) hoster;
|
||||
|
||||
@end
|
||||
64
iLyrics/PreferencesController.m
Normal file
64
iLyrics/PreferencesController.m
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// PreferencesController.m
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 14.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PreferencesController.h"
|
||||
|
||||
@implementation PreferencesController {
|
||||
NSMutableArray *hosters;
|
||||
}
|
||||
@synthesize hosterTable;
|
||||
|
||||
-(id)init {
|
||||
hosters = [[NSMutableArray alloc] init];
|
||||
return [super init];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Properties
|
||||
|
||||
-(NSArray *)hosters {
|
||||
return hosters;
|
||||
}
|
||||
|
||||
-(void)setHosters:(NSArray *)hstrs {
|
||||
hosters = [NSMutableArray arrayWithArray:hstrs];
|
||||
[hosterTable reloadData];
|
||||
}
|
||||
|
||||
#pragma mark Modifying hosters
|
||||
|
||||
-(void)addHoster:(id<LyricsHoster>)hoster {
|
||||
[hosters addObject:hoster];
|
||||
[hosterTable reloadData];
|
||||
}
|
||||
|
||||
-(void)removeHoster:(id<LyricsHoster>)hoster {
|
||||
[hosters removeObject:hoster];
|
||||
[hosterTable reloadData];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Table Data Source
|
||||
-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
|
||||
return [hosters count];
|
||||
}
|
||||
|
||||
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
if ([[tableColumn identifier] isEqualToString:@"hoster"]) {
|
||||
return [[hosters objectAtIndex:row] name];
|
||||
} else {
|
||||
NSDate *version = [[hosters objectAtIndex:row] hosterVersion];
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
|
||||
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
|
||||
return [dateFormatter stringFromDate:version];
|
||||
// return desc == nil ? NSLocalizedString(@"iLyrics.text.illegalDateFormat", @"") : desc;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
19
iLyrics/SearchResult.h
Normal file
19
iLyrics/SearchResult.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SearchResult.h
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 10.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SearchResult : NSObject
|
||||
@property NSString *name;
|
||||
@property NSString *artist;
|
||||
@property NSString *preview;
|
||||
@property id link;
|
||||
|
||||
-(id)initWithName: (NSString*) name fromArtist: (NSString*) artist preview: (NSString*) preview link: (id) link;
|
||||
|
||||
@end
|
||||
25
iLyrics/SearchResult.m
Normal file
25
iLyrics/SearchResult.m
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// SearchResult.m
|
||||
// iLyrics
|
||||
//
|
||||
// Created by Kim Wittenburg on 10.06.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SearchResult.h"
|
||||
|
||||
@implementation SearchResult
|
||||
@synthesize name;
|
||||
@synthesize artist;
|
||||
@synthesize preview;
|
||||
@synthesize link;
|
||||
|
||||
-(id)initWithName:(NSString *)sng fromArtist:(NSString *)art preview:(NSString *)pre link:(id)l {
|
||||
name = sng;
|
||||
artist = art;
|
||||
preview = pre;
|
||||
link = l;
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
19
iLyrics/de.lproj/Credits.rtf
Normal file
19
iLyrics/de.lproj/Credits.rtf
Normal file
@@ -0,0 +1,19 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf470
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw11900\paperh16840\vieww9600\viewh8400\viewkind0
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
|
||||
|
||||
\f0\b\fs24 \cf0 Entwickelt von:
|
||||
\b0 \
|
||||
Kim Wittenburg\
|
||||
\
|
||||
|
||||
\b Designed von:
|
||||
\b0 \
|
||||
Kim Wittenburg\
|
||||
\
|
||||
|
||||
\b Getestet von:
|
||||
\b0 \
|
||||
Kim Wittenbug}
|
||||
@@ -1,29 +1,19 @@
|
||||
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf470
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw9840\paperh8400
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
|
||||
\paperw11900\paperh16840\vieww9600\viewh8400\viewkind0
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
|
||||
|
||||
\f0\b\fs24 \cf0 Engineering:
|
||||
\b0 \
|
||||
Some people\
|
||||
Kim Wittenburg\
|
||||
\
|
||||
|
||||
\b Human Interface Design:
|
||||
\b0 \
|
||||
Some other people\
|
||||
Kim Wittenburg\
|
||||
\
|
||||
|
||||
\b Testing:
|
||||
\b0 \
|
||||
Hopefully not nobody\
|
||||
\
|
||||
|
||||
\b Documentation:
|
||||
\b0 \
|
||||
Whoever\
|
||||
\
|
||||
|
||||
\b With special thanks to:
|
||||
\b0 \
|
||||
Mom\
|
||||
}
|
||||
Kim Wittenbug}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<string>iLyrics.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>wittenburg.kim.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
|
||||
506
iLyrics/iTunes.h
Normal file
506
iLyrics/iTunes.h
Normal file
@@ -0,0 +1,506 @@
|
||||
/*
|
||||
* iTunes.h
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <ScriptingBridge/ScriptingBridge.h>
|
||||
|
||||
|
||||
@class iTunesPrintSettings, iTunesApplication, iTunesItem, iTunesArtwork, iTunesEncoder, iTunesEQPreset, iTunesPlaylist, iTunesAudioCDPlaylist, iTunesDevicePlaylist, iTunesLibraryPlaylist, iTunesRadioTunerPlaylist, iTunesSource, iTunesTrack, iTunesAudioCDTrack, iTunesDeviceTrack, iTunesFileTrack, iTunesSharedTrack, iTunesURLTrack, iTunesUserPlaylist, iTunesFolderPlaylist, iTunesVisual, iTunesWindow, iTunesBrowserWindow, iTunesEQWindow, iTunesPlaylistWindow;
|
||||
|
||||
enum iTunesEKnd {
|
||||
iTunesEKndTrackListing = 'kTrk' /* a basic listing of tracks within a playlist */,
|
||||
iTunesEKndAlbumListing = 'kAlb' /* a listing of a playlist grouped by album */,
|
||||
iTunesEKndCdInsert = 'kCDi' /* a printout of the playlist for jewel case inserts */
|
||||
};
|
||||
typedef enum iTunesEKnd iTunesEKnd;
|
||||
|
||||
enum iTunesEnum {
|
||||
iTunesEnumStandard = 'lwst' /* Standard PostScript error handling */,
|
||||
iTunesEnumDetailed = 'lwdt' /* print a detailed report of PostScript errors */
|
||||
};
|
||||
typedef enum iTunesEnum iTunesEnum;
|
||||
|
||||
enum iTunesEPlS {
|
||||
iTunesEPlSStopped = 'kPSS',
|
||||
iTunesEPlSPlaying = 'kPSP',
|
||||
iTunesEPlSPaused = 'kPSp',
|
||||
iTunesEPlSFastForwarding = 'kPSF',
|
||||
iTunesEPlSRewinding = 'kPSR'
|
||||
};
|
||||
typedef enum iTunesEPlS iTunesEPlS;
|
||||
|
||||
enum iTunesERpt {
|
||||
iTunesERptOff = 'kRpO',
|
||||
iTunesERptOne = 'kRp1',
|
||||
iTunesERptAll = 'kAll'
|
||||
};
|
||||
typedef enum iTunesERpt iTunesERpt;
|
||||
|
||||
enum iTunesEVSz {
|
||||
iTunesEVSzSmall = 'kVSS',
|
||||
iTunesEVSzMedium = 'kVSM',
|
||||
iTunesEVSzLarge = 'kVSL'
|
||||
};
|
||||
typedef enum iTunesEVSz iTunesEVSz;
|
||||
|
||||
enum iTunesESrc {
|
||||
iTunesESrcLibrary = 'kLib',
|
||||
iTunesESrcIPod = 'kPod',
|
||||
iTunesESrcAudioCD = 'kACD',
|
||||
iTunesESrcMP3CD = 'kMCD',
|
||||
iTunesESrcDevice = 'kDev',
|
||||
iTunesESrcRadioTuner = 'kTun',
|
||||
iTunesESrcSharedLibrary = 'kShd',
|
||||
iTunesESrcUnknown = 'kUnk'
|
||||
};
|
||||
typedef enum iTunesESrc iTunesESrc;
|
||||
|
||||
enum iTunesESrA {
|
||||
iTunesESrAAlbums = 'kSrL' /* albums only */,
|
||||
iTunesESrAAll = 'kAll' /* all text fields */,
|
||||
iTunesESrAArtists = 'kSrR' /* artists only */,
|
||||
iTunesESrAComposers = 'kSrC' /* composers only */,
|
||||
iTunesESrADisplayed = 'kSrV' /* visible text fields */,
|
||||
iTunesESrASongs = 'kSrS' /* song names only */
|
||||
};
|
||||
typedef enum iTunesESrA iTunesESrA;
|
||||
|
||||
enum iTunesESpK {
|
||||
iTunesESpKNone = 'kNon',
|
||||
iTunesESpKBooks = 'kSpA',
|
||||
iTunesESpKFolder = 'kSpF',
|
||||
iTunesESpKGenius = 'kSpG',
|
||||
iTunesESpKITunesU = 'kSpU',
|
||||
iTunesESpKLibrary = 'kSpL',
|
||||
iTunesESpKMovies = 'kSpI',
|
||||
iTunesESpKMusic = 'kSpZ',
|
||||
iTunesESpKPartyShuffle = 'kSpS',
|
||||
iTunesESpKPodcasts = 'kSpP',
|
||||
iTunesESpKPurchasedMusic = 'kSpM',
|
||||
iTunesESpKTVShows = 'kSpT'
|
||||
};
|
||||
typedef enum iTunesESpK iTunesESpK;
|
||||
|
||||
enum iTunesEVdK {
|
||||
iTunesEVdKNone = 'kNon' /* not a video or unknown video kind */,
|
||||
iTunesEVdKMovie = 'kVdM' /* movie track */,
|
||||
iTunesEVdKMusicVideo = 'kVdV' /* music video track */,
|
||||
iTunesEVdKTVShow = 'kVdT' /* TV show track */
|
||||
};
|
||||
typedef enum iTunesEVdK iTunesEVdK;
|
||||
|
||||
enum iTunesERtK {
|
||||
iTunesERtKUser = 'kRtU' /* user-specified rating */,
|
||||
iTunesERtKComputed = 'kRtC' /* iTunes-computed rating */
|
||||
};
|
||||
typedef enum iTunesERtK iTunesERtK;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Standard Suite
|
||||
*/
|
||||
|
||||
@interface iTunesPrintSettings : SBObject
|
||||
|
||||
@property (readonly) NSInteger copies; // the number of copies of a document to be printed
|
||||
@property (readonly) BOOL collating; // Should printed copies be collated?
|
||||
@property (readonly) NSInteger startingPage; // the first page of the document to be printed
|
||||
@property (readonly) NSInteger endingPage; // the last page of the document to be printed
|
||||
@property (readonly) NSInteger pagesAcross; // number of logical pages laid across a physical page
|
||||
@property (readonly) NSInteger pagesDown; // number of logical pages laid out down a physical page
|
||||
@property (readonly) iTunesEnum errorHandling; // how errors are handled
|
||||
@property (copy, readonly) NSDate *requestedPrintTime; // the time at which the desktop printer should print the document
|
||||
@property (copy, readonly) NSArray *printerFeatures; // printer specific options
|
||||
@property (copy, readonly) NSString *faxNumber; // for fax number
|
||||
@property (copy, readonly) NSString *targetPrinter; // for target printer
|
||||
|
||||
- (void) printPrintDialog:(BOOL)printDialog withProperties:(iTunesPrintSettings *)withProperties kind:(iTunesEKnd)kind theme:(NSString *)theme; // Print the specified object(s)
|
||||
- (void) close; // Close an object
|
||||
- (void) delete; // Delete an element from an object
|
||||
- (SBObject *) duplicateTo:(SBObject *)to; // Duplicate one or more object(s)
|
||||
- (BOOL) exists; // Verify if an object exists
|
||||
- (void) open; // open the specified object(s)
|
||||
- (void) playOnce:(BOOL)once; // play the current track or the specified track or file.
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* iTunes Suite
|
||||
*/
|
||||
|
||||
// The application program
|
||||
@interface iTunesApplication : SBApplication
|
||||
|
||||
- (SBElementArray *) browserWindows;
|
||||
- (SBElementArray *) encoders;
|
||||
- (SBElementArray *) EQPresets;
|
||||
- (SBElementArray *) EQWindows;
|
||||
- (SBElementArray *) playlistWindows;
|
||||
- (SBElementArray *) sources;
|
||||
- (SBElementArray *) visuals;
|
||||
- (SBElementArray *) windows;
|
||||
|
||||
@property (copy) iTunesEncoder *currentEncoder; // the currently selected encoder (MP3, AIFF, WAV, etc.)
|
||||
@property (copy) iTunesEQPreset *currentEQPreset; // the currently selected equalizer preset
|
||||
@property (copy, readonly) iTunesPlaylist *currentPlaylist; // the playlist containing the currently targeted track
|
||||
@property (copy, readonly) NSString *currentStreamTitle; // the name of the current song in the playing stream (provided by streaming server)
|
||||
@property (copy, readonly) NSString *currentStreamURL; // the URL of the playing stream or streaming web site (provided by streaming server)
|
||||
@property (copy, readonly) iTunesTrack *currentTrack; // the current targeted track
|
||||
@property (copy) iTunesVisual *currentVisual; // the currently selected visual plug-in
|
||||
@property BOOL EQEnabled; // is the equalizer enabled?
|
||||
@property BOOL fixedIndexing; // true if all AppleScript track indices should be independent of the play order of the owning playlist.
|
||||
@property BOOL frontmost; // is iTunes the frontmost application?
|
||||
@property BOOL fullScreen; // are visuals displayed using the entire screen?
|
||||
@property (copy, readonly) NSString *name; // the name of the application
|
||||
@property BOOL mute; // has the sound output been muted?
|
||||
@property NSInteger playerPosition; // the player’s position within the currently playing track in seconds.
|
||||
@property (readonly) iTunesEPlS playerState; // is iTunes stopped, paused, or playing?
|
||||
@property (copy, readonly) SBObject *selection; // the selection visible to the user
|
||||
@property NSInteger soundVolume; // the sound output volume (0 = minimum, 100 = maximum)
|
||||
@property (copy, readonly) NSString *version; // the version of iTunes
|
||||
@property BOOL visualsEnabled; // are visuals currently being displayed?
|
||||
@property iTunesEVSz visualSize; // the size of the displayed visual
|
||||
|
||||
- (void) printPrintDialog:(BOOL)printDialog withProperties:(iTunesPrintSettings *)withProperties kind:(iTunesEKnd)kind theme:(NSString *)theme; // Print the specified object(s)
|
||||
- (void) run; // run iTunes
|
||||
- (void) quit; // quit iTunes
|
||||
- (iTunesTrack *) add:(NSArray *)x to:(SBObject *)to; // add one or more files to a playlist
|
||||
- (void) backTrack; // reposition to beginning of current track or go to previous track if already at start of current track
|
||||
- (iTunesTrack *) convert:(NSArray *)x; // convert one or more files or tracks
|
||||
- (void) fastForward; // skip forward in a playing track
|
||||
- (void) nextTrack; // advance to the next track in the current playlist
|
||||
- (void) pause; // pause playback
|
||||
- (void) playOnce:(BOOL)once; // play the current track or the specified track or file.
|
||||
- (void) playpause; // toggle the playing/paused state of the current track
|
||||
- (void) previousTrack; // return to the previous track in the current playlist
|
||||
- (void) resume; // disable fast forward/rewind and resume playback, if playing.
|
||||
- (void) rewind; // skip backwards in a playing track
|
||||
- (void) stop; // stop playback
|
||||
- (void) update; // update the specified iPod
|
||||
- (void) eject; // eject the specified iPod
|
||||
- (void) subscribe:(NSString *)x; // subscribe to a podcast feed
|
||||
- (void) updateAllPodcasts; // update all subscribed podcast feeds
|
||||
- (void) updatePodcast; // update podcast feed
|
||||
- (void) openLocation:(NSString *)x; // Opens a Music Store or audio stream URL
|
||||
|
||||
@end
|
||||
|
||||
// an item
|
||||
@interface iTunesItem : SBObject
|
||||
|
||||
@property (copy, readonly) SBObject *container; // the container of the item
|
||||
- (NSInteger) id; // the id of the item
|
||||
@property (readonly) NSInteger index; // The index of the item in internal application order.
|
||||
@property (copy) NSString *name; // the name of the item
|
||||
@property (copy, readonly) NSString *persistentID; // the id of the item as a hexidecimal string. This id does not change over time.
|
||||
|
||||
- (void) printPrintDialog:(BOOL)printDialog withProperties:(iTunesPrintSettings *)withProperties kind:(iTunesEKnd)kind theme:(NSString *)theme; // Print the specified object(s)
|
||||
- (void) close; // Close an object
|
||||
- (void) delete; // Delete an element from an object
|
||||
- (SBObject *) duplicateTo:(SBObject *)to; // Duplicate one or more object(s)
|
||||
- (BOOL) exists; // Verify if an object exists
|
||||
- (void) open; // open the specified object(s)
|
||||
- (void) playOnce:(BOOL)once; // play the current track or the specified track or file.
|
||||
- (void) reveal; // reveal and select a track or playlist
|
||||
|
||||
@end
|
||||
|
||||
// a piece of art within a track
|
||||
@interface iTunesArtwork : iTunesItem
|
||||
|
||||
@property (copy) NSImage *data; // data for this artwork, in the form of a picture
|
||||
@property (copy) NSString *objectDescription; // description of artwork as a string
|
||||
@property (readonly) BOOL downloaded; // was this artwork downloaded by iTunes?
|
||||
@property (copy, readonly) NSNumber *format; // the data format for this piece of artwork
|
||||
@property NSInteger kind; // kind or purpose of this piece of artwork
|
||||
@property (copy) NSData *rawData; // data for this artwork, in original format
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// converts a track to a specific file format
|
||||
@interface iTunesEncoder : iTunesItem
|
||||
|
||||
@property (copy, readonly) NSString *format; // the data format created by the encoder
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// equalizer preset configuration
|
||||
@interface iTunesEQPreset : iTunesItem
|
||||
|
||||
@property double band1; // the equalizer 32 Hz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band2; // the equalizer 64 Hz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band3; // the equalizer 125 Hz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band4; // the equalizer 250 Hz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band5; // the equalizer 500 Hz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band6; // the equalizer 1 kHz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band7; // the equalizer 2 kHz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band8; // the equalizer 4 kHz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band9; // the equalizer 8 kHz band level (-12.0 dB to +12.0 dB)
|
||||
@property double band10; // the equalizer 16 kHz band level (-12.0 dB to +12.0 dB)
|
||||
@property (readonly) BOOL modifiable; // can this preset be modified?
|
||||
@property double preamp; // the equalizer preamp level (-12.0 dB to +12.0 dB)
|
||||
@property BOOL updateTracks; // should tracks which refer to this preset be updated when the preset is renamed or deleted?
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a list of songs/streams
|
||||
@interface iTunesPlaylist : iTunesItem
|
||||
|
||||
- (SBElementArray *) tracks;
|
||||
|
||||
@property (readonly) NSInteger duration; // the total length of all songs (in seconds)
|
||||
@property (copy) NSString *name; // the name of the playlist
|
||||
@property (copy, readonly) iTunesPlaylist *parent; // folder which contains this playlist (if any)
|
||||
@property BOOL shuffle; // play the songs in this playlist in random order?
|
||||
@property (readonly) long long size; // the total size of all songs (in bytes)
|
||||
@property iTunesERpt songRepeat; // playback repeat mode
|
||||
@property (readonly) iTunesESpK specialKind; // special playlist kind
|
||||
@property (copy, readonly) NSString *time; // the length of all songs in MM:SS format
|
||||
@property (readonly) BOOL visible; // is this playlist visible in the Source list?
|
||||
|
||||
- (void) moveTo:(SBObject *)to; // Move playlist(s) to a new location
|
||||
- (iTunesTrack *) searchFor:(NSString *)for_ only:(iTunesESrA)only; // search a playlist for tracks matching the search string. Identical to entering search text in the Search field in iTunes.
|
||||
|
||||
@end
|
||||
|
||||
// a playlist representing an audio CD
|
||||
@interface iTunesAudioCDPlaylist : iTunesPlaylist
|
||||
|
||||
- (SBElementArray *) audioCDTracks;
|
||||
|
||||
@property (copy) NSString *artist; // the artist of the CD
|
||||
@property BOOL compilation; // is this CD a compilation album?
|
||||
@property (copy) NSString *composer; // the composer of the CD
|
||||
@property NSInteger discCount; // the total number of discs in this CD’s album
|
||||
@property NSInteger discNumber; // the index of this CD disc in the source album
|
||||
@property (copy) NSString *genre; // the genre of the CD
|
||||
@property NSInteger year; // the year the album was recorded/released
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a playlist representing the contents of a portable device
|
||||
@interface iTunesDevicePlaylist : iTunesPlaylist
|
||||
|
||||
- (SBElementArray *) deviceTracks;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// the master music library playlist
|
||||
@interface iTunesLibraryPlaylist : iTunesPlaylist
|
||||
|
||||
- (SBElementArray *) fileTracks;
|
||||
- (SBElementArray *) URLTracks;
|
||||
- (SBElementArray *) sharedTracks;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// the radio tuner playlist
|
||||
@interface iTunesRadioTunerPlaylist : iTunesPlaylist
|
||||
|
||||
- (SBElementArray *) URLTracks;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a music source (music library, CD, device, etc.)
|
||||
@interface iTunesSource : iTunesItem
|
||||
|
||||
- (SBElementArray *) audioCDPlaylists;
|
||||
- (SBElementArray *) devicePlaylists;
|
||||
- (SBElementArray *) libraryPlaylists;
|
||||
- (SBElementArray *) playlists;
|
||||
- (SBElementArray *) radioTunerPlaylists;
|
||||
- (SBElementArray *) userPlaylists;
|
||||
|
||||
@property (readonly) long long capacity; // the total size of the source if it has a fixed size
|
||||
@property (readonly) long long freeSpace; // the free space on the source if it has a fixed size
|
||||
@property (readonly) iTunesESrc kind;
|
||||
|
||||
- (void) update; // update the specified iPod
|
||||
- (void) eject; // eject the specified iPod
|
||||
|
||||
@end
|
||||
|
||||
// playable audio source
|
||||
@interface iTunesTrack : iTunesItem
|
||||
|
||||
- (SBElementArray *) artworks;
|
||||
|
||||
@property (copy) NSString *album; // the album name of the track
|
||||
@property (copy) NSString *albumArtist; // the album artist of the track
|
||||
@property NSInteger albumRating; // the rating of the album for this track (0 to 100)
|
||||
@property (readonly) iTunesERtK albumRatingKind; // the rating kind of the album rating for this track
|
||||
@property (copy) NSString *artist; // the artist/source of the track
|
||||
@property (readonly) NSInteger bitRate; // the bit rate of the track (in kbps)
|
||||
@property double bookmark; // the bookmark time of the track in seconds
|
||||
@property BOOL bookmarkable; // is the playback position for this track remembered?
|
||||
@property NSInteger bpm; // the tempo of this track in beats per minute
|
||||
@property (copy) NSString *category; // the category of the track
|
||||
@property (copy) NSString *comment; // freeform notes about the track
|
||||
@property BOOL compilation; // is this track from a compilation album?
|
||||
@property (copy) NSString *composer; // the composer of the track
|
||||
@property (readonly) NSInteger databaseID; // the common, unique ID for this track. If two tracks in different playlists have the same database ID, they are sharing the same data.
|
||||
@property (copy, readonly) NSDate *dateAdded; // the date the track was added to the playlist
|
||||
@property (copy) NSString *objectDescription; // the description of the track
|
||||
@property NSInteger discCount; // the total number of discs in the source album
|
||||
@property NSInteger discNumber; // the index of the disc containing this track on the source album
|
||||
@property (readonly) double duration; // the length of the track in seconds
|
||||
@property BOOL enabled; // is this track checked for playback?
|
||||
@property (copy) NSString *episodeID; // the episode ID of the track
|
||||
@property NSInteger episodeNumber; // the episode number of the track
|
||||
@property (copy) NSString *EQ; // the name of the EQ preset of the track
|
||||
@property double finish; // the stop time of the track in seconds
|
||||
@property BOOL gapless; // is this track from a gapless album?
|
||||
@property (copy) NSString *genre; // the music/audio genre (category) of the track
|
||||
@property (copy) NSString *grouping; // the grouping (piece) of the track. Generally used to denote movements within a classical work.
|
||||
@property (copy, readonly) NSString *kind; // a text description of the track
|
||||
@property (copy) NSString *longDescription;
|
||||
@property (copy) NSString *lyrics; // the lyrics of the track
|
||||
@property (copy, readonly) NSDate *modificationDate; // the modification date of the content of this track
|
||||
@property NSInteger playedCount; // number of times this track has been played
|
||||
@property (copy) NSDate *playedDate; // the date and time this track was last played
|
||||
@property (readonly) BOOL podcast; // is this track a podcast episode?
|
||||
@property NSInteger rating; // the rating of this track (0 to 100)
|
||||
@property (readonly) iTunesERtK ratingKind; // the rating kind of this track
|
||||
@property (copy, readonly) NSDate *releaseDate; // the release date of this track
|
||||
@property (readonly) NSInteger sampleRate; // the sample rate of the track (in Hz)
|
||||
@property NSInteger seasonNumber; // the season number of the track
|
||||
@property BOOL shufflable; // is this track included when shuffling?
|
||||
@property NSInteger skippedCount; // number of times this track has been skipped
|
||||
@property (copy) NSDate *skippedDate; // the date and time this track was last skipped
|
||||
@property (copy) NSString *show; // the show name of the track
|
||||
@property (copy) NSString *sortAlbum; // override string to use for the track when sorting by album
|
||||
@property (copy) NSString *sortArtist; // override string to use for the track when sorting by artist
|
||||
@property (copy) NSString *sortAlbumArtist; // override string to use for the track when sorting by album artist
|
||||
@property (copy) NSString *sortName; // override string to use for the track when sorting by name
|
||||
@property (copy) NSString *sortComposer; // override string to use for the track when sorting by composer
|
||||
@property (copy) NSString *sortShow; // override string to use for the track when sorting by show name
|
||||
@property (readonly) NSInteger size; // the size of the track (in bytes)
|
||||
@property double start; // the start time of the track in seconds
|
||||
@property (copy, readonly) NSString *time; // the length of the track in MM:SS format
|
||||
@property NSInteger trackCount; // the total number of tracks on the source album
|
||||
@property NSInteger trackNumber; // the index of the track on the source album
|
||||
@property BOOL unplayed; // is this track unplayed?
|
||||
@property iTunesEVdK videoKind; // kind of video track
|
||||
@property NSInteger volumeAdjustment; // relative volume adjustment of the track (-100% to 100%)
|
||||
@property NSInteger year; // the year the track was recorded/released
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a track on an audio CD
|
||||
@interface iTunesAudioCDTrack : iTunesTrack
|
||||
|
||||
@property (copy, readonly) NSURL *location; // the location of the file represented by this track
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a track residing on a portable music player
|
||||
@interface iTunesDeviceTrack : iTunesTrack
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a track representing an audio file (MP3, AIFF, etc.)
|
||||
@interface iTunesFileTrack : iTunesTrack
|
||||
|
||||
@property (copy) NSURL *location; // the location of the file represented by this track
|
||||
|
||||
- (void) refresh; // update file track information from the current information in the track’s file
|
||||
|
||||
@end
|
||||
|
||||
// a track residing in a shared library
|
||||
@interface iTunesSharedTrack : iTunesTrack
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a track representing a network stream
|
||||
@interface iTunesURLTrack : iTunesTrack
|
||||
|
||||
@property (copy) NSString *address; // the URL for this track
|
||||
|
||||
- (void) download; // download podcast episode
|
||||
|
||||
@end
|
||||
|
||||
// custom playlists created by the user
|
||||
@interface iTunesUserPlaylist : iTunesPlaylist
|
||||
|
||||
- (SBElementArray *) fileTracks;
|
||||
- (SBElementArray *) URLTracks;
|
||||
- (SBElementArray *) sharedTracks;
|
||||
|
||||
@property BOOL shared; // is this playlist shared?
|
||||
@property (readonly) BOOL smart; // is this a Smart Playlist?
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a folder that contains other playlists
|
||||
@interface iTunesFolderPlaylist : iTunesUserPlaylist
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a visual plug-in
|
||||
@interface iTunesVisual : iTunesItem
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// any window
|
||||
@interface iTunesWindow : iTunesItem
|
||||
|
||||
@property NSRect bounds; // the boundary rectangle for the window
|
||||
@property (readonly) BOOL closeable; // does the window have a close box?
|
||||
@property (readonly) BOOL collapseable; // does the window have a collapse (windowshade) box?
|
||||
@property BOOL collapsed; // is the window collapsed?
|
||||
@property NSPoint position; // the upper left position of the window
|
||||
@property (readonly) BOOL resizable; // is the window resizable?
|
||||
@property BOOL visible; // is the window visible?
|
||||
@property (readonly) BOOL zoomable; // is the window zoomable?
|
||||
@property BOOL zoomed; // is the window zoomed?
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// the main iTunes window
|
||||
@interface iTunesBrowserWindow : iTunesWindow
|
||||
|
||||
@property BOOL minimized; // is the small player visible?
|
||||
@property (copy, readonly) SBObject *selection; // the selected songs
|
||||
@property (copy) iTunesPlaylist *view; // the playlist currently displayed in the window
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// the iTunes equalizer window
|
||||
@interface iTunesEQWindow : iTunesWindow
|
||||
|
||||
@property BOOL minimized; // is the small EQ window visible?
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// a sub-window showing a single playlist
|
||||
@interface iTunesPlaylistWindow : iTunesWindow
|
||||
|
||||
@property (copy, readonly) SBObject *selection; // the selected songs
|
||||
@property (copy, readonly) iTunesPlaylist *view; // the playlist displayed in the window
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user