aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Video Tuneup/Classes/WebserviceCommunicator.h7
-rw-r--r--Video Tuneup/Classes/WebserviceCommunicator.m17
-rw-r--r--Video Tuneup/ViewController.h2
-rw-r--r--Video Tuneup/ViewController.m7
-rw-r--r--Video Tuneup/en.lproj/ViewController_iPad.xib2
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 <Foundation/Foundation.h>
+#import "ViewController.h"
-@interface WebserviceCommunicator : NSObject <NSURLConnectionDelegate>
+@interface WebserviceCommunicator : NSObject <NSURLConnectionDelegate>{
+ 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 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
- <string key="label">derpSendPostRequest:</string>
+ <string key="label">sendMixRequest:</string>
<reference key="source" ref="267035392"/>
<reference key="destination" ref="841351856"/>
<int key="IBEventType">7</int>