Permalink
Browse files

initial commit for OSS Play

  • Loading branch information...
maddox committed Apr 9, 2012
0 parents commit e1d6aad46ce62aaf500c69125512ab409da68f4b
Showing with 14,812 additions and 0 deletions.
  1. +16 −0 .gitignore
  2. +16 −0 CHANGELOG.md
  3. +17 −0 Play Client/PLAPlayClient.h
  4. +48 −0 Play Client/PLAPlayClient.m
  5. +31 −0 Play Client/PLATrack.h
  6. +55 −0 Play Client/PLATrack.m
  7. +860 −0 Play Item.xcodeproj/project.pbxproj
  8. +31 −0 Play Item/PLAItemAppDelegate.h
  9. +193 −0 Play Item/PLAItemAppDelegate.m
  10. +8 −0 Play Item/Supporting Files/IgnoredAudioProcesses.plist
  11. +38 −0 Play Item/Supporting Files/Play-Info.plist
  12. +7 −0 Play Item/Supporting Files/Play-Prefix.pch
  13. +29 −0 Play Item/Supporting Files/en.lproj/Credits.rtf
  14. +2 −0 Play Item/Supporting Files/en.lproj/InfoPlist.strings
  15. +3,285 −0 Play Item/Supporting Files/en.lproj/MainMenu.xib
  16. BIN Play Item/Supporting Files/icon.icns
  17. +14 −0 Play Item/Supporting Files/main.m
  18. BIN Play Item/images/status-icon-inverted.png
  19. BIN Play Item/images/status-icon-off.png
  20. BIN Play Item/images/status-icon-on.png
  21. +43 −0 Play iOS/Classes/Controllers/PLAPlayerViewController.h
  22. +272 −0 Play iOS/Classes/Controllers/PLAPlayerViewController.m
  23. +108 −0 Play iOS/Classes/Controllers/PLAPlayerViewController_iPad.xib
  24. +474 −0 Play iOS/Classes/Controllers/PLAPlayerViewController_iPhone.xib
  25. +19 −0 Play iOS/PLAIOSAppDelegate.h
  26. +54 −0 Play iOS/PLAIOSAppDelegate.m
  27. +69 −0 Play iOS/Supporting Files/Play-iOS-Info.plist
  28. +14 −0 Play iOS/Supporting Files/Play-iOS-Prefix.pch
  29. +2 −0 Play iOS/Supporting Files/en.lproj/InfoPlist.strings
  30. +18 −0 Play iOS/Supporting Files/main.m
  31. BIN Play iOS/images/Default.png
  32. BIN Play iOS/images/Default@2x.png
  33. BIN Play iOS/images/bottom-shadow.png
  34. BIN Play iOS/images/bottom-shadow@2x.png
  35. BIN Play iOS/images/button-pause.png
  36. BIN Play iOS/images/button-pause@2x.png
  37. BIN Play iOS/images/button-play.png
  38. BIN Play iOS/images/button-play@2x.png
  39. BIN Play iOS/images/default_album.png
  40. BIN Play iOS/images/default_album@2x.png
  41. BIN Play iOS/images/icon-72.png
  42. BIN Play iOS/images/icon.png
  43. BIN Play iOS/images/icon@2x.png
  44. BIN Play iOS/images/shadow.png
  45. BIN Play iOS/images/shadow@2x.png
  46. +16 −0 README.md
  47. +475 −0 vendor/AFNetworking/AFHTTPClient.h
  48. +602 −0 vendor/AFNetworking/AFHTTPClient.m
  49. +96 −0 vendor/AFNetworking/AFHTTPRequestOperation.h
  50. +118 −0 vendor/AFNetworking/AFHTTPRequestOperation.m
  51. +123 −0 vendor/AFNetworking/AFImageRequestOperation.h
  52. +249 −0 vendor/AFNetworking/AFImageRequestOperation.m
  53. +68 −0 vendor/AFNetworking/AFJSONRequestOperation.h
  54. +152 −0 vendor/AFNetworking/AFJSONRequestOperation.m
  55. +26 −0 vendor/AFNetworking/AFJSONUtilities.h
  56. +169 −0 vendor/AFNetworking/AFJSONUtilities.m
  57. +66 −0 vendor/AFNetworking/AFNetworkActivityIndicatorManager.h
  58. +114 −0 vendor/AFNetworking/AFNetworkActivityIndicatorManager.m
  59. +44 −0 vendor/AFNetworking/AFNetworking.h
  60. +74 −0 vendor/AFNetworking/AFPropertyListRequestOperation.h
  61. +152 −0 vendor/AFNetworking/AFPropertyListRequestOperation.m
  62. +198 −0 vendor/AFNetworking/AFURLConnectionOperation.h
  63. +459 −0 vendor/AFNetworking/AFURLConnectionOperation.m
  64. +96 −0 vendor/AFNetworking/AFXMLRequestOperation.h
  65. +203 −0 vendor/AFNetworking/AFXMLRequestOperation.m
  66. +75 −0 vendor/AFNetworking/UIImageView+AFNetworking.h
  67. +191 −0 vendor/AFNetworking/UIImageView+AFNetworking.m
  68. +218 −0 vendor/AudioStreamer/AudioStreamer.h
  69. +2,426 −0 vendor/AudioStreamer/AudioStreamer.m
  70. +136 −0 vendor/AudioStreamer/UIDevice+Hardware.h
  71. +622 −0 vendor/AudioStreamer/UIDevice+Hardware.m
  72. +32 −0 vendor/SDWebImage/SDImageCache.h
  73. +340 −0 vendor/SDWebImage/SDImageCache.m
  74. +19 −0 vendor/SDWebImage/SDImageCacheDelegate.h
  75. +21 −0 vendor/SDWebImage/SDWebImageCompat.h
  76. +36 −0 vendor/SDWebImage/SDWebImageDecoder.h
  77. +124 −0 vendor/SDWebImage/SDWebImageDecoder.m
  78. +42 −0 vendor/SDWebImage/SDWebImageDownloader.h
  79. +174 −0 vendor/SDWebImage/SDWebImageDownloader.m
  80. +21 −0 vendor/SDWebImage/SDWebImageDownloaderDelegate.h
  81. +39 −0 vendor/SDWebImage/SDWebImageManager.h
  82. +290 −0 vendor/SDWebImage/SDWebImageManager.m
  83. +19 −0 vendor/SDWebImage/SDWebImageManagerDelegate.h
  84. +44 −0 vendor/SDWebImage/SDWebImagePrefetcher.h
  85. +112 −0 vendor/SDWebImage/SDWebImagePrefetcher.m
  86. +39 −0 vendor/SDWebImage/UIButton+WebCache.h
  87. +44 −0 vendor/SDWebImage/UIButton+WebCache.m
  88. +52 −0 vendor/SDWebImage/UIImageView+WebCache.h
  89. +48 −0 vendor/SDWebImage/UIImageView+WebCache.m
  90. +41 −0 vendor/SFHFKeychainUtils.h
  91. +384 −0 vendor/SFHFKeychainUtils.m
