2014-01-22 79 views
0

我記錄視頻後出現問題,點擊使用按鈕將此視頻保存到庫中,但保存完成後,我無法點擊播放按鈕或重拍按鈕。這是我的代碼:單擊UIImagepickercontroller中的使用按鈕後無法點擊ios

-(void)actionLaunchAppCamera 
{ 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
    { 
     UIImagePickerController * imagePickerController = [[UIImagePickerController alloc] init]; 

     if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
      imagePickerController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; 
      imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 
      imagePickerController.showsCameraControls = YES; 
      imagePickerController.allowsEditing = YES; 
      imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo; 
      imagePickerController.delegate = self; 
      imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear; 

      [self presentModalViewController:imagePickerController animated:YES]; 
      //[imagePickerController release]; 
     } 
    } 
} 

保存所採取

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ 
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 
    NSURL *recordedVideoURL= [info objectForKey:UIImagePickerControllerMediaURL]; 

    if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:recordedVideoURL]) { 
     [library writeVideoAtPathToSavedPhotosAlbum:recordedVideoURL 
       completionBlock:^(NSURL *assetURL, NSError *error){ 
        [library assetForURL:assetURL resultBlock:^(ALAsset *asset) { 
         NSDate* date = [asset valueForProperty:ALAssetPropertyDate]; 
         NSLog(@"Date Time Modify %@",date); 
         NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease]; 
         [formatter setDateFormat: @"dd.MM.yyyy HH:mm:ss"]; 
         NSString* CurrentDateStamp = [formatter stringFromDate:date]; 

         NSLog(@"NameVideo %@",asset.defaultRepresentation.filename); 
         NSLog(@"DateModify %@",CurrentDateStamp); 
         NSLog(@"Size: %lld", asset.defaultRepresentation.size); 
        } failureBlock:nil]; 

actionSheetUpload= [[UIActionSheet alloc] initWithTitle:@"Do you want to upload this video?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Upload" otherButtonTitles:nil]; 
       actionSheetUpload.actionSheetStyle = UIActionSheetStyleBlackOpaque; 
       [actionSheetUpload showInView:[UIApplication sharedApplication].keyWindow]; 
       [actionSheetUpload release]; 
       } 
     ]; 
    } 
    [library release]; 
} 

任何想法的形象呢?在此先感謝

+1

又在哪裏是玩的代碼..?您只是保存視頻,之後需要播放視頻 –

+0

保存視頻後,我會將此視頻上傳到服務器。我更新了我的問題中的代碼。 – user3214941

+1

然後你應該使用播放器來播放它。 –

回答

0

該代碼是很好的保存視頻,如果你想得到它播放。然後你需要使用播放器來播放它。

例如:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ 
    NSURL *recordedVideoURL= [info objectForKey:UIImagePickerControllerMediaURL]; 
.// Save Your Stuff 
. 
. 

    MPMoviePlayerController *movieplayer =[[MPMoviePlayerController alloc] initWithContentURL: recordedVideoURL];  
    [[movieplayer view] setFrame: 
    [self.view bounds]]; 
    [self.view addSubview: 
    [movieplayer view]]; 
    [movieplayer play]; 
} 

編輯: 上傳影片,根據您的代碼: 聲明NSURL *recordedVideoURL;

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ 
    //NSLog(@"but ind %d", buttonIndex); 
    if (buttonIndex == uploadBTnIndex) { 
    NSData *videoData = [NSData dataWithContentsOfURL:recordedVideoURL]; 
    //Use this NSData to upload, So what else your problem to upload using web Services ? 
} 
+0

謝謝,但我不需要播放視頻。我只需要將其上傳到服務器。 – user3214941

+0

然後是什麼問題,你問我做完(保存)後上傳的代碼。 –

+0

我的問題是點擊使用視頻後,它會顯示工作表上傳,然後我點擊工作表上的取消,以支持UIImagePickercontroller,但UIImagePickerController似乎無法點擊任何按鈕。 – user3214941

0

也許你不排除選擇器與- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion