@@ -67,33 +67,34 @@ - (IBAction)recordingBtnClicked:(UIButton*)sender {
6767
6868 if ([_myCameraViewHandler isRecording ])
6969 {
70- [_myCameraViewHandler endRecording: ^{
70+ void (^finishBlock)( void ) = ^{
7171 NSLog (@" End recording...\n " );
72- }];
73-
74- [sender setTitle: @" 录制结束" forState: UIControlStateNormal];
75- NSURL *outputURL = [NSURL URLWithString: _pathToMovie];
76- ALAssetsLibrary *library = [[ALAssetsLibrary alloc ] init ];
77- if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum: outputURL])
78- {
79- [library writeVideoAtPathToSavedPhotosAlbum: outputURL completionBlock: ^(NSURL *assetURL, NSError *error)
72+
73+ [sender setTitle: @" 录制结束" forState: UIControlStateNormal];
74+ NSURL *outputURL = [NSURL URLWithString: _pathToMovie];
75+ ALAssetsLibrary *library = [[ALAssetsLibrary alloc ] init ];
76+ if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum: outputURL])
8077 {
81- dispatch_async (dispatch_get_main_queue (), ^{
82-
83- if (error) {
84- UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Error" message: @" Video Saving Failed"
85- delegate: nil cancelButtonTitle: @" OK" otherButtonTitles: nil ];
86- [alert show ];
87- } else {
88- UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Video Saved" message: @" Saved To Photo Album"
89- delegate: self cancelButtonTitle: @" OK" otherButtonTitles: nil ];
90- [alert show ];
91- }
92- });
93- }];
94- }
95-
78+ [library writeVideoAtPathToSavedPhotosAlbum: outputURL completionBlock: ^(NSURL *assetURL, NSError *error)
79+ {
80+ dispatch_async (dispatch_get_main_queue (), ^{
81+
82+ if (error)
83+ {
84+ UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Error" message: @" Video Saving Failed" delegate: nil cancelButtonTitle: @" OK" otherButtonTitles: nil ];
85+ [alert show ];
86+ }
87+ else
88+ {
89+ UIAlertView *alert = [[UIAlertView alloc ] initWithTitle: @" Video Saved" message: @" Saved To Photo Album" delegate: self cancelButtonTitle: @" OK" otherButtonTitles: nil ];
90+ [alert show ];
91+ }
92+ });
93+ }];
94+ }
95+ };
9696
97+ [_myCameraViewHandler endRecording: finishBlock];
9798 }
9899 else
99100 {
@@ -124,7 +125,7 @@ - (void)viewDidLoad
124125 [super viewDidLoad ];
125126 cgeSetLoadImageCallback (loadImageCallback, loadImageOKCallback, nil );
126127
127- _pathToMovie = [NSHomeDirectory () stringByAppendingPathComponent: @" Documents/Movie.m4v " ];
128+ _pathToMovie = [NSHomeDirectory () stringByAppendingPathComponent: @" Documents/Movie.mp4 " ];
128129
129130 CGRect rt = [[UIScreen mainScreen ] bounds ];
130131
0 commit comments