Created
April 13, 2012 09:37
-
-
Save runeb/2375436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "RBAppDelegate.h" | |
@implementation RBAppDelegate | |
- (void) createMenu | |
{ | |
NSStatusBar *bar = [NSStatusBar systemStatusBar]; | |
systemStatusItem = [bar statusItemWithLength:NSVariableStatusItemLength]; | |
[systemStatusItem setTitle:@"Radio"]; | |
[systemStatusItem setHighlightMode:YES]; | |
[systemStatusItem retain]; | |
NSMenu *appMenu = [[NSMenu alloc] init]; | |
NSString *stationsPath = [[NSBundle mainBundle] | |
pathForResource:@"stations" | |
ofType:@"plist"]; | |
NSArray *stations = [NSArray arrayWithContentsOfFile:stationsPath]; | |
for(NSDictionary *station in stations) { | |
NSString *name = [station valueForKey:@"name"]; | |
[appMenu addItemWithTitle:name action:NULL keyEquivalent:@""]; | |
} | |
[appMenu addItemWithTitle:@"Avslutt" action:@selector(quit) keyEquivalent:@""]; | |
[systemStatusItem setMenu:appMenu]; | |
[appMenu release]; | |
} | |
-(void) playURLString:(NSString*) urlString | |
{ | |
NSURL *url = [NSURL URLWithString:urlString]; | |
NSDictionary *movieAttrs = [NSDictionary dictionaryWithObjectsAndKeys: | |
url, | |
QTMovieURLAttribute, | |
[NSNumber numberWithBool:YES], | |
QTMovieOpenForPlaybackAttribute, | |
nil]; | |
if(radio) { | |
[radio stop]; | |
[radio release]; | |
} | |
radio = [[QTMovie alloc] initWithAttributes:movieAttrs error:nil]; | |
[radio autoplay]; | |
} | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | |
{ | |
[self createMenu]; | |
} | |
- (void) quit { | |
[NSApp terminate:NULL]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment