Skip to content

Instantly share code, notes, and snippets.

@maxchuquimia
Last active August 29, 2015 14:17
Show Gist options
  • Save maxchuquimia/42805a7d97916c86242a to your computer and use it in GitHub Desktop.
Save maxchuquimia/42805a7d97916c86242a to your computer and use it in GitHub Desktop.
Because sometimes you don't want to tab to iTunes when you're listening to a stream.
//gcc -o audiostream audiostream.m -framework Foundation -framework AppKit -framework AVFoundation
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <AppKit/AppKit.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSUserDefaults *args = [NSUserDefaults standardUserDefaults];
NSString *stream = [args objectForKey:@"s"] ?: [args objectForKey:@"-stream"];
if (!stream) {
NSLog(@"Usage: audiostream -s,--stream <stream URL>");
return 1;
}
AVPlayer *player = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:stream]];
[player play];
[[NSApplication sharedApplication] run];
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment