您好我正在創建一個演示應用程序來記錄音頻。我按照這個教程從文檔到服務器發佈音頻文件
// Set the audio file
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
@"MyAudioMemo.m4a",
nil];
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
// Setup audio session
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
// Define the recorder setting
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
// Initiate and prepare the recorder
recorder = [[AVAudioRecorder alloc] initWithURL:outputFileURL settings:recordSetting error:NULL];
recorder.delegate = self;
recorder.meteringEnabled = YES;
[recorder prepareToRecord];
錄音部分工作正常並且應用程序正在播放的音頻文件,
問題: 我如何上傳錄製的文件到服務器。
有你實現web服務? –
您可以使用ASIHttpRequest或任何其他框架將outputFilePath上傳到服務器。請參閱http://allseeing-i.com/ASIHTTPRequest/ – Natarajan
如果問題是「如何上傳文件?」爲什麼要寫所有這些員工?請關閉此票並打開更具體的票。 – Avt