アプリがバックグラウンドに移行したときに、ビデオを GPUImage videoCamera からカメラ ロールに保存する際に問題が発生しています。ファイルは、アプリがフォアグラウンドに戻ったとき/再起動されたときにのみカメラロールに保存されます。私は間違いなく初心者のコードエラーを作成しています。誰かがそれを指摘できれば幸いです。
- (void)applicationDidEnterBackground:(UIApplication *)application {
if (isRecording){
[self stopRecording];
};
if (self.isViewLoaded && self.view.window){
[videoCamera stopCameraCapture];
};
runSynchronouslyOnVideoProcessingQueue(^{
glFinish();
});
NSLog(@"applicationDidEnterBackground");
その後
-(void)stopRecording {
[filterBlend removeTarget:movieWriter];
videoCamera.audioEncodingTarget = nil;
[movieWriter finishRecording];
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"file.mov"];
ALAssetsLibrary *al = [[ALAssetsLibrary alloc] init];
[al writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:path] completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"Error %@", error);
} else {
NSLog(@"Success");
}
}];
isRecording = NO;
NSLog(@"Stop recording");