@@ -0,0 +1,16 @@
+# Xcode
+build/*
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+*.xcworkspace
+!default.xcworkspace
+xcuserdata
+profile
+*.moved-aside
+*.DS_Store
@@ -0,0 +1,16 @@
+Verion 1.2.1
+
+* Fixed bug where a nil metadata string crashes app
+* Now parses the infamous Deadmau5 song's metadata
+
+Version 1.2
+* Added ability to play/pause with media keys (@dannygreg)
+* Replaced the streaming backend with something way better - No more garbled music.
+
+Version 1.1
+* Added: Quit item
+* Added: Item to go straight to the Play website
+
+Version 1.0
+First Release
+
@@ -0,0 +1,17 @@
+//
+// PLPlayClient.h
+// Play
+//
+// Created by Jon Maddox on 2/9/12.
+// Copyright (c) 2012 GitHub, Inc. All rights reserved.
+//
+
+#import "AFHTTPClient.h"
+
+extern NSString * const kPLBaseURLString;
+
+@interface PLAPlayClient : AFHTTPClient
+
++ (id)sharedClient;
+
+@end
@@ -0,0 +1,48 @@
+//
+// PLPlayClient.m
+// Play
+//
+// Created by Jon Maddox on 2/9/12.
+// Copyright (c) 2012 GitHub, Inc. All rights reserved.
+//
+
+#import "PLAPlayClient.h"
+#import "AFJSONRequestOperation.h"
+
+NSString * const kPLBaseURLString = @"https://play.githubapp.com";
+
+@implementation PLAPlayClient
+
++ (PLAPlayClient *)sharedClient {
+ static PLAPlayClient *_sharedClient = nil;
+ static dispatch_once_t oncePredicate;
+
+ dispatch_once(&oncePredicate, ^{
+ _sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kPLBaseURLString]];
+ });
+
+ return _sharedClient;
+}
+
+- (id)initWithBaseURL:(NSURL *)url {
+ self = [super initWithBaseURL:url];
+ if (!self) {
+ return nil;
+ }
+
+ [self registerHTTPOperationClass:[AFJSONRequestOperation class]];
+ [self setDefaultHeader:@"Accept" value:@"application/json"];
+ [self setDefaultHeader:@"Accept-Encoding" value:@"gzip,deflate"];
+
+ return self;
+}
+
+
+
+
+
+
+
+
+
+@end
@@ -0,0 +1,31 @@
+//
+// PLTrack.h
+// Play
+//
+// Created by Jon Maddox on 2/9/12.
+// Copyright (c) 2012 GitHub, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface PLATrack : NSObject{
+ NSString *trackId;
+ NSString *name;
+ NSString *album;
+ NSString *artist;
+ BOOL starred;
+ BOOL queued;
+}
+
+@property (nonatomic, retain) NSString *trackId;
+@property (nonatomic, retain) NSString *name;
+@property (nonatomic, retain) NSString *album;
+@property (nonatomic, retain) NSString *artist;
+@property (nonatomic, assign) BOOL starred;
+@property (nonatomic, assign) BOOL queued;
+
+- (id)initWithAttributes:(NSDictionary *)attributes;
+- (NSString *)albumArtUrl;
++ (void)currentTrackWithBlock:(void(^)(PLATrack *track))block;
+
+@end
@@ -0,0 +1,55 @@
+//
+// PLTrack.m
+// Play
+//
+// Created by Jon Maddox on 2/9/12.
+// Copyright (c) 2012 GitHub, Inc. All rights reserved.
+//
+
+#import "PLATrack.h"
+#import "PLAPlayClient.h"
+
+@implementation PLATrack
+@synthesize trackId, name, album, artist, queued, starred;
+
+- (void)dealloc{
+ [trackId release];
+ [name release];
+ [album release];
+ [artist release];
+}
+
+- (id)initWithAttributes:(NSDictionary *)attributes {
+ self = [super init];
+ if (!self) {
+ return nil;
+ }
+
+ self.trackId = [attributes valueForKeyPath:@"id"];
+ self.name = [attributes valueForKeyPath:@"name"];
+ self.album = [attributes valueForKeyPath:@"album"];
+ self.artist = [attributes valueForKeyPath:@"artist"];
+ queued = [[attributes valueForKeyPath:@"queued"] boolValue];
+ starred = [[attributes valueForKeyPath:@"starred"] boolValue];
+
+ return self;
+}
+
++ (void)currentTrackWithBlock:(void(^)(PLATrack *track))block{
+ NSDictionary *parameters = [NSDictionary dictionaryWithObject:@"hubot" forKey:@"login"];
+
+ [[PLAPlayClient sharedClient] getPath:@"/now_playing" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
+ PLATrack *track = [[[PLATrack alloc] initWithAttributes:responseObject] autorelease];
+ block(track);
+ } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
+ NSLog(@"error: %@", error);
+ block(nil);
+ }];
+}
+
+- (NSString *)albumArtUrl{
+ return [NSString stringWithFormat:@"%@/images/art/%@.png?login=hubot", kPLBaseURLString, trackId];
+}
+
+
+@end

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,31 @@
+//
+// PLAItemAppDelegate.h
+// Play
+//
+// Created by Jon Maddox on 2/9/12.
+// Copyright (c) 2012 GitHub, Inc. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "AudioStreamer.h"
+
+@interface PLAItemAppDelegate : NSObject <NSApplicationDelegate>{
+ NSStatusItem *statusItem;
+ NSMenu *statusMenu;
+ AudioStreamer *streamer;
+}
+
+@property (strong) NSStatusItem *statusItem;
+@property (strong) IBOutlet NSMenu *statusMenu;
+@property (assign) IBOutlet NSWindow *window;
+
+- (NSMenuItem *)playStatusItem;
+- (NSMenuItem *)playActionItem;
+- (void)setPlayStatus:(NSString *)statusString;
+- (void)setPlayActionTitle:(NSString *)actionTitle;
+- (void)createStreamer;
+- (void)destroyStreamer;
+- (IBAction)togglePlayState;
+- (IBAction)goToPlay;
+
+@end
Oops, something went wrong.

0 comments on commit e1d6aad

Please sign in to comment.