Skip to content

Instantly share code, notes, and snippets.

@runeb
Created April 13, 2012 09:37
Show Gist options
  • Save runeb/2375436 to your computer and use it in GitHub Desktop.
Save runeb/2375436 to your computer and use it in GitHub Desktop.
#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