Last active
August 29, 2015 14:17
-
-
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.
This file contains 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
//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