2
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];


    //get the videoURL 
    NSString *tempFilePath = [videoURL path];


    if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath))
    {
      // Copy it to the camera roll.
      UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), tempFilePath);
    } 



    //NSURL *movieUrl = [NSURL fileURLWithPath:filePath];
    _videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
    _videoPlayer.view.frame = CGRectMake(kMarginWidth, kMarginWidth, kMPlayerWidth, kMPlayerHeight);

    // Here is where you set the control Style like fullscreen or embedded
    _videoPlayer.controlStyle = MPMovieControlStyleDefault;
    _videoPlayer.scalingMode = MPMovieScalingModeAspectFit;
    _videoPlayer.contentURL = videoURL; 

     self addSubview:_videoPlayer];

}

但 videoPlayer 无法正常工作,只会在屏幕上显示“正在加载电影”几秒钟。

那么有人可以告诉我如何播放保存的视频吗?或者如何检索相册中保存视频的路径?

4

0 回答 0