aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rw-r--r--Video Tuneup.xcodeproj/project.pbxproj6
-rw-r--r--Video Tuneup/Classes/WebserviceCommunicator.h17
-rw-r--r--Video Tuneup/Classes/WebserviceCommunicator.m78
-rw-r--r--Video Tuneup/ViewController.h6
-rw-r--r--Video Tuneup/ViewController.m12
-rw-r--r--Video Tuneup/en.lproj/ViewController_iPad.xib66
7 files changed, 187 insertions, 8 deletions
diff --git a/README.md b/README.md
index 2b86ce3..5482724 100644
--- a/README.md
+++ b/README.md
@@ -95,5 +95,11 @@ Maybe we can build a web-based version and api…
## AssetLibrary
-http://www.icodeblog.com/2010/07/08/asset-libraries-and-blocks-in-ios-4/
-http://www.youtube.com/watch?v=-5kAPVGYMf4
+* http://www.icodeblog.com/2010/07/08/asset-libraries-and-blocks-in-ios-4/
+* http://www.youtube.com/watch?v=-5kAPVGYMf4
+
+## Multipart NSMutableURLRequest
+* http://stackoverflow.com/questions/8042360/nsdata-and-uploading-images-via-post-in-ios
+* http://zcentric.com/2008/08/29/post-a-uiimage-to-the-web/
+* http://stackoverflow.com/questions/10051150/multiform-data-send-to-server-using-iphone-sdk
+* http://www.iphonedevsdk.com/forum/iphone-sdk-development/14919-how-upload-download-http-server.html
diff --git a/Video Tuneup.xcodeproj/project.pbxproj b/Video Tuneup.xcodeproj/project.pbxproj
index 74eb038..3cf1867 100644
--- a/Video Tuneup.xcodeproj/project.pbxproj
+++ b/Video Tuneup.xcodeproj/project.pbxproj
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
D19C74771547289A006E4122 /* AssetsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D19C74761547289A006E4122 /* AssetsViewController.m */; };
+ D1A3079F1548F71C00FA4A94 /* WebserviceCommunicator.m in Sources */ = {isa = PBXBuildFile; fileRef = D1A3079E1548F71C00FA4A94 /* WebserviceCommunicator.m */; };
D3531C9C1523B7BB00E286B8 /* SimpleEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = D3531C9B1523B7BB00E286B8 /* SimpleEditor.m */; };
D3531CA01523B8DA00E286B8 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3531C9F1523B8DA00E286B8 /* QuartzCore.framework */; };
D3531CA21523BE2900E286B8 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3531CA11523BE2900E286B8 /* AssetsLibrary.framework */; };
@@ -52,6 +53,8 @@
/* Begin PBXFileReference section */
D19C74751547289A006E4122 /* AssetsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AssetsViewController.h; path = Classes/AssetsViewController.h; sourceTree = "<group>"; };
D19C74761547289A006E4122 /* AssetsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AssetsViewController.m; path = Classes/AssetsViewController.m; sourceTree = "<group>"; };
+ D1A3079D1548F71C00FA4A94 /* WebserviceCommunicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebserviceCommunicator.h; path = Classes/WebserviceCommunicator.h; sourceTree = "<group>"; };
+ D1A3079E1548F71C00FA4A94 /* WebserviceCommunicator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebserviceCommunicator.m; path = Classes/WebserviceCommunicator.m; sourceTree = "<group>"; };
D3531C9A1523B7BB00E286B8 /* SimpleEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleEditor.h; sourceTree = "<group>"; };
D3531C9B1523B7BB00E286B8 /* SimpleEditor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleEditor.m; sourceTree = "<group>"; };
D3531C9D1523B89200E286B8 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
@@ -166,6 +169,8 @@
D3531C9A1523B7BB00E286B8 /* SimpleEditor.h */,
D3531C9B1523B7BB00E286B8 /* SimpleEditor.m */,
D36CCD4515227D06003CCAFC /* AppDelegate.m */,
+ D1A3079D1548F71C00FA4A94 /* WebserviceCommunicator.h */,
+ D1A3079E1548F71C00FA4A94 /* WebserviceCommunicator.m */,
D36CCD7615228B04003CCAFC /* Controllers */,
D36CCD7515228ADC003CCAFC /* Views */,
D36CCD4A15227D06003CCAFC /* ViewController_iPhone.xib */,
@@ -360,6 +365,7 @@
D36CCD7415228ACE003CCAFC /* PlayerView.m in Sources */,
D3531C9C1523B7BB00E286B8 /* SimpleEditor.m in Sources */,
D19C74771547289A006E4122 /* AssetsViewController.m in Sources */,
+ D1A3079F1548F71C00FA4A94 /* WebserviceCommunicator.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Video Tuneup/Classes/WebserviceCommunicator.h b/Video Tuneup/Classes/WebserviceCommunicator.h
new file mode 100644
index 0000000..5c0a378
--- /dev/null
+++ b/Video Tuneup/Classes/WebserviceCommunicator.h
@@ -0,0 +1,17 @@
+//
+// WebserviceCommunicator.h
+// Video Tuneup
+//
+// Created by tw on 4/25/12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface WebserviceCommunicator : NSObject <NSURLConnectionDelegate>
+
+@property (nonatomic, retain) NSFileHandle *fileHandle;
+
+-(void)mixMusic:(NSURL *)file;
+
+@end
diff --git a/Video Tuneup/Classes/WebserviceCommunicator.m b/Video Tuneup/Classes/WebserviceCommunicator.m
new file mode 100644
index 0000000..bffd7ac
--- /dev/null
+++ b/Video Tuneup/Classes/WebserviceCommunicator.m
@@ -0,0 +1,78 @@
+//
+// WebserviceCommunicator.m
+// Video Tuneup
+//
+// Created by tw on 4/25/12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "WebserviceCommunicator.h"
+
+#define BASEPATH (@"http://localhost:4567")
+
+@implementation WebserviceCommunicator
+
+@synthesize fileHandle;
+
+- (id)init {
+ self = [super init];
+ if (self) {
+ NSString *songPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"mixed_song.mp3"];
+ [[NSFileManager defaultManager] createFileAtPath:songPath contents:nil attributes:nil];
+ fileHandle = [NSFileHandle fileHandleForWritingAtPath:songPath];
+ }
+ return self;
+}
+
+-(void)mixMusic:(NSURL *)file {
+ NSString *uploadFileName = [file lastPathComponent];
+ NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/blend/%@", BASEPATH, uploadFileName]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:130.0]; // BASEPATH/blend/:filename
+ [request setHTTPMethod:@"POST"];
+ [request setHTTPShouldHandleCookies:NO];
+ NSString *boundary = @"--x-x-x-x-";
+ [request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] forHTTPHeaderField:@"Content-Type"];
+
+ NSData *songData = [NSData dataWithContentsOfURL:file];
+ NSMutableData *requestData = [[NSMutableData alloc] init];
+
+// To send extra params:
+//
+// for (NSString *paramName in params) ...
+// [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+// [body appendData:[@"Content-Disposition: form-data; name=\"photo-description\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+// [body appendData:[@"testing 123" dataUsingEncoding:NSUTF8StringEncoding]];
+// [body appendData:[[NSString stringWithFormat:@"%@\r\n", [_params objectForKey:param]] dataUsingEncoding:NSUTF8StringEncoding]];
+
+ [requestData appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+ [requestData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", @"data", uploadFileName] dataUsingEncoding:NSUTF8StringEncoding]];
+ [requestData appendData:[@"Content-Type: audio/mpeg\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+ [requestData appendData:songData];
+ [requestData appendData:[[NSString stringWithFormat:@"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
+
+ [requestData appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+
+ [request setHTTPBody:requestData];
+
+ (void)[[NSURLConnection alloc] initWithRequest:request delegate:self];
+}
+
+#pragma mark NSURLConnection delegate methods
+
+-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
+ NSLog(@"Got response data");
+
+ [fileHandle seekToEndOfFile];
+ [fileHandle writeData:data];
+}
+
+-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
+ NSLog(@"Song send failed");
+}
+
+-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
+ NSLog(@"Song send finished loading.");
+
+ [fileHandle closeFile];
+}
+
+@end
diff --git a/Video Tuneup/ViewController.h b/Video Tuneup/ViewController.h
index 78d033b..c9ae6a4 100644
--- a/Video Tuneup/ViewController.h
+++ b/Video Tuneup/ViewController.h
@@ -15,7 +15,7 @@
@class PlayerView;
// UIImagePickerControllerDelegate requires that we conform to UINavigationControllerDelegate
-@interface ViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
+@interface ViewController : UIViewController <MPMediaPickerControllerDelegate> {
AVURLAsset *asset;
AVURLAsset *songAsset;
@@ -39,6 +39,8 @@
@property (nonatomic, retain) IBOutlet UIButton *mediaLibraryButton;
@property (nonatomic, retain) UIPopoverController *mediaLibraryPopover;
+@property (nonatomic, retain) IBOutlet UIButton *derpSendPostRequestButton;
+
- (void)hideCameraRollText;
- (IBAction)loadDefaultAssetFromFile:sender;
@@ -61,4 +63,6 @@
- (void)exportDidFinish:(AVAssetExportSession*)session;
- (IBAction)showMediaLibrary:(id)sender;
+
+- (IBAction)derpSendPostRequest:(id)sender;
@end \ No newline at end of file
diff --git a/Video Tuneup/ViewController.m b/Video Tuneup/ViewController.m
index 73a1e67..ec31aa6 100644
--- a/Video Tuneup/ViewController.m
+++ b/Video Tuneup/ViewController.m
@@ -11,6 +11,8 @@
#import "SimpleEditor.h"
#import "AssetsViewController.h"
+#import "WebserviceCommunicator.h"
+
// Define this constant for the key-value observation context.
static const NSString *ItemStatusContext;
@@ -20,6 +22,8 @@ static const NSString *ItemStatusContext;
@synthesize player, playerItem, playerView, playButton, pauseButton, rewindButton, editor, videoNavBar, exportStatus,
mScrubber, mediaLibraryButton, mediaLibraryPopover;
+@synthesize derpSendPostRequestButton;
+
#pragma mark - Video playback
- (void)syncUI {
@@ -458,6 +462,14 @@ mScrubber, mediaLibraryButton, mediaLibraryPopover;
[self.mediaLibraryPopover presentPopoverFromRect:[theButton bounds] inView:theButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
+#pragma mark DEEEERRRRRRRRRRRRPPPPPPPPPPPPP
+
+- (IBAction)derpSendPostRequest:(id)sender {
+ WebserviceCommunicator *com = [[WebserviceCommunicator alloc] init];
+ NSURL *songFileURL = [[NSBundle mainBundle] URLForResource:@"song" withExtension:@"mp3"];
+ [com mixMusic:songFileURL];
+}
+
#pragma mark - View controller boilerplate
- (void)didReceiveMemoryWarning {
diff --git a/Video Tuneup/en.lproj/ViewController_iPad.xib b/Video Tuneup/en.lproj/ViewController_iPad.xib
index 8879bbb..346f2e0 100644
--- a/Video Tuneup/en.lproj/ViewController_iPad.xib
+++ b/Video Tuneup/en.lproj/ViewController_iPad.xib
@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1280</int>
- <string key="IBDocument.SystemVersion">11D50d</string>
+ <string key="IBDocument.SystemVersion">10K549</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
- <string key="IBDocument.AppKitVersion">1138.32</string>
- <string key="IBDocument.HIToolboxVersion">568.00</string>
+ <string key="IBDocument.AppKitVersion">1038.36</string>
+ <string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">933</string>
@@ -267,7 +267,7 @@
<string key="NSFrame">{{580, 906}, {75, 37}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
+ <reference key="NSNextKeyView" ref="267035392"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -283,6 +283,28 @@
<reference key="IBUIFontDescription" ref="1067550929"/>
<reference key="IBUIFont" ref="361109798"/>
</object>
+ <object class="IBUIButton" id="267035392">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{7, 960}, {262, 37}}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <int key="IBUIButtonType">1</int>
+ <string key="IBUINormalTitle">DerpyButtonToSendPostRequest</string>
+ <reference key="IBUIHighlightedTitleColor" ref="804940373"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="752673392"/>
+ <reference key="IBUIFontDescription" ref="1067550929"/>
+ <reference key="IBUIFont" ref="361109798"/>
+ </object>
</array>
<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
<reference key="NSSuperview"/>
@@ -371,6 +393,14 @@
<int key="connectionID">60</int>
</object>
<object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">derpSendPostRequestButton</string>
+ <reference key="source" ref="841351856"/>
+ <reference key="destination" ref="267035392"/>
+ </object>
+ <int key="connectionID">66</int>
+ </object>
+ <object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">loadDefaultAssetFromFile:</string>
<reference key="source" ref="1049445720"/>
@@ -467,6 +497,15 @@
</object>
<int key="connectionID">64</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">derpSendPostRequest:</string>
+ <reference key="source" ref="267035392"/>
+ <reference key="destination" ref="841351856"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">67</int>
+ </object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -498,6 +537,7 @@
<reference ref="761978491"/>
<reference ref="938661883"/>
<reference ref="27096655"/>
+ <reference ref="267035392"/>
</array>
<reference key="parent" ref="0"/>
</object>
@@ -595,6 +635,11 @@
<reference key="object" ref="27096655"/>
<reference key="parent" ref="766721923"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">65</int>
+ <reference key="object" ref="267035392"/>
+ <reference key="parent" ref="766721923"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -618,6 +663,7 @@
<string key="47.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="59.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="62.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="65.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="7.CustomClassName">PlayerView</string>
<string key="7.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
@@ -625,7 +671,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">64</int>
+ <int key="maxID">67</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -641,6 +687,7 @@
<string key="className">ViewController</string>
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="actions">
+ <string key="derpSendPostRequest:">id</string>
<string key="exportToCameraRoll:">id</string>
<string key="loadAssetFromFile:">id</string>
<string key="loadAudioFromFile:">id</string>
@@ -650,6 +697,10 @@
<string key="showMediaLibrary:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
+ <object class="IBActionInfo" key="derpSendPostRequest:">
+ <string key="name">derpSendPostRequest:</string>
+ <string key="candidateClassName">id</string>
+ </object>
<object class="IBActionInfo" key="exportToCameraRoll:">
<string key="name">exportToCameraRoll:</string>
<string key="candidateClassName">id</string>
@@ -680,6 +731,7 @@
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
+ <string key="derpSendPostRequestButton">UIButton</string>
<string key="exportStatus">UILabel</string>
<string key="mScrubber">UISlider</string>
<string key="mediaLibraryButton">UIButton</string>
@@ -690,6 +742,10 @@
<string key="videoNavBar">UIToolbar</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <object class="IBToOneOutletInfo" key="derpSendPostRequestButton">
+ <string key="name">derpSendPostRequestButton</string>
+ <string key="candidateClassName">UIButton</string>
+ </object>
<object class="IBToOneOutletInfo" key="exportStatus">
<string key="name">exportStatus</string>
<string key="candidateClassName">UILabel</string>