I am going to create app where I am going to record video with audio and then play it.
For this I am using AVCaptureManager in my code.
Here if video is about 10 second, both audio and video playing and it's working fine.
But if I recorded videos more than 10 second, Only video play silently(No sound play on that).
Here is my code.
- (void)startRecording
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/GeneralInstruction"];
NSError *error;
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]; //Create folder
NSDate *time = [NSDate date];
NSDateFormatter* df = [NSDateFormatter new];
[df setDateFormat:@"ddMMyyyyhhmmss"];
NSString *timeString = [df stringFromDate:time];
NSString *myUniqueNames = [NSString stringWithFormat:@"%@", timeString];
NSString *myUniqueName = [NSString stringWithFormat:@"file://%@/%@.mp4",dataPath, myUniqueNames];
[self.fileOutput startRecordingToOutputFileURL:[NSURL URLWithString:myUniqueName] recordingDelegate:self];
}
After that when i complete the recording it comes...
#pragma mark - AVCaptureFileOutputRecordingDelegate
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput
didStartRecordingToOutputFileAtURL:(NSURL *)fileURL
fromConnections:(NSArray *)connections
{
_isRecording = YES;
}
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
fromConnections:(NSArray *)connections error:(NSError *)error
{// [self saveRecordedFile:outputFileURL];
_isRecording = NO;
if ([self.delegate respondsToSelector:@selector(didFinishRecordingToOutputFileAtURL:error:)]) {
[self.delegate didFinishRecordingToOutputFileAtURL:outputFileURL error:error];
}
}