From cf1969fa1dc7f944b5edf37d04b84996ef0b6320 Mon Sep 17 00:00:00 2001 From: Brian Jordan Date: Thu, 26 Apr 2012 14:25:43 -0400 Subject: fix build, add ViewController reference to WebserviceCommunicator --- Video Tuneup/Classes/WebserviceCommunicator.h | 7 ++++++- Video Tuneup/Classes/WebserviceCommunicator.m | 17 ++++++++++++++--- Video Tuneup/ViewController.h | 2 +- Video Tuneup/ViewController.m | 7 ++++--- Video Tuneup/en.lproj/ViewController_iPad.xib | 2 +- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Video Tuneup/Classes/WebserviceCommunicator.h b/Video Tuneup/Classes/WebserviceCommunicator.h index 5c0a378..3eb9e7a 100644 --- a/Video Tuneup/Classes/WebserviceCommunicator.h +++ b/Video Tuneup/Classes/WebserviceCommunicator.h @@ -7,11 +7,16 @@ // #import +#import "ViewController.h" -@interface WebserviceCommunicator : NSObject +@interface WebserviceCommunicator : NSObject { + ViewController* _viewController; +} @property (nonatomic, retain) NSFileHandle *fileHandle; +@property (nonatomic, retain) NSString *songPath; -(void)mixMusic:(NSURL *)file; +-(void)setParentController:(ViewController *)viewController; @end diff --git a/Video Tuneup/Classes/WebserviceCommunicator.m b/Video Tuneup/Classes/WebserviceCommunicator.m index bffd7ac..c8ca27f 100644 --- a/Video Tuneup/Classes/WebserviceCommunicator.m +++ b/Video Tuneup/Classes/WebserviceCommunicator.m @@ -12,12 +12,12 @@ @implementation WebserviceCommunicator -@synthesize fileHandle; +@synthesize fileHandle, songPath; - (id)init { self = [super init]; if (self) { - NSString *songPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"mixed_song.mp3"]; + songPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"mixed_song.mp3"]; [[NSFileManager defaultManager] createFileAtPath:songPath contents:nil attributes:nil]; fileHandle = [NSFileHandle fileHandleForWritingAtPath:songPath]; } @@ -56,6 +56,12 @@ (void)[[NSURLConnection alloc] initWithRequest:request delegate:self]; } + +- (void)setParentController:(ViewController *)viewController { + _viewController = viewController; +} + + #pragma mark NSURLConnection delegate methods -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { @@ -71,8 +77,13 @@ -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"Song send finished loading."); - + [fileHandle closeFile]; + + // This is happening before file is completely sent back. Need to change timeout. + + NSLog(@"Received song path is %@", songPath); +// [_viewController loadAudioFromFile:[NSURL URLWithString:songPath]]; } @end diff --git a/Video Tuneup/ViewController.h b/Video Tuneup/ViewController.h index c9ae6a4..669bd5f 100644 --- a/Video Tuneup/ViewController.h +++ b/Video Tuneup/ViewController.h @@ -64,5 +64,5 @@ - (IBAction)showMediaLibrary:(id)sender; -- (IBAction)derpSendPostRequest:(id)sender; +- (IBAction)sendMixRequest:(id)sender; @end \ No newline at end of file diff --git a/Video Tuneup/ViewController.m b/Video Tuneup/ViewController.m index ec31aa6..50b9e51 100644 --- a/Video Tuneup/ViewController.m +++ b/Video Tuneup/ViewController.m @@ -146,7 +146,7 @@ mScrubber, mediaLibraryButton, mediaLibraryPopover; NSLog(@"Got media item"); // NSLog(@"%@",[[[mediaItemCollection items] objectAtIndex:0]valueForKey:MPMediaItemPropertyTitle]); -// NSURL *url = [[[mediaItemCollection items] objectAtIndex:0] valueForProperty:MPMediaItemPropertyAssetURL]; + NSURL *url = [[[mediaItemCollection items] objectAtIndex:0] valueForProperty:MPMediaItemPropertyAssetURL]; // NSLog(@"%@", url); [self loadAudioFromFile:url]; @@ -462,11 +462,12 @@ mScrubber, mediaLibraryButton, mediaLibraryPopover; [self.mediaLibraryPopover presentPopoverFromRect:[theButton bounds] inView:theButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } -#pragma mark DEEEERRRRRRRRRRRRPPPPPPPPPPPPP +#pragma mark - Networking -- (IBAction)derpSendPostRequest:(id)sender { +- (IBAction)sendMixRequest:(id)sender { WebserviceCommunicator *com = [[WebserviceCommunicator alloc] init]; NSURL *songFileURL = [[NSBundle mainBundle] URLForResource:@"song" withExtension:@"mp3"]; + [com setParentController:self]; [com mixMusic:songFileURL]; } diff --git a/Video Tuneup/en.lproj/ViewController_iPad.xib b/Video Tuneup/en.lproj/ViewController_iPad.xib index 346f2e0..021db75 100644 --- a/Video Tuneup/en.lproj/ViewController_iPad.xib +++ b/Video Tuneup/en.lproj/ViewController_iPad.xib @@ -499,7 +499,7 @@ - derpSendPostRequest: + sendMixRequest: 7 -- cgit v1.2.